kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #29762
[PATCH] Fix wrong directory building for python plugins
Hi all,
See attached patch to use os.path.join instead of manual building of
path.
The previous "plugins_dir+module" was not working in most case (when
plugins_dir don't have a tailing "/")
It will allow Python plugin inside directory to be correctly loaded
when those plugins are installed inside KiCad's system plugin directory
(/usr/share/kicad/scripting/plugins for example in Linux)
Regards,
From 73caa4f1c2782076c91467835eaa86c5cd032022 Mon Sep 17 00:00:00 2001
From: Jean-Samuel Reynaud <js.reynaud@xxxxxxxxx>
Date: Thu, 22 Jun 2017 19:27:09 +0200
Subject: [PATCH] Fix wrong directory building for python plugins
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.7.4"
This is a multi-part message in MIME format.
--------------2.7.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit
---
scripting/kicadplugins.i | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
--------------2.7.4
Content-Type: text/x-patch; name="0001-Fix-wrong-directory-building-for-python-plugins.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Fix-wrong-directory-building-for-python-plugins.patch"
diff --git a/scripting/kicadplugins.i b/scripting/kicadplugins.i
index a008d04..794009c 100644
--- a/scripting/kicadplugins.i
+++ b/scripting/kicadplugins.i
@@ -136,9 +136,9 @@ def LoadPlugins(bundlepath=None):
plugin_directories.append(os.path.join(config_path, 'scripting', 'plugins'))
if sys.platform.startswith('linux'):
- plugin_directories.append(os.environ['HOME']+'/.kicad_plugins/')
- plugin_directories.append(os.environ['HOME']+'/.kicad/scripting/')
- plugin_directories.append(os.environ['HOME']+'/.kicad/scripting/plugins/')
+ plugin_directories.append(os.path.join(os.environ['HOME'],'.kicad_plugins'))
+ plugin_directories.append(os.path.join(os.environ['HOME'],'.kicad','scripting'))
+ plugin_directories.append(os.path.join(os.environ['HOME'],'.kicad','scripting','plugins'))
global PLUGIN_DIRECTORIES_SEARCH
PLUGIN_DIRECTORIES_SEARCH=""
@@ -160,14 +160,14 @@ def LoadPlugins(bundlepath=None):
sys.path.append(plugins_dir)
for module in os.listdir(plugins_dir):
- if os.path.isdir(plugins_dir+module):
+ if os.path.isdir(os.path.join(plugins_dir,module)):
__import__(module, locals(), globals())
if module == '__init__.py' or module[-3:] != '.py':
continue
try: # If there is an error loading the script, skip it
- module_filename = plugins_dir + "/" + module
+ module_filename = os.path.join(plugins_dir,module)
mtime = os.path.getmtime(module_filename)
if KICAD_PLUGINS.has_key(module):
--------------2.7.4--
Follow ups