From 0a3dff85f24ffaf1b05a82104b11df3a942a045e Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 26 May 2022 09:34:44 -0300 Subject: [PATCH] Added support for iBoM installed as plugin - Not yet functional, we are working on iBoM layout See: openscopeproject/InteractiveHtmlBom#301 --- kibot/__main__.py | 5 +++++ kibot/kiplot.py | 4 +++- kibot/out_ibom.py | 10 +++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/kibot/__main__.py b/kibot/__main__.py index 98a6e2d4..66aa35b3 100644 --- a/kibot/__main__.py +++ b/kibot/__main__.py @@ -213,6 +213,7 @@ def detect_kicad(): # /usr/share/kicad/* GS.kicad_plugins_dirs.append(os.path.join(GS.kicad_share_path, 'scripting')) GS.kicad_plugins_dirs.append(os.path.join(GS.kicad_share_path, 'scripting', 'plugins')) + GS.kicad_plugins_dirs.append(os.path.join(GS.kicad_share_path, '3rdparty', 'plugins')) # KiCad 6.0 PCM # ~/.config/kicad/* GS.kicad_plugins_dirs.append(os.path.join(GS.kicad_conf_path, 'scripting')) GS.kicad_plugins_dirs.append(os.path.join(GS.kicad_conf_path, 'scripting', 'plugins')) @@ -222,6 +223,10 @@ def detect_kicad(): GS.kicad_plugins_dirs.append(os.path.join(home, '.kicad_plugins')) GS.kicad_plugins_dirs.append(os.path.join(home, '.kicad', 'scripting')) GS.kicad_plugins_dirs.append(os.path.join(home, '.kicad', 'scripting', 'plugins')) + if GS.kicad_version_major >= 6: + # KiCad 6.0 PCM + ver_dir = str(GS.kicad_version_major)+'.'+str(GS.kicad_version_minor) + GS.kicad_plugins_dirs.append(os.path.join(home, '.local', 'share', 'kicad', ver_dir, '3rdparty', 'plugins')) if GS.debug_level > 1: logger.debug('KiCad config path {}'.format(GS.kicad_conf_path)) diff --git a/kibot/kiplot.py b/kibot/kiplot.py index 6364b90e..2f211e07 100644 --- a/kibot/kiplot.py +++ b/kibot/kiplot.py @@ -102,6 +102,8 @@ def check_version(command, version): if command in script_versions: return cmd = [command, '--version'] + if not os.access(command, os.X_OK) and command.endswith('.py'): + cmd.insert(0, 'python3') logger.debug('Running: '+str(cmd)) result = run(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True) z = re.match(command + r' (\d+\.\d+\.\d+)', result.stdout, re.IGNORECASE) @@ -120,7 +122,7 @@ def check_version(command, version): def check_script(cmd, url, version=None): - if which(cmd) is None: + if which(cmd) is None and not os.path.isfile(cmd): logger.error('No `'+cmd+'` command found.\n' 'Please install it, visit: '+url) logger.error(TRY_INSTALL_CHECK) diff --git a/kibot/out_ibom.py b/kibot/out_ibom.py index 0dc29b0a..4c37be63 100644 --- a/kibot/out_ibom.py +++ b/kibot/out_ibom.py @@ -15,14 +15,15 @@ from . import log logger = log.get_logger() WARNING_MIX = "Avoid using it in conjunction with IBoM native filtering options" +PLUGIN_NAMES = ['InteractiveHtmlBom', 'InteractiveHtmlBom/InteractiveHtmlBom', + 'org_openscopeproject_InteractiveHtmlBom/InteractiveHtmlBom'] RegDependency.register(ToolDependency('ibom', 'Interactive HTML BoM', URL_IBOM, url_down=URL_IBOM+'/releases', command=CMD_IBOM, in_debian=False, no_cmd_line_version_old=True, - plugin_dirs=['InteractiveHtmlBom', 'InteractiveHtmlBom/InteractiveHtmlBom'], - roles=ToolDependencyRole(version=(2, 4, 1, 4)))) + plugin_dirs=PLUGIN_NAMES, roles=ToolDependencyRole(version=(2, 4, 1, 4)))) def check_tool(): - tool = search_as_plugin(CMD_IBOM, ['InteractiveHtmlBom', 'InteractiveHtmlBom/InteractiveHtmlBom']) + tool = search_as_plugin(CMD_IBOM, PLUGIN_NAMES) check_script(tool, URL_IBOM) return tool @@ -161,6 +162,9 @@ class IBoMOptions(VariantOptions): else: output_dir = name cmd = [tool, GS.pcb_file, '--dest-dir', output_dir, '--no-browser', ] + if not os.access(tool, os.X_OK): + # Plugin could be installed without execute flags + cmd.insert(0, 'python3') # Check if the user wants extra_fields but there is no data about them (#68) if self.need_extra_fields() and not os.path.isfile(self.extra_data_file): logger.warning(W_NONETLIST+'iBoM needs information about user defined fields and no netlist provided')