From 496de2712fd1b70eb607e8d83ce3950f8c177892 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sun, 25 Apr 2021 10:45:16 -0300 Subject: [PATCH] Give priority to submodule in out_kicost --- kibot/misc.py | 1 + kibot/out_kicost.py | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kibot/misc.py b/kibot/misc.py index 5764ea9a..305ae8a1 100644 --- a/kibot/misc.py +++ b/kibot/misc.py @@ -71,6 +71,7 @@ CMD_IBOM = 'generate_interactive_bom.py' URL_IBOM = 'https://github.com/INTI-CMNB/InteractiveHtmlBom' CMD_KICOST = 'kicost' URL_KICOST = 'https://github.com/INTI-CMNB/KiCost' +KICOST_SUBMODULE = '../submodules/KiCost/src/kicost' KICAD2STEP = 'kicad2step' PCBDRAW = 'pcbdraw' URL_PCBDRAW = 'https://github.com/INTI-CMNB/pcbdraw' diff --git a/kibot/out_kicost.py b/kibot/out_kicost.py index 141603dd..aca5a3fc 100644 --- a/kibot/out_kicost.py +++ b/kibot/out_kicost.py @@ -3,9 +3,9 @@ # Copyright (c) 2021 Instituto Nacional de TecnologĂ­a Industrial # License: GPL-3.0 # Project: KiBot (formerly KiPlot) -from os.path import isfile +from os.path import isfile, abspath, join, dirname from subprocess import check_output, STDOUT, CalledProcessError -from .misc import CMD_KICOST, URL_KICOST, BOM_ERROR, DISTRIBUTORS, W_UNKDIST, ISO_CURRENCIES, W_UNKCUR +from .misc import CMD_KICOST, URL_KICOST, BOM_ERROR, DISTRIBUTORS, W_UNKDIST, ISO_CURRENCIES, W_UNKCUR, KICOST_SUBMODULE from .error import KiPlotConfigurationError from .optionable import Optionable from .gs import GS @@ -137,9 +137,12 @@ class KiCostOptions(VariantOptions): logger.error('You can generate it using the `update_xml` pre-flight') exit(BOM_ERROR) # Check KiCost is available - check_script(CMD_KICOST, URL_KICOST) + cmd_kicost = abspath(join(dirname(__file__), KICOST_SUBMODULE)) + if not isfile(cmd_kicost): + check_script(CMD_KICOST, URL_KICOST) + cmd_kicost = CMD_KICOST # Construct the command - cmd = [CMD_KICOST, '-w', '-o', name, '-i', netlist] + cmd = [cmd_kicost, '-w', '-o', name, '-i', netlist] # Add the rest of input files and their variants if self.aggregate: # More than one project