[Dependencies] Added auto-download for iBoM
This commit is contained in:
parent
166e927ca4
commit
59d6d2caac
|
|
@ -133,7 +133,7 @@ Notes:
|
||||||
- Mandatory for `pcbdraw`
|
- Mandatory for `pcbdraw`
|
||||||
- Optional to create realistic solder masks for `pcb_print`
|
- Optional to create realistic solder masks for `pcb_print`
|
||||||
|
|
||||||
[**Interactive HTML BoM**](https://github.com/INTI-CMNB/InteractiveHtmlBom) v2.4.1.4 [](https://github.com/INTI-CMNB/InteractiveHtmlBom)
|
[**Interactive HTML BoM**](https://github.com/INTI-CMNB/InteractiveHtmlBom) v2.4.1.4 [](https://github.com/INTI-CMNB/InteractiveHtmlBom) 
|
||||||
- Mandatory for `ibom`
|
- Mandatory for `ibom`
|
||||||
|
|
||||||
[**KiBoM**](https://github.com/INTI-CMNB/KiBoM) v1.8.0 [](https://github.com/INTI-CMNB/KiBoM) 
|
[**KiBoM**](https://github.com/INTI-CMNB/KiBoM) v1.8.0 [](https://github.com/INTI-CMNB/KiBoM) 
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ import site
|
||||||
from sys import exit, stdout
|
from sys import exit, stdout
|
||||||
from shutil import which, rmtree, move
|
from shutil import which, rmtree, move
|
||||||
from math import ceil
|
from math import ceil
|
||||||
from .kiplot import search_as_plugin
|
|
||||||
from .misc import MISSING_TOOL, TRY_INSTALL_CHECK, W_DOWNTOOL, W_MISSTOOL, USER_AGENT
|
from .misc import MISSING_TOOL, TRY_INSTALL_CHECK, W_DOWNTOOL, W_MISSTOOL, USER_AGENT
|
||||||
|
from .gs import GS
|
||||||
from . import log
|
from . import log
|
||||||
|
|
||||||
logger = log.get_logger()
|
logger = log.get_logger()
|
||||||
|
|
@ -32,6 +32,20 @@ version_check_fail = False
|
||||||
binary_tools_cache = {}
|
binary_tools_cache = {}
|
||||||
|
|
||||||
|
|
||||||
|
def search_as_plugin(cmd, names):
|
||||||
|
""" If a command isn't in the path look for it in the KiCad plugins """
|
||||||
|
name = which(cmd)
|
||||||
|
if name is not None:
|
||||||
|
return name
|
||||||
|
for dir in GS.kicad_plugins_dirs:
|
||||||
|
for name in names:
|
||||||
|
fname = os.path.join(dir, name, cmd)
|
||||||
|
if os.path.isfile(fname):
|
||||||
|
logger.debug('Using `{}` for `{}` ({})'.format(fname, cmd, name))
|
||||||
|
return fname
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def show_progress(done):
|
def show_progress(done):
|
||||||
stdout.write("\r[%s%s] %3d%%" % ('=' * done, ' ' * (50-done), 2*done))
|
stdout.write("\r[%s%s] %3d%%" % ('=' * done, ' ' * (50-done), 2*done))
|
||||||
stdout.flush()
|
stdout.flush()
|
||||||
|
|
@ -423,8 +437,9 @@ def do_int(v):
|
||||||
return int(v) if v is not None else 0
|
return int(v) if v is not None else 0
|
||||||
|
|
||||||
|
|
||||||
def run_command(cmd, only_first_line=True, pre_ver_text=None, no_err_2=False):
|
def run_command(cmd, only_first_line=False, pre_ver_text=None, no_err_2=False):
|
||||||
global last_stderr
|
global last_stderr
|
||||||
|
logger.debugl(3, '- Running {}'.format(cmd))
|
||||||
try:
|
try:
|
||||||
res_run = subprocess.run(cmd, check=True, capture_output=True)
|
res_run = subprocess.run(cmd, check=True, capture_output=True)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
|
|
@ -445,6 +460,7 @@ def run_command(cmd, only_first_line=True, pre_ver_text=None, no_err_2=False):
|
||||||
for pre_ver in pre_vers:
|
for pre_ver in pre_vers:
|
||||||
if pre_ver and res.startswith(pre_ver):
|
if pre_ver and res.startswith(pre_ver):
|
||||||
res = res[len(pre_ver):]
|
res = res[len(pre_ver):]
|
||||||
|
logger.debugl(3, '- Looking for version in `{}`'.format(res))
|
||||||
res = ver_re.search(res)
|
res = ver_re.search(res)
|
||||||
if res:
|
if res:
|
||||||
return tuple(map(do_int, res.groups()))
|
return tuple(map(do_int, res.groups()))
|
||||||
|
|
|
||||||
|
|
@ -135,19 +135,6 @@ def check_eeschema_do():
|
||||||
check_script(CMD_EESCHEMA_DO, URL_EESCHEMA_DO, '1.5.4')
|
check_script(CMD_EESCHEMA_DO, URL_EESCHEMA_DO, '1.5.4')
|
||||||
|
|
||||||
|
|
||||||
def search_as_plugin(cmd, names):
|
|
||||||
""" If a command isn't in the path look for it in the KiCad plugins """
|
|
||||||
if which(cmd) is not None:
|
|
||||||
return cmd
|
|
||||||
for dir in GS.kicad_plugins_dirs:
|
|
||||||
for name in names:
|
|
||||||
fname = os.path.join(dir, name, cmd)
|
|
||||||
if os.path.isfile(fname):
|
|
||||||
logger.debug('Using `{}` for `{}` ({})'.format(fname, cmd, name))
|
|
||||||
return fname
|
|
||||||
return cmd
|
|
||||||
|
|
||||||
|
|
||||||
def extract_errors(text):
|
def extract_errors(text):
|
||||||
in_error = in_warning = False
|
in_error = in_warning = False
|
||||||
msg = ''
|
msg = ''
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import os
|
||||||
from subprocess import (check_output, STDOUT, CalledProcessError)
|
from subprocess import (check_output, STDOUT, CalledProcessError)
|
||||||
from shutil import which
|
from shutil import which
|
||||||
from .misc import (CMD_IBOM, URL_IBOM, BOM_ERROR, W_EXTNAME, ToolDependency, ToolDependencyRole, W_NONETLIST)
|
from .misc import (CMD_IBOM, URL_IBOM, BOM_ERROR, W_EXTNAME, ToolDependency, ToolDependencyRole, W_NONETLIST)
|
||||||
from .gs import (GS)
|
from .gs import GS
|
||||||
from .kiplot import check_script, search_as_plugin
|
from .dep_downloader import check_tool, pytool_downloader
|
||||||
from .out_base import VariantOptions
|
from .out_base import VariantOptions
|
||||||
from .registrable import RegDependency
|
from .registrable import RegDependency
|
||||||
from .macros import macros, document, output_class # noqa: F401
|
from .macros import macros, document, output_class # noqa: F401
|
||||||
|
|
@ -18,15 +18,11 @@ logger = log.get_logger()
|
||||||
WARNING_MIX = "Avoid using it in conjunction with IBoM native filtering options"
|
WARNING_MIX = "Avoid using it in conjunction with IBoM native filtering options"
|
||||||
PLUGIN_NAMES = ['InteractiveHtmlBom', 'InteractiveHtmlBom/InteractiveHtmlBom',
|
PLUGIN_NAMES = ['InteractiveHtmlBom', 'InteractiveHtmlBom/InteractiveHtmlBom',
|
||||||
'org_openscopeproject_InteractiveHtmlBom/InteractiveHtmlBom']
|
'org_openscopeproject_InteractiveHtmlBom/InteractiveHtmlBom']
|
||||||
RegDependency.register(ToolDependency('ibom', 'Interactive HTML BoM', URL_IBOM, url_down=URL_IBOM+'/releases',
|
ibom_dep = ToolDependency('ibom', 'Interactive HTML BoM', URL_IBOM, url_down=URL_IBOM+'/releases',
|
||||||
command=CMD_IBOM, in_debian=False, no_cmd_line_version_old=True,
|
command=CMD_IBOM, in_debian=False, no_cmd_line_version_old=True,
|
||||||
plugin_dirs=PLUGIN_NAMES, roles=ToolDependencyRole(version=(2, 4, 1, 4))))
|
plugin_dirs=PLUGIN_NAMES, downloader=pytool_downloader,
|
||||||
|
roles=ToolDependencyRole(version=(2, 4, 1, 4)))
|
||||||
|
RegDependency.register(ibom_dep)
|
||||||
def check_tool():
|
|
||||||
tool = search_as_plugin(CMD_IBOM, PLUGIN_NAMES)
|
|
||||||
check_script(tool, URL_IBOM)
|
|
||||||
return tool
|
|
||||||
|
|
||||||
|
|
||||||
class IBoMOptions(VariantOptions):
|
class IBoMOptions(VariantOptions):
|
||||||
|
|
@ -149,7 +145,7 @@ class IBoMOptions(VariantOptions):
|
||||||
|
|
||||||
def run(self, name):
|
def run(self, name):
|
||||||
super().run(name)
|
super().run(name)
|
||||||
tool = check_tool()
|
tool = check_tool(ibom_dep, fatal=True)
|
||||||
logger.debug('Doing Interactive BoM')
|
logger.debug('Doing Interactive BoM')
|
||||||
# Tell ibom we don't want to use the screen
|
# Tell ibom we don't want to use the screen
|
||||||
os.environ['INTERACTIVE_HTML_BOM_NO_DISPLAY'] = ''
|
os.environ['INTERACTIVE_HTML_BOM_NO_DISPLAY'] = ''
|
||||||
|
|
@ -226,11 +222,7 @@ class IBoM(BaseOutput): # noqa: F821
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_conf_examples(name, layers, templates):
|
def get_conf_examples(name, layers, templates):
|
||||||
enabled = True
|
tool = check_tool(ibom_dep)
|
||||||
try:
|
if tool is None:
|
||||||
check_tool()
|
|
||||||
except SystemExit:
|
|
||||||
enabled = False
|
|
||||||
if not enabled:
|
|
||||||
return None
|
return None
|
||||||
return BaseOutput.simple_conf_examples(name, 'Interactive HTML BoM', 'Assembly') # noqa: F821
|
return BaseOutput.simple_conf_examples(name, 'Interactive HTML BoM', 'Assembly') # noqa: F821
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ deps = '{\
|
||||||
"Interactive HTML BoM": {\
|
"Interactive HTML BoM": {\
|
||||||
"command": "generate_interactive_bom.py",\
|
"command": "generate_interactive_bom.py",\
|
||||||
"deb_package": "interactive html bom",\
|
"deb_package": "interactive html bom",\
|
||||||
"downloader": null,\
|
"downloader": {},\
|
||||||
"extra_deb": null,\
|
"extra_deb": null,\
|
||||||
"help_option": "--version",\
|
"help_option": "--version",\
|
||||||
"importance": 10000,\
|
"importance": 10000,\
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ from kibot.layer import Layer
|
||||||
from kibot.pre_base import BasePreFlight
|
from kibot.pre_base import BasePreFlight
|
||||||
from kibot.out_base import BaseOutput
|
from kibot.out_base import BaseOutput
|
||||||
from kibot.gs import GS
|
from kibot.gs import GS
|
||||||
from kibot.kiplot import load_actions, _import, load_board, search_as_plugin, generate_makefile
|
from kibot.kiplot import load_actions, _import, load_board, generate_makefile
|
||||||
|
from kibot.dep_downloader import search_as_plugin
|
||||||
from kibot.registrable import RegOutput, RegFilter
|
from kibot.registrable import RegOutput, RegFilter
|
||||||
from kibot.misc import (WRONG_INSTALL, BOM_ERROR, DRC_ERROR, ERC_ERROR, PDF_PCB_PRINT, CMD_PCBNEW_PRINT_LAYERS, KICAD2STEP_ERR)
|
from kibot.misc import (WRONG_INSTALL, BOM_ERROR, DRC_ERROR, ERC_ERROR, PDF_PCB_PRINT, CMD_PCBNEW_PRINT_LAYERS, KICAD2STEP_ERR)
|
||||||
from kibot.bom.columnlist import ColumnList
|
from kibot.bom.columnlist import ColumnList
|
||||||
|
|
@ -308,7 +309,7 @@ def test_search_as_plugin_fail(test_dir, caplog):
|
||||||
dir_fake = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data')
|
dir_fake = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data')
|
||||||
GS.kicad_plugins_dirs.append(dir_fake)
|
GS.kicad_plugins_dirs.append(dir_fake)
|
||||||
fname = search_as_plugin('fake', [''])
|
fname = search_as_plugin('fake', [''])
|
||||||
assert fname == 'fake'
|
assert fname is None
|
||||||
|
|
||||||
|
|
||||||
def test_layer_no_id():
|
def test_layer_no_id():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue