1 from __future__
import absolute_import
8 import logging.handlers
14 from PyQt4.QtCore import SIGNAL,qVersion,QString,QVariant, Qt
15 from PyQt4.QtGui import QApplication,QMenu,QPixmap,QAction,QFileDialog,QIcon,QMessageBox
17 from Vispa.Main.Directories import logDirectory,pluginDirectory,baseDirectory,homeDirectory,iniFileName,applicationName,docDirectory,websiteUrl
27 from .
import Resources
32 MAX_VISIBLE_RECENT_FILES = 10
33 MAX_VISIBLE_UNDO_EVENTS = 10
34 FAILED_LOADING_PLUGINS_ERROR =
"Errors while loading plugins. For details see error output or log file.\n\nThe following plugins won't work correctly:\n\n"
35 TAB_PREMATURELY_CLOSED_WARNING =
"Tab was closed before user request could be handled."
36 NO_PROCESS_EVENTS =
False
39 QApplication.__init__(self, argv)
58 logging.debug(
'Running with Qt-Version ' + str(qVersion()))
89 return self._commandLineOptions
95 """ Returns version string.
100 """ Returns True if given versionString is newer than current used version of Qt.
102 [majorV, minorV, revisionV] = versionString.split(
".")
103 [majorQ, minorQ, revisionQ] = str(qVersion()).
split(
".")
106 elif majorV < majorQ:
108 elif majorV == majorQ:
111 elif minorV < minorQ:
113 elif minorV == minorQ:
114 if revisionV > revisionQ:
116 elif revisionV < revisionQ:
118 elif revisionV == revisionQ:
123 """ Set the available command line options.
125 self._commandLineParser.add_option(
"-f",
"--file", dest=
"filename", help=
"open a FILE", metavar=
"FILE")
126 self._commandLineParser.add_option(
"-l",
"--loglevel", dest=
"loglevel", help=
"set LOGLEVEL to 10=DEBUG, 20=INFO, 30=WARNING, 40=ERROR, 50=CRITICAL", metavar=
"LOGLEVEL", type=
"int")
129 """ Initialize command line parser.
131 After calling this function, plugins may add options.
133 class QuiteOptionParser(optparse.OptionParser):
135 optparse.OptionParser.__init__(self,add_help_option=
False)
136 def error(self,message=""):
138 self._commandLineParser = QuiteOptionParser()
139 self._setCommandLineOptions()
140 (self._commandLineOptions, self._args) = self._commandLineParser.parse_args()
141 if self._commandLineOptions.loglevel:
142 logging.root.setLevel(self._commandLineOptions.loglevel)
143 self._commandLineParser = optparse.OptionParser()
144 self._setCommandLineOptions()
147 """ Analyzes the command line attributes and print usage summary if required.
149 (self._commandLineOptions, self._args) = self._commandLineParser.parse_args()
150 if self._commandLineOptions.filename:
151 self.
mainWindow().setStartupScreenVisible(
False)
152 self.
openFile(self._commandLineOptions.filename)
153 if len(self._args) > 0:
154 self.
mainWindow().setStartupScreenVisible(
False)
158 """ Check if logfile is closed correctly
161 file = open(filename,
"r")
162 for line
in file.readlines():
163 if "INFO Start logging" in line:
165 if "INFO Stop logging" in line:
170 """ Add logging handlers for a log file as well as stderr.
177 logfile = os.path.join(logDirectory,
"log" + str(instance) +
".txt")
181 logfile = os.path.join(logDirectory,
"log" + str(instance) +
".txt")
184 if not os.path.exists(logfile):
190 nextlogfile = os.path.join(logDirectory,
"log" + str(instance + 1) +
".txt")
191 if os.path.exists(nextlogfile):
193 file = open(nextlogfile,
"a")
194 file.write(
"Cleaning up logfile after abnormal termination: INFO Stop logging\n")
196 if os.path.exists(logDirectory):
197 handler1 = logging.handlers.RotatingFileHandler(logfile, maxBytes=100000, backupCount=1)
198 formatter1 = logging.Formatter(
'%(asctime)s %(levelname)s %(message)s')
199 handler1.setFormatter(formatter1)
202 handler2 = logging.StreamHandler(sys.stderr)
203 formatter2 = logging.Formatter(
'%(asctime)s %(levelname)s %(message)s')
204 handler2.setFormatter(formatter2)
206 logging.root.handlers = []
207 if os.path.exists(logDirectory):
208 logging.root.addHandler(handler1)
209 logging.root.addHandler(handler2)
213 self._infologger.setLevel(logging.INFO)
214 self._infologger.handlers = []
216 self._infologger.info(
"Start logging to " + self.
_logFile)
219 """ Show the MainWindow and run the application.
225 self._infologger.info(
"Stop logging to " + self.
_logFile)
228 """ Connect signal to observe the TabWidget in the MainWindow.
230 logging.debug(
'Application: _connectSignals()')
231 self.connect(self._window.tabWidget(), SIGNAL(
"currentChanged(int)"), self.
tabChanged)
233 self.connect(self._window.tabWidget(), SIGNAL(
"tabCloseRequested(int)"), self.
tabCloseRequest)
236 """ Search all subfolders of the plugin directory for vispa plugins and registers them.
238 logging.debug(
'Application: _loadPlugins()')
239 dirs = [
"Vispa.Plugins." + str(f)
for f
in os.listdir(pluginDirectory)
240 if os.path.isdir(os.path.join(pluginDirectory, f))
and not f.startswith(
".")
and not f.startswith(
"CVS")]
244 module = __import__(di, globals(), locals(),
"Vispa.Plugins")
248 failedToLoad.append(di)
249 except PluginIgnoredException
as e:
250 logging.info(
'Application: plugin ' + di +
' cannot be loaded and is ignored: ' + str(e))
251 except AttributeError
as e:
252 logging.info(
'Application: plugin ' + di +
' is deactivated (define plugin in __init__.py to activate): ' + str(e))
254 for pluginName
in self._loadablePlugins.keys():
258 failedToLoad.append(pluginName)
260 if len(failedToLoad) > 0:
266 if name
in [plugin.__class__.__name__
for plugin
in self.
_plugins]:
267 logging.info(
"%s: initalizePlugin(): Plugin '%s' already loaded. Aborting..." % (self.__class__.__name__, name))
269 if not name
in self._loadablePlugins.keys():
270 logging.error(
"%s: initalizePlugin(): Unknown plugin '%s'. Aborting..." % (self.__class__.__name__, name))
275 self._plugins.append(pluginObject)
276 logging.debug(
'Application: added plugin ' + name)
287 """ Returns plugin with given name or None if there is no such one.
289 if not name.endswith(
"Plugin"):
293 if name == plugin.__class__.__name__:
298 controllers=[self._window.tabWidget().widget(i).controller()
for i
in range(0, self._window.tabWidget().
count())]
299 controllers+=[tab.controller()
for tab
in self.
mainWindow().tabWidgets()]
303 if controller.tab().tabWidget():
304 self._window.activateWindow()
307 controller.tab().activateWindow()
310 """ Return the TabController that belongs to the tab selected in the MainWindow.
313 if isinstance(self.activeWindow(),AbstractTab):
314 return self.activeWindow().controller()
316 currentWidget = self._window.tabWidget().currentWidget()
317 if isinstance(currentWidget, AbstractTab):
318 return currentWidget.controller()
319 raise NoCurrentTabControllerException
328 def createAction(self, name, slot=None, shortcut=None, image=None, enabled=True):
329 """ create an action with name and icon and connect it to a slot.
334 image0.load(
":/resources/" + image +
".svg")
335 action = QAction(QIcon(image0), name, self.
_window)
337 action = QAction(name, self.
_window)
338 action.setEnabled(enabled)
340 self.connect(action, SIGNAL(
"triggered()"), slot)
342 if isinstance(shortcut, list):
343 action.setShortcuts(shortcut)
345 action.setShortcut(shortcut)
349 """Called for the first time this function creates the file menu and fill it.
351 The function is written in a way that it recreates the whole menu, if it
352 is called again later during execution. So it is possible to aad new
353 plugins and use them (which means they appear in the menus) without
354 restarting the program.
356 logging.debug(
'Application: _fillFileMenu()')
358 if not self._window.fileMenu().isEmpty():
359 self._window.fileMenu().
clear()
364 newFileActions += plugin.getNewFileActions()
366 if len(newFileActions) == 1:
367 newFileActions[0].setShortcut(
'Ctrl+N')
369 self._window.fileMenu().addActions(newFileActions)
373 self._window.fileMenu().addAction(openFileAction)
374 self._window.fileToolBar().addAction(openFileAction)
378 self._window.fileMenu().addAction(self.
_fileMenuItems[
'reloadFileAction'])
382 if not hasattr(self,
'recentFilesMenu'):
387 action.setVisible(
False)
388 self._recentFilesMenu.addAction(action)
389 self._recentFilesMenuActions.append(action)
390 self._recentFilesMenu.addSeparator()
392 self._recentFilesMenu.addAction(self.
_fileMenuItems[
'clearMissingRecentFilesAction'])
394 self._recentFilesMenu.addAction(self.
_fileMenuItems[
'clearRecentFilesAction'])
398 self._window.fileMenu().addSeparator()
402 self._window.fileMenu().addAction(self.
_fileMenuItems[
'closeFileAction'])
406 self._window.fileMenu().addAction(self.
_fileMenuItems[
'closeAllAction'])
408 self._window.fileMenu().addSeparator()
412 self._window.fileMenu().addAction(self.
_fileMenuItems[
'saveFileAction'])
413 self._window.fileToolBar().addAction(self.
_fileMenuItems[
'saveFileAction'])
417 self._window.fileMenu().addAction(self.
_fileMenuItems[
'saveFileAsAction'])
421 self._window.fileMenu().addAction(self.
_fileMenuItems[
'saveAllFilesAction'])
423 self._window.fileMenu().addSeparator()
429 self._window.fileMenu().addAction(exit)
432 """Called for the first time this function creates the edit menu and fills it.
434 The function is written in a way that it recreates the whole menu, if it
435 is called again later during execution. So it is possible to aad new
436 plugins and use them (which means they appear in the menus) without
437 restarting the program.
439 logging.debug(
'Application: _fillEditMenu()')
441 if not self._window.editMenu().isEmpty():
442 self._window.editMenu().
clear()
451 self._window.editMenu().addAction(self.
_editMenuItems[
"undoAction"])
452 self._window.editMenu().addAction(self.
_editMenuItems[
"redoAction"])
461 action.setVisible(
False)
462 self._undoActionsMenu.addAction(action)
463 self._undoMenuActions.append(action)
469 action.setVisible(
False)
470 self._redoActionsMenu.addAction(action)
471 self._redoMenuActions.append(action)
475 self._window.editMenu().addAction(self.
_editMenuItems[
'cutAction'])
480 self._window.editMenu().addAction(self.
_editMenuItems[
'copyAction'])
485 self._window.editMenu().addAction(self.
_editMenuItems[
'pasteAction'])
490 self._window.editMenu().addAction(self.
_editMenuItems[
'selectAllAction'])
493 self._window.editMenu().addSeparator()
497 self._window.editMenu().addAction(self.
_editMenuItems[
'findAction'])
501 logging.debug(
'Application: _fillHelpMenu()')
506 self._window.helpMenu().addAction(self.
_helpMenuItems[
'aboutAction'])
511 self._window.helpMenu().addAction(self.
_helpMenuItems[
'openLogFile'])
514 if os.path.exists(os.path.join(docDirectory,
"index.html")):
521 """ Update recent files and enable disable menu entries in file and edit menu.
528 for i
in range(0, num_recent_files):
539 if num_recent_files == 0:
541 self.
_fileMenuItems[
'clearMissingRecentFilesAction'].setEnabled(
False)
544 self.
_fileMenuItems[
'clearMissingRecentFilesAction'].setEnabled(
True)
547 at_least_one_flag =
False
548 at_least_two_flag =
False
550 at_least_one_flag =
True
551 at_least_two_flag =
True
553 at_least_one_flag =
True
555 self.
_fileMenuItems[
'saveFileAction'].setEnabled(at_least_one_flag)
556 self.
_fileMenuItems[
'saveFileAsAction'].setEnabled(at_least_one_flag)
557 self.
_fileMenuItems[
'reloadFileAction'].setEnabled(at_least_one_flag)
558 self.
_fileMenuItems[
'closeFileAction'].setEnabled(at_least_one_flag)
560 self.
_fileMenuItems[
'saveAllFilesAction'].setEnabled(at_least_two_flag)
561 self.
_fileMenuItems[
'closeAllAction'].setEnabled(at_least_two_flag)
564 if at_least_one_flag:
572 copy_paste_enabled_flag = at_least_one_flag
and self.
currentTabController().isCopyPasteEnabled()
573 self.
_editMenuItems[
'cutAction'].setEnabled(copy_paste_enabled_flag)
574 self.
_editMenuItems[
'copyAction'].setEnabled(copy_paste_enabled_flag)
575 self.
_editMenuItems[
'pasteAction'].setEnabled(copy_paste_enabled_flag)
589 if undo_supported_flag:
593 if num_undo_events > 1:
597 for i
in range(0, num_undo_events):
598 undo_event = undo_events[num_undo_events - i - 1]
610 if num_redo_events > 1:
614 for i
in range(0, num_redo_events):
615 redo_event = redo_events[num_redo_events - i - 1]
624 except NoCurrentTabControllerException:
628 """ Opens Vispa Offline Documentation
630 webbrowser.open(os.path.join(docDirectory,
"index.html"), 2,
True)
633 """ Open new browser tab and opens Vispa Project Website.
635 webbrowser.open(websiteUrl, 2,
True)
638 """ Creates menu in main window's menu bar before help menu and adds it to _pluginMenus list.
641 self._window.menuBar().insertMenu(self._window.helpMenu().menuAction(), menu)
642 self._pluginMenus.append(menu)
646 """ Shows given menu if it is in _pluginMenus list.
652 for action
in menuObject.actions():
653 if hasattr(action,
"_wasVisible")
and action._wasVisible!=
None:
654 action.setVisible(action._wasVisible)
655 action._wasVisible=
None
657 action.setVisible(
True)
658 menuObject.menuAction().setVisible(show)
661 """ Hides given menu object if it it in _pluginMenus list.
666 """ Hides all menus in _pluginMenus list.
670 menuObject.menuAction().setVisible(
False)
671 for action
in menuObject.actions():
672 if not hasattr(action,
"_wasVisible")
or action._wasVisible==
None:
673 action._wasVisible=action.isVisible()
674 action.setVisible(
False)
677 """ Creates tool bar in main window and adds it to _pluginToolBars list.
679 toolBar = self._window.addToolBar(name)
680 self._pluginToolBars.append(toolBar)
684 """ Shows given toolbar if it is in _pluginToolBars list.
687 toolBarObject.setVisible(show)
690 """ Hides given toolbar object if it it in _pluginToolBars list.
697 """ Hides all toolbars in _toolBarMenus list.
703 """ Creates tool bar with three buttons "user", "100 %" and "all".
705 See TabController's documentation of zoomUser(), zoomHundred() and zoomAll() to find out more on the different zoom levels.
713 """ Makes zoom tool bar visible.
715 Should be called from TabController's selected() function, if the controller wants to use the tool bar.
720 """ Makes zoom tool bar invisible.
722 self._zoomToolBar.hide()
725 """ Creates tool bar with buttons to invoke undo and redo events.
727 Needs to be called after _fillEditMenu() as actions are defined there.
734 """ Makes undo tool bar visible.
739 """ Hides undo tool bar.
741 self._undoToolBar.hide()
744 """ Empties list of recent files and updates main menu.
751 """ Removes entries from recent files menu if file does no longer exist.
755 if os.path.exists(file):
762 """ Adds given filename to list of recent files.
764 logging.debug(
'Application: addRecentFile() - ' + filename)
765 if isinstance(filename, QString):
766 filename = str(filename)
769 del self.
_recentFiles[self._recentFiles.index(filename)]
774 """ Returns list of recently opened files.
779 """ Returns directory name of first entry of recent files list.
782 if os.path.abspath(os.getcwd())
in [os.path.abspath(baseDirectory),os.path.abspath(os.path.join(baseDirectory,
"bin"))]
or platform.system() ==
"Darwin":
785 elif platform.system() ==
"Darwin":
787 return homeDirectory +
"/Documents"
796 filetypes = plugin.filetypes()
798 if len(filetypes) > 0:
799 extension=filetypes[0].extension().lower()
801 if os.path.splitext(os.path.basename(file))[1][1:].lower()==extension:
807 screen.analysisDesignerRecentFilesList().
clear()
808 screen.analysisDesignerRecentFilesList().addItem(
"...")
809 screen.analysisDesignerRecentFilesList().setCurrentRow(0)
810 plugin=self.
plugin(
"AnalysisDesignerPlugin")
814 screen.analysisDesignerRecentFilesList().addItem(os.path.basename(file))
816 screen.pxlEditorRecentFilesList().
clear()
817 screen.pxlEditorRecentFilesList().addItem(
"...")
818 screen.pxlEditorRecentFilesList().setCurrentRow(0)
819 plugin=self.
plugin(
"PxlPlugin")
823 screen.pxlEditorRecentFilesList().addItem(os.path.basename(file))
829 logging.debug(
'Application: shutting down plugins' )
835 """ Loop over all plugins and remember their file extensions.
839 self._knownFiltersList.append(
'All files (*.*)')
841 for ft
in plugin.filetypes():
843 self._knownFiltersList.append(ft.fileDialogFilter())
845 allKnownFilter =
'All known files (*.' +
" *.".
join(self._knownExtensionsDictionary.keys()) +
')'
846 self._knownFiltersList.insert(1, allKnownFilter)
847 logging.debug(
'Application: _collectFileExtensions() - ' + allKnownFilter)
849 logging.debug(
'Application: _collectFileExtensions()')
853 """Displays a common open dialog for all known file types.
855 logging.debug(
'Application: openFileDialog()')
857 if not defaultFileFilter:
866 filename = QFileDialog.getOpenFileName(
872 if not filename.isEmpty():
876 """ Decides which plugin should handle opening of the given file name.
878 logging.debug(
'Application: openFile()')
879 statusMessage = self.
startWorking(
"Opening file " + filename)
880 if isinstance(filename, QString):
881 filename = str(filename)
885 if filename == controller.filename():
890 baseName = os.path.basename(filename)
891 ext = os.path.splitext(baseName)[1].lower().strip(
".")
897 foundCorrectPlugin =
False
898 if os.path.exists(filename):
900 foundCorrectPlugin =
True
905 logging.error(self.__class__.__name__ +
": openFile() - Error while opening '" + str(filename) +
"'.")
908 logging.error(self.__class__.__name__ +
": openFile() - Error while opening '" + str(filename) +
"' : " +
exception_traceback())
909 self.
errorMessage(
"Exception while opening file. See log for details.")
911 if not foundCorrectPlugin:
912 errormsg =
'Unknown file type (.' + ext +
'). Aborting.'
914 errormsg =
'File does not exist: ' + filename
922 logging.error(errormsg)
927 """ Tells current tab controller to refresh.
929 logging.debug(
'Application: reloadFile()')
934 except NoCurrentTabControllerException:
940 """ Tells current tab controller to close.
942 logging.debug(
'Application: closeCurrentFile()')
945 except NoCurrentTabControllerException:
951 """ Closes all open tabs unless user aborts closing.
953 logging.debug(
'Application: closeAllFiles()')
958 if controller.close() ==
False:
966 """ Tells current tab controller to save its file.
968 logging.debug(
'Application: saveFile()')
971 except NoCurrentTabControllerException:
975 """This functions asks the user for a file name.
977 logging.debug(
'Application: saveFileAsDialog()')
980 except NoCurrentTabControllerException:
984 if currentTabController.filename():
985 startDirectory = currentTabController.filename()
990 for filetype
in currentTabController.supportedFileTypes():
991 filetypesList.append(
Filetype(filetype[0], filetype[1]).fileDialogFilter())
992 filetypesList.append(
'Any (*.*)')
994 selectedFilter = QString(
"")
995 filename = str(QFileDialog.getSaveFileName(
999 ";;".
join(filetypesList), selectedFilter))
1002 if os.path.splitext(filename)[1].strip(
".") ==
"" and str(selectedFilter) !=
'Any (*.*)':
1003 ext = currentTabController.supportedFileTypes()[filetypesList.index(str(selectedFilter))][0]
1004 filename = os.path.splitext(filename)[0] +
"." + ext
1005 return currentTabController.save(filename)
1009 """ Tells tab controllers of all tabs to save.
1011 logging.debug(
'Application: saveAllFiles()')
1018 """ Called when cut action is triggered (e.g. from menu entry) and forwards it to current tab controller.
1022 except NoCurrentTabControllerException:
1026 """ Called when copy action is triggered (e.g. from menu entry) and forwards it to current tab controller.
1030 except NoCurrentTabControllerException:
1034 """ Called when paste action is triggered (e.g. from menu entry) and forwards it to current tab controller.
1038 except NoCurrentTabControllerException:
1042 """ Called when selectAll action is triggered (e.g. from menu entry) and forwards it to current tab controller.
1046 except NoCurrentTabControllerException:
1050 """ Called when find action is triggered (e.g. from menu entry) and forwards it to current tab controller.
1054 except NoCurrentTabControllerException:
1058 """ Handles button pressed event from zoom tool bar and forwards it to current tab controller.
1062 except NoCurrentTabControllerException:
1066 """ Handles button pressed event from zoom tool bar and forwards it to current tab controller.
1070 except NoCurrentTabControllerException:
1074 """ Handles button pressed event from zoom tool bar and forwards it to current tab controller.
1078 except NoCurrentTabControllerException:
1082 """ Handles undo action for buttons in undo tool bar and edit menu.
1086 sender = self.sender()
1088 num = sender.data().toInt()
1093 except NoCurrentTabControllerException:
1097 """ Handles redo action for buttons in undo tool bar and edit menu.
1101 sender = self.sender()
1103 num = sender.data().toInt()
1108 except NoCurrentTabControllerException:
1112 """ Displays about box.
1114 logging.debug(
'Application: aboutBoxSlot()')
1122 logging.warning(
"%s: openLogFileSlot(): _logFile not set. Aborting..." % self.__class__.__name__)
1125 """ Slot for opening recent file.
1127 Called from recent file menu action. Filename is set as data object (QVariant) of action.
1130 logging.debug(
'Application: openRecentFileSlot() - ' + filename)
1134 """ when a different tab is activated update menu
1136 logging.debug(
'Application: tabChanged()')
1146 except NoCurrentTabControllerException:
1152 """ Update menu and window title.
1158 return str(self._window.windowTitle()).
split(
"-")[0].strip()
1161 """ update window caption
1168 except NoCurrentTabControllerException:
1172 dirName = os.path.dirname(sys.argv[0])
1173 if os.path.abspath(dirName)
in filename:
1174 filename = filename[len(os.path.abspath(dirName)) + 1:]
1175 name = name +
" - " + filename
1176 self._window.setWindowTitle(name)
1180 self.
_ini = ConfigParser.ConfigParser()
1187 self._ini.write(configfile)
1194 """ Save the list of recent files.
1196 logging.debug(
'Application: _loadIni()')
1199 if ini.has_section(
"history"):
1201 if ini.has_option(
"history", str(i)):
1205 """ Load the list of recent files.
1207 logging.debug(
'Application: _saveIni()')
1209 if ini.has_section(
"history"):
1210 ini.remove_section(
"history")
1211 ini.add_section(
"history")
1218 """ Displays error message.
1220 QMessageBox.critical(self.
mainWindow(),
'Error', message)
1223 """ Displays warning message.
1225 QMessageBox.warning(self.
mainWindow(),
'Warning', message)
1228 """ Displays info message.
1230 QMessageBox.about(self.
mainWindow(),
'Info', message)
1232 def showMessageBox(self, text, informativeText="", standardButtons=QMessageBox.Ok | QMessageBox.Cancel | QMessageBox.Ignore, defaultButton=QMessageBox.Ok, extraButtons=None):
1233 """ Shows a standardized message box and returns the pressed button.
1235 See documentation on Qt's QMessageBox for a list of possible standard buttons.
1239 msgBox.setParent(self.
mainWindow(), Qt.Sheet)
1240 msgBox.setText(text)
1241 msgBox.setInformativeText(informativeText)
1242 msgBox.setStandardButtons(standardButtons)
1243 if extraButtons!=
None:
1244 for button,role
in extraButtons:
1245 msgBox.addButton(button,role)
1246 msgBox.setDefaultButton(defaultButton)
1247 return msgBox.exec_()
1250 """ Opens file given as argument if possible in Vispa.
1252 If Vispa cannot handle the file type the file will be opened in it's default application.
1254 logging.debug(self.__class__.__name__ +
": doubleClickOnFile() - " + str(filename))
1259 baseName = os.path.basename(filename)
1260 ext = os.path.splitext(baseName)[1].lower().strip(
".")
1263 if os.path.exists(filename):
1269 if 'Windows' in platform.system():
1270 os.startfile(filename)
1271 elif 'Darwin' in platform.system():
1272 if os.access(filename, os.X_OK):
1273 logging.warning(
"It seems that executing the python program is the default action on this system, which is processed when double clicking a file. Please change that to open the file witrh your favourite editor, to use this feature.")
1275 subprocess.call((
"open", filename))
1276 elif 'Linux' in platform.system():
1278 if os.access(filename, os.X_OK):
1279 logging.warning(
"It seems that executing the python program is the default action on this system, which is processed when double clicking a file. Please change that to open the file witrh your favourite editor, to use this feature.")
1283 subprocess.call((
"xdg-open", filename))
1286 subprocess.call((
"gnome-open", filename))
1288 logging.error(self.__class__.__name__ +
": doubleClickOnFile() - Platform '" + platform.platform() +
"'. Cannot open file. I Don't know how!")
1290 logging.error(self.__class__.__name__ +
": doubleClickOnFile() - Platform '" + platform.platform() +
"'. Error while opening file: " + str(filename))
1299 if len(self._workingMessages.keys()) == 0:
1300 self._progressWidget.start()
1301 self._window.statusBar().showMessage(message +
"...")
1304 self._progressWidget.setToolTip(message)
1308 if not id
in self._workingMessages.keys():
1309 logging.error(self.__class__.__name__ +
": stopWorking() - Unknown id %s. Aborting..." % str(id))
1311 if len(self._workingMessages.keys()) > 1:
1312 self._window.statusBar().showMessage(self.
_workingMessages[self._workingMessages.keys()[0]] +
"...")
1313 self._progressWidget.setToolTip(self.
_workingMessages[self._workingMessages.keys()[0]])
1315 self._progressWidget.stop()
1316 self._progressWidget.setToolTip(
"")
1317 self._window.statusBar().showMessage(self.
_workingMessages[id] +
"... " + end +
".")
1321 self.
mainWindow().tabWidget().setCurrentIndex(i)
1325 self._window.statusBar().showMessage(message, timeout)
1328 """ Cancel operations in current tab.
1330 logging.debug(__name__ +
": cancel")
1333 except NoCurrentTabControllerException:
_knownExtensionsDictionary
def updateMenuAndWindowTitle
string TAB_PREMATURELY_CLOSED_WARNING
string FAILED_LOADING_PLUGINS_ERROR
def _readCommandLineAttributes
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def _collectFileExtensions
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
def clearMissingRecentFiles
def _setCommandLineOptions
def setCurrentTabController
static std::string join(char **cmd)
int MAX_VISIBLE_UNDO_EVENTS
def _initCommandLineAttributes
int MAX_VISIBLE_RECENT_FILES
def recentFilesFromPlugin