Minor scripting improvements and code cleaning.

* Coding policy fixes in the scripting initialization code missed in my previous commit.
* Remove redundant checks for valid Python library paths in kicadplugins.i.
This commit is contained in:
Wayne Stambaugh 2015-10-01 20:15:01 -04:00
parent 28bda90e87
commit 053458b81a
2 changed files with 11 additions and 12 deletions

View File

@ -207,7 +207,7 @@ static bool scriptingSetup()
#if defined( __MINGW32__ )
// force python environment under Windows:
const wxString python_us( "python27_us" );
const wxString python_us( wxT( "python27_us" ) );
// Build our python path inside kicad
wxString kipython = FindKicadFile( python_us + wxT( "/python.exe" ) );
@ -281,21 +281,21 @@ static bool scriptingSetup()
wxSetEnv( "PYTHONPATH", pypath );
#else
/* Linux-specific setup */
// Linux-specific setup
wxString pypath;
pypath = Pgm().GetExecutablePath() + wxT( "../lib/python2.7/dist-packages" );
if( !wxIsEmpty( wxGetenv("PYTHONPATH") ) )
pypath = wxString( wxGetenv("PYTHONPATH") ) + wxT( ":" ) + pypath;
if( !wxIsEmpty( wxGetenv( wxT( "PYTHONPATH" ) ) )
pypath = wxString( wxGetenv( wxT( "PYTHONPATH" ) ) ) + wxT( ":" ) + pypath;
wxSetEnv( "PYTHONPATH", pypath );
wxSetEnv( wxT( "PYTHONPATH" ), pypath );
// Add this default search path:
path_frag = Pgm().GetExecutablePath() + wxT( "../share/kicad/scripting/plugins" );
#endif
if( ! pcbnewInitPythonScripting( TO_UTF8( path_frag ) ) )
if( !pcbnewInitPythonScripting( TO_UTF8( path_frag ) ) )
{
wxLogError( wxT( "pcbnewInitPythonScripting() failed." ) );
return false;

View File

@ -78,17 +78,17 @@ def ReloadPlugins():
ReloadPlugin(k)
def LoadPlugins( plugpath ):
def LoadPlugins(plugpath):
import os
import sys
kicad_path = os.environ.get('KICAD_PATH')
plugin_directories=[]
if plugpath and os.path.isdir( plugpath ):
plugin_directories.append( plugpath )
if plugpath:
plugin_directories.append(plugpath)
if kicad_path and os.path.isdir(kicad_path):
if kicad_path:
plugin_directories.append(os.path.join(kicad_path, 'scripting', 'plugins'))
if sys.platform.startswith('linux'):
@ -97,8 +97,7 @@ def LoadPlugins( plugpath ):
if sys.platform.startswith('darwin'):
for singlepath in sys.path:
if os.path.isdir( os.path.join( singlepath, 'scripting', 'plugins') ):
plugin_directories.append( os.path.join( singlepath, 'scripting', 'plugins') )
plugin_directories.append(os.path.join( singlepath, 'scripting', 'plugins'))
for plugins_dir in plugin_directories:
if not os.path.isdir(plugins_dir):