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

View File

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