ReloadPlugins() python function, and mtime stored in the KICAD_PLUGINS dictionary

This commit is contained in:
Miguel Angel Ajo 2013-03-17 03:03:18 +01:00
parent 1cf52baaa0
commit f227383341
2 changed files with 24 additions and 9 deletions

View File

@ -47,11 +47,25 @@ def ReloadPlugin(name):
if not KICAD_PLUGINS.has_key(name): if not KICAD_PLUGINS.has_key(name):
return False return False
KICAD_PLUGINS[name]["wizard"].deregister() KICAD_PLUGINS[name]["object"].deregister()
mod = reload(KICAD_PLUGINS[name]["module"]) mod = reload(KICAD_PLUGINS[name]["module"])
KICAD_PLUGINS[name]["object"]= mod.register()
def ReloadPlugins():
import os.path
for k in KICAD_PLUGINS.keys():
plugin = KICAD_PLUGINS[k]
filename = plugin["filename"]
mtime = plugin["modification_time"]
now_mtime = os.path.getmtime(filename)
if mtime!=now_mtime:
print filename, " is modified, reloading"
KICAD_PLUGINS[k]["modification_time"]=now_mtime
ReloadPlugin(k)
KICAD_PLUGINS[name]["wizard"]= mod.register()
def LoadPlugins(): def LoadPlugins():
import os import os
@ -85,11 +99,12 @@ def LoadPlugins():
mod = __import__(module[:-3], locals(), globals()) mod = __import__(module[:-3], locals(), globals())
module_filename = plugins_dir+"/"+module
mtime = os.path.getmtime(module_filename)
if hasattr(mod,'register'): if hasattr(mod,'register'):
KICAD_PLUGINS[module]={"filename":plugins_dir+"/"+module, KICAD_PLUGINS[module]={"filename":module_filename,
"wizard":mod.register(), "modification_time":mtime,
"object":mod.register(),
"module":mod} "module":mod}

View File

@ -224,8 +224,8 @@ wxWindow* CreatePythonShellWindow( wxWindow* parent )
"\t\tself.SetSizer(sizer)\n\n" "\t\tself.SetSizer(sizer)\n\n"
"\n" "\n"
"def makeWindow(parent):\n" "def makeWindow(parent):\n"
" win = PyCrustPanel(parent)\n" " shell_window = PyCrustPanel(parent)\n"
" return win\n" " return shell_window\n"
"\n"; "\n";