def __init__(self, parent): wx.Panel.__init__(self, parent, -1, size=(640, 480)) self.sizer = wx.GridBagSizer(5, 5) conf = Configuration.getConfiguration() vtkpath = conf.getConfigItem("VTKPath", "VTK") datapath = conf.getConfigItem("DataPath", "Paths") removevtk = conf.getConfigItem("RemoveOldVTK", "VTK") remember = conf.getConfigItem("RememberPath", "Paths") self.dataBox = wx.StaticBox(self, -1, "Data Files Directory", size=(600, 150)) self.dataBoxSizer = wx.StaticBoxSizer(self.dataBox, wx.VERTICAL) self.dataBoxSizer.SetMinSize(self.dataBox.GetSize()) self.databrowse = filebrowse.DirBrowseButton( self, -1, labelText="Location of Data Files", toolTip="Set the default directory for data files", startDirectory=datapath, ) self.databrowse.SetValue(datapath) self.dataBoxSizer.Add(self.databrowse, 0, wx.EXPAND) self.useLastCheckbox = wx.CheckBox(self, -1, "Use last opened directory as default directory") if type(remember) in [types.StringType, types.UnicodeType]: remember = eval(remember) self.useLastCheckbox.SetValue(remember) self.dataBoxSizer.Add(self.useLastCheckbox) self.cacheBox = wx.StaticBox(self, -1, "Log and cache files", size=(600, 150)) self.cacheBoxSizer = wx.StaticBoxSizer(self.cacheBox, wx.VERTICAL) self.cacheBoxSizer.SetMinSize(self.cacheBox.GetSize()) logdir = scripting.get_log_dir() self.logbrowse = filebrowse.DirBrowseButton( self, -1, labelText="Select log files directory", startDirectory=logdir ) self.logbrowse.SetValue(logdir) previewdir = scripting.get_preview_dir() self.previewbrowse = filebrowse.DirBrowseButton( self, -1, labelText="Select preview files directory", startDirectory=previewdir ) self.previewbrowse.SetValue(previewdir) self.clearCacheButton = wx.Button(self, -1, "Clear logs and previews") self.clearCacheButton.Bind(wx.EVT_BUTTON, self.onClearCache) self.cacheBoxSizer.Add(self.logbrowse, 0, wx.EXPAND) self.cacheBoxSizer.Add(self.previewbrowse, 0, wx.EXPAND) self.cacheBoxSizer.Add(self.clearCacheButton) self.sizer.Add(self.dataBoxSizer, (0, 0), flag=wx.EXPAND | wx.ALL) self.sizer.Add(self.cacheBoxSizer, (1, 0), flag=wx.EXPAND | wx.ALL) self.SetAutoLayout(1) self.SetSizer(self.sizer) self.Layout() self.sizer.Fit(self)
def onClearCache(self, evt): """ Clear the logs and previews directory """ logdir = scripting.get_log_dir() logfiles = glob.glob(os.path.join(logdir, "*.log")) for file in logfiles: os.unlink(file) previewdir = scripting.get_preview_dir() previewfiles = glob.glob(os.path.join(previewdir, "*.png")) for file in previewfiles: os.unlink(file)
def writeSettings(self, conf): """ A method that writes out the settings that have been modified in this window. """ datapath = self.databrowse.GetValue() rememberlast = self.useLastCheckbox.GetValue() logpath = unicode(self.logbrowse.GetValue()) if logpath and logpath != scripting.get_log_dir(): conf.setConfigItem("LogPath", "Paths", logpath) print u"Setting logpath to", logpath previewpath = self.previewbrowse.GetValue() if previewpath and previewpath != scripting.get_preview_dir(): conf.setConfigItem("PreviewPath", "Paths", previewpath) print "Setting preview path to", previewpath conf.setConfigItem("DataPath", "Paths", datapath) conf.setConfigItem("RememberPath", "Paths", rememberlast)
import BatchApplication app = BatchApplication.BXDBatchApplication() dataFiles.extend(args) # If the main application is frozen, then we redirect logging # to a log file #TODO: Why create a new variable logFile in scripting? Shouldn't it just be logFile captureOutput = StringIO.StringIO() scripting.logFile = captureOutput if toFile or scripting.main_is_frozen(): import time if not logfile: logfile = time.strftime("bioimagexd_%d.%m.%y@%H%M.log") logdir = scripting.get_log_dir() if not os.path.exists(logdir): os.mkdir(logdir) logfile = os.path.join(logdir, logfile) timestampedLogfile = codecs.open(logfile, "w","utf-8") if logdir: logfile2 = os.path.join(logdir, "latest.log") latestLogfile = codecs.open(logfile2, "w","utf-8") logFiles = Logging.Tee(timestampedLogfile, latestLogfile, captureOutput) clean = eval(conf.getConfigItem("CleanExit", "General")) if not clean: scripting.uncleanLog = conf.getConfigItem("LastLogFile", "General") else: scripting.uncleanLog = None
def __init__(self, parent): wx.Panel.__init__(self, parent, -1, size=(640, 480)) self.sizer = wx.GridBagSizer(5, 5) conf = Configuration.getConfiguration() vtkpath = conf.getConfigItem("VTKPath", "VTK") datapath = conf.getConfigItem("DataPath", "Paths") removevtk = conf.getConfigItem("RemoveOldVTK", "VTK") remember = conf.getConfigItem("RememberPath", "Paths") self.dataBox = wx.StaticBox(self, -1, "Data Files Directory", size=(600, 150)) self.dataBoxSizer = wx.StaticBoxSizer(self.dataBox, wx.VERTICAL) self.dataBoxSizer.SetMinSize(self.dataBox.GetSize()) self.databrowse = filebrowse.DirBrowseButton( self, -1, labelText="Location of Data Files", toolTip="Set the default directory for data files", startDirectory=datapath) self.databrowse.SetValue(datapath) self.dataBoxSizer.Add(self.databrowse, 0, wx.EXPAND) self.useLastCheckbox = wx.CheckBox( self, -1, "Use last opened directory as default directory") if type(remember) in [types.StringType, types.UnicodeType]: remember = eval(remember) self.useLastCheckbox.SetValue(remember) self.dataBoxSizer.Add(self.useLastCheckbox) self.cacheBox = wx.StaticBox(self, -1, "Log and cache files", size=(600, 150)) self.cacheBoxSizer = wx.StaticBoxSizer(self.cacheBox, wx.VERTICAL) self.cacheBoxSizer.SetMinSize(self.cacheBox.GetSize()) logdir = scripting.get_log_dir() self.logbrowse = filebrowse.DirBrowseButton( self, -1, labelText="Select log files directory", startDirectory=logdir) self.logbrowse.SetValue(logdir) previewdir = scripting.get_preview_dir() self.previewbrowse = filebrowse.DirBrowseButton( self, -1, labelText="Select preview files directory", startDirectory=previewdir) self.previewbrowse.SetValue(previewdir) self.clearCacheButton = wx.Button(self, -1, "Clear logs and previews") self.clearCacheButton.Bind(wx.EVT_BUTTON, self.onClearCache) self.cacheBoxSizer.Add(self.logbrowse, 0, wx.EXPAND) self.cacheBoxSizer.Add(self.previewbrowse, 0, wx.EXPAND) self.cacheBoxSizer.Add(self.clearCacheButton) self.sizer.Add(self.dataBoxSizer, (0, 0), flag=wx.EXPAND | wx.ALL) self.sizer.Add(self.cacheBoxSizer, (1, 0), flag=wx.EXPAND | wx.ALL) self.SetAutoLayout(1) self.SetSizer(self.sizer) self.Layout() self.sizer.Fit(self)