def OnOpenLogFile(self, event=None): log_select = GetFileOpenDialog(self, GT(u'Open Log'), directory=PATH_logs) if ShowDialog(log_select): logFile = log_select.GetPath() if os.path.isfile(logFile): self.SetLogFile(logFile) return ShowErrorDialog(u'{}: {}'.format(GT(u'File does not exist'), logFile), parent=self)
def OnLoadLauncher(self, event=None): dia = GetFileOpenDialog(GetMainWindow(), GT(u'Open Launcher')) if ShowDialog(dia): path = dia.GetPath() data = ReadFile(path, split=True, convert=list) # Remove unneeded lines if data[0] == u'[Desktop Entry]': data = data[1:] self.Reset() # First line needs to be changed to '1' data.insert(0, u'1') self.Set(u'\n'.join(data))
def OnBrowse(self, event=None): browse_dialog = GetFileOpenDialog(GetMainWindow(), GT(u'Open File')) if ShowDialog(browse_dialog): self.ImportFromFile(browse_dialog.GetPath())
def ProjectOpen(self, project_file=None): Logger.Debug(__name__, u'Opening project: {}'.format(project_file)) # Need to show file open dialog because no project file was specified if not project_file: wc_z = GetDialogWildcards(ID_PROJ_Z) wc_l = GetDialogWildcards(ID_PROJ_L) wc_a = GetDialogWildcards(ID_PROJ_A) wc_t = GetDialogWildcards(ID_PROJ_T) wildcards = ( wc_a[0], wc_a[1], wc_z[0], wc_z[1], wc_t[0], wc_t[1], wc_l[0], wc_l[1], ) open_dialog = GetFileOpenDialog(self, GT(u'Open Debreate Project'), wildcards) if not ShowDialog(open_dialog): return dbrerrno.ECNCLD # Get the path and set the saved project project_file = open_dialog.GetPath() # Failsafe check that file exists if not os.path.isfile(project_file): err_l1 = GT(u'Cannot open project:') err_details = GT(u'File does not exist') ShowErrorDialog(u'{} {}'.format(err_l1, project_file), err_details) return dbrerrno.ENOENT # Check for unsaved changes & reset project to defaults if not self.ProjectClose(): return dbrerrno.ECNCLD mime_type = GetFileMimeType(project_file) Logger.Debug(__name__, GT(u'Project mime type: {}').format(mime_type)) opened = None if mime_type == u'text/plain': p_text = ReadFile(project_file) filename = os.path.split(project_file)[1] # Legacy projects should return None since we can't save in that format opened = self.ProjectOpenLegacy(p_text, filename) else: opened = self.ProjectOpenArchive(project_file, mime_type) Logger.Debug( __name__, GT(u'Project loaded before OnProjectOpen: {}').format( self.ProjectIsLoaded())) if opened == dbrerrno.SUCCESS: self.LoadedProject = project_file # Set project 'unmodified' for newly opened project self.ProjectSetDirty(False) Logger.Debug( __name__, GT(u'Project loaded after OnOpenPreject: {}').format( self.ProjectIsLoaded())) if DebugEnabled() and self.ProjectIsLoaded(): Logger.Debug(__name__, GT(u'Loaded project: {}').format(self.LoadedProject)) return opened