def __ValidateOutDir(self, path=None): if path is None: path = self.tcFolder.GetValue().strip() if not os.path.isdir(path): dlg = wx.MessageDialog( self, _("Folder does not exists! Do you want %s to create it?") % Constants.APP_NAME, _("Question"), wx.YES_NO | wx.ICON_QUESTION) resp = dlg.ShowModal() dlg.Destroy() if resp == wx.ID_YES: try: os.makedirs(path) except Exception as err: dlg = wx.MessageDialog( self, _("Cannot create folder: %s") % str(err), _("Error"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return False else: return False else: if not IsPathWritable(path): dlg = wx.MessageDialog(self, _("Cannot write into folder!"), _("Error"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return False return True
def __init__(self): self.cp = None if IsPathWritable(Constants.APP_DIR): setPath = Constants.APP_DIR else: userpath = os.path.expanduser("~") if userpath == "~": userpath = tempfile.gettempdir() setPath = userpath self.filename = os.path.join(setPath, '.%s' % Constants.APP_NAME) logging.debug("settings file: %s", self.filename) self.Load()