This program is released under the GNU General Public License version 2.\r
'''\r
\r
-from libhooke import HOOKE_VERSION\r
-from libhooke import WX_GOOD\r
+from .libhooke import HOOKE_VERSION, WX_GOOD\r
\r
import os\r
\r
import matplotlib.numerix as nx\r
import scipy as sp\r
\r
-from threading import *\r
+from threading import Thread\r
import Queue\r
\r
-from hooke_cli import HookeCli\r
-from libhooke import *\r
-import libhookecurve as lhc\r
+from .hooke_cli import HookeCli\r
+from .libhooke import HookeConfig, ClickedPoint\r
+from . import libhookecurve as lhc\r
\r
#import file versions, just to know with what we're working...\r
from hooke_cli import __version__ as hookecli_version\r
plugin_gui_namespaces=[]\r
for plugin_name in config['plugins']:\r
try:\r
- plugin=__import__(plugin_name)\r
+ hooke_module=__import__('hooke.plugin.'+plugin_name)\r
+ plugin = getattr(hooke_module.plugin, plugin_name)\r
try:\r
- eval('CLI_PLUGINS.append(plugin.'+plugin_name+'Commands)') #take Command plugin classes\r
- plugin_commands_namespaces.append(dir(eval('plugin.'+plugin_name+'Commands')))\r
+ #take Command plugin classes\r
+ commands = getattr(plugin, plugin_name+'Commands')\r
+ CLI_PLUGINS.append(commands)\r
+ plugin_commands_namespaces.append(dir(commands))\r
except:\r
pass\r
try:\r
- eval('GUI_PLUGINS.append(plugin.'+plugin_name+'Gui)') #take Gui plugin classes\r
- plugin_gui_namespaces.append(dir(eval('plugin.'+plugin_name+'Gui')))\r
+ #take Gui plugin classes\r
+ gui = getattr(plugin, plugin_name+'Gui')\r
+ GUI_PLUGINS.append(gui)\r
+ plugin_gui_namespaces.append(dir(gui))\r
except:\r
pass\r
except ImportError:\r
print 'Imported plugin ',plugin_name\r
\r
#eliminate names common to all namespaces\r
-for i in range(len(plugin_commands_namespaces)):\r
- plugin_commands_namespaces[i]=[item for item in plugin_commands_namespaces[i] if (item != '__doc__' and item != '__module__' and item != '_plug_init')]\r
+for i,namespace in enumerate(plugin_commands_namespaces):\r
+ plugin_commands_namespaces[i] = \\r
+ filter(lambda item : not (item.startswith('__')\r
+ or item == '_plug_init'),\r
+ namespace)\r
#check for conflicts in namespaces between plugins\r
#FIXME: only in commands now, because I don't have Gui plugins to check\r
#FIXME: how to check for plugin-defined variables (self.stuff) ??\r
for item in namespace:\r
if item in plugin_commands_names:\r
i=plugin_commands_names.index(item) #we exploit the fact index gives the *first* occurrence of a name...\r
- print 'Error. Plugin ',plugin_name,' defines a function already defined by ',whatplugin_defines[i],'!'\r
+ print 'Error. Plugin %s defines a function %s already defined by %s!' \\r
+ % (plugin_name, item, whatplugin_defines[i])\r
print 'This should not happen. Please disable one or both plugins and contact the plugin authors to solve the conflict.'\r
print 'Hooke cannot continue.'\r
exit()\r
LOADED_DRIVERS=[]\r
for driver_name in config['drivers']:\r
try:\r
- driver=__import__(driver_name)\r
+ hooke_module=__import__('hooke.driver.'+driver_name)\r
+ driver = getattr(hooke_module.driver, driver_name)\r
try:\r
- eval('FILE_DRIVERS.append(driver.'+driver_name+'Driver)')\r
+ FILE_DRIVERS.append(getattr(driver, driver_name+'Driver'))\r
except:\r
pass\r
except ImportError:\r
#make sure we execute _plug_init() for every command line plugin we import\r
for plugin_name in config['plugins']:\r
try:\r
- plugin=__import__(plugin_name)\r
+ hooke_module=__import__('hooke.plugin.'+plugin_name)\r
+ plugin = getattr(hooke_module.plugin, plugin_name)\r
try:\r
eval('plugin.'+plugin_name+'Gui._plug_init(self)')\r
pass\r
# This is a recipe to a the screen.\r
# Modify the following variables as necessary.\r
#aBitmap = wx.Image(name = "wxPyWiki.jpg").ConvertToBitmap()\r
- aBitmap=wx.Image(name='hooke.jpg').ConvertToBitmap()\r
+ aBitmap=wx.Image(name=os.path.join(\r
+ config['install']['docpath'],\r
+ 'hooke.jpg')).ConvertToBitmap()\r
splashStyle = wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT\r
splashDuration = 2000 # milliseconds\r
splashCallback = None\r
#------------------------------------------------------------------------------\r
\r
def main():\r
-\r
- #save the directory where Hooke is located\r
- config['hookedir']=os.getcwd()\r
-\r
- #now change to the working directory.\r
- try:\r
- os.chdir(config['workdir'])\r
- except OSError:\r
- print "Warning: Invalid work directory."\r
-\r
app=wx.PySimpleApp()\r
\r
def make_gui_class(*bases):\r
my_cmdline=CliThread(main_frame, list_of_events)\r
my_cmdline.start()\r
\r
-\r
app.MainLoop()\r
\r
-main()\r
+if __name__ == '__main__':\r
+ main()\r