Commit d4831f2b authored by eric pellegrini's avatar eric pellegrini

Several small fixes

parent 76fc5e46
......@@ -150,7 +150,12 @@ class Platform(object):
raise PlatformError('Invalid query object type.')
basepath = os.path.join(os.path.dirname(self.package_directory()),'')
print basepath, len(basepath), path.split(basepath), path
s = path.split(basepath)
if len(s) != 2:
return None
_,relativePath = path.split(basepath)
relativePath = os.path.splitext(relativePath)[0]
......
......@@ -228,7 +228,7 @@ class InputDirectory(PreferencesItem):
'''
value = PLATFORM.get_path(value)
try:
PLATFORM.create_directory(value)
except PlatformError:
......@@ -238,7 +238,7 @@ class InputDirectory(PreferencesItem):
self._value = value
def get_value(self):
return self._value
class Preferences(collections.OrderedDict):
......
......@@ -40,7 +40,7 @@ import subprocess
import sys
import traceback
from MDANSE import PLATFORM, REGISTRY
from MDANSE import LOGGER, PLATFORM, REGISTRY
from MDANSE.Core.Error import Error
from MDANSE.Framework.Configurable import Configurable
from MDANSE.Framework.Jobs.JobStatus import JobStatus
......@@ -471,16 +471,18 @@ class IJob(Configurable):
longname = shortname
if REGISTRY['job'].has_key(shortname):
raise IOError("A job with %r name is already stored in the registry" % shortname)
LOGGER('A job with %r name is already stored in the registry' % shortname,'error')
return
from MDANSE import PREFERENCES
macrosDir = PREFERENCES["macros_directory"].get_value()
templateFile = os.path.join(macrosDir,"%s.py" % longname)
f = open(templateFile,'w')
try:
f = open(templateFile,'w')
f.write(
f.write(
'''import collections
from MDANSE.Framework.Jobs.IJob import IJob
......@@ -545,7 +547,9 @@ class %s(IJob):
self.configuration['trajectory']['instance'].close()
''' % (longname,shortname,longname))
f.close()
except IOError:
LOGGER('The job template could not be save to %r. Maybe a permission problem.' % templateFile,'error')
else:
f.close()
return templateFile
\ No newline at end of file
......@@ -14,9 +14,12 @@ class JobHelpFrame(wx.Frame):
self.nolog = wx.LogNull()
moduleFullName = PLATFORM.full_dotted_module(job.__class__)
self._doc = os.path.join(PLATFORM.help_path(), moduleFullName+'.html')
if moduleFullName is None:
self._doc = ""
else:
self._doc = os.path.join(PLATFORM.help_path(), moduleFullName+'.html')
self.build()
def build(self):
......
......@@ -92,7 +92,10 @@ class RegistryViewer(wx.Dialog):
moduleFullName = PLATFORM.full_dotted_module(ItemData.GetData())
moduleDocPath = os.path.join(PLATFORM.help_path(), moduleFullName+'.html')
if moduleFullName is None:
moduleDocPath = ''
else:
moduleDocPath = os.path.join(PLATFORM.help_path(), moduleFullName+'.html')
self._info.LoadPage(moduleDocPath)
......
......@@ -67,6 +67,15 @@ class CommandLineParser(optparse.OptionParser):
Creates the MDANSE commad line parser.
'''
def __init__(self,*args,**kwargs):
optparse.OptionParser.__init__(self,*args,**kwargs)
from MDANSE import LOGGER
LOGGER.add_handler("terminal", REGISTRY['handler']['terminal'](), level="info", start=True)
LOGGER.start()
def add_mmtk_definition(self, option, opt_str, value, parser):
if len(parser.rargs) != 3:
......@@ -331,9 +340,7 @@ class CommandLineParser(optparse.OptionParser):
else:
raise CommandLineParserError("Invalid number of arguments for %r option" % opt_str)
filename = IJob.save_template(shortname,longname)
print "Template for job %r saved in %r" % (shortname, filename)
IJob.save_template(shortname,longname)
if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment