Commit 9f8c10a8 authored by eric pellegrini's avatar eric pellegrini
Browse files

Prevent the controller tab from closing

The temporary job script files are now also saved when running a job
from the GUI
parent 7cca2257
......@@ -23,7 +23,7 @@ class ControllerPanel(wx.Panel):
def build_panel(self):
self._notebook = wxaui.AuiNotebook(self)
self._notebook = wxaui.AuiNotebook(self, style=wxaui.AUI_NB_DEFAULT_STYLE & ~wxaui.AUI_NB_CLOSE_ON_ACTIVE_TAB)
self._pages = collections.OrderedDict()
self._pages["logger"] = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_BESTWRAP|wx.HSCROLL|wx.TE_AUTO_URL)
......
......@@ -103,10 +103,9 @@ class JobPlugin(ComponentPlugin):
parameters = self._parametersPanel.get_value()
t = tempfile.mkstemp(prefix = "MDANSE_%s_" % self._job.type, text = True)
os.close(t[0])
script = os.path.join(PLATFORM.jobscripts_directory(),self._job._name)+'.py'
self._job.save(t[1], parameters)
self._job.save(script, parameters)
if PLATFORM.name == "windows":
startupinfo = subprocess.STARTUPINFO()
......@@ -115,7 +114,7 @@ class JobPlugin(ComponentPlugin):
else:
startupinfo = None
subprocess.Popen([sys.executable, t[1]], startupinfo=startupinfo, stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
subprocess.Popen([sys.executable, script], startupinfo=startupinfo, stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(1)
......
......@@ -302,6 +302,20 @@ class Platform(object):
return path
def jobscripts_directory(self):
'''
Returns the path of the directory where the MDANSE job script files are stored.
:return: the path of the directory where the MDANSE job script files are stored.
:rtype: str
'''
path = os.path.join(self.application_directory(), 'jobscripts')
self.create_directory(path)
return path
def temporary_files_directory(self):
'''
Returns the path of the directory where the temporary MDANSE job status files are stored.
......
......@@ -85,12 +85,12 @@ class JobError(Error):
return self._message
def key_generator(size=4, chars=None, prefix=""):
def key_generator(keySize, chars=None, prefix=""):
if chars is None:
chars = string.ascii_lowercase + string.digits
key = ''.join(random.choice(chars) for _ in range(size))
key = ''.join(random.choice(chars) for _ in range(keySize))
if prefix:
key = "%s_%s" % (prefix,key)
......@@ -121,7 +121,7 @@ class IJob(Configurable):
while True:
# Followed by 4 random letters.
name = key_generator(4, prefix=prefix)
name = key_generator(6, prefix=prefix)
if not name in registeredJobs:
break
......
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