--- a/ProjectPyramid/Project.py Thu Dec 22 15:55:52 2016 +0100 +++ b/ProjectPyramid/Project.py Fri Dec 23 17:15:21 2016 +0100 @@ -56,8 +56,12 @@ @keyparam args list of parameters (list of strings) @keyparam mode access mode (QIODevice.OpenMode) """ - if cmd.endswith('gnome-terminal') and args[0] == '-e': - args = ['-e', ' '.join(args[1:])] + if cmd.endswith(('gnome-terminal', 'konsole', 'xfce4-terminal', + 'mate-terminal')): + if '-e' in args: + index = args.index('-e') + 1 + cargs = ' '.join(args[index:]) + args[index:] = [cargs] super(QProcess, self).start(cmd, args, mode) @@ -72,8 +76,12 @@ @keyparam path new working directory (string) @return tuple of successful start and process id (boolean, integer) """ - if cmd.endswith('gnome-terminal') and args[0] == '-e': - args = ['-e', ' '.join(args[1:])] + if cmd.endswith(('gnome-terminal', 'konsole', 'xfce4-terminal', + 'mate-terminal')): + if '-e' in args: + index = args.index('-e') + 1 + cargs = ' '.join(args[index:]) + args[index:] = [cargs] return QProcessPyQt.startDetached(cmd, args, path) @@ -770,7 +778,7 @@ """ Private slot to show some info about Pyramid. """ - version = self.getPyramidVersion() + version = self.getPyramidVersionString() url = "http://www.pylonsproject.org/projects/pyramid/about" msgBox = E5MessageBox.E5MessageBox( @@ -792,11 +800,12 @@ os.path.join("ProjectPyramid", "icons", "pyramid64.png"))) msgBox.exec_() - def getPyramidVersion(self): + def getPyramidVersionString(self): """ - Public method to get the Pyramid version. + Public method to get the Pyramid version as a string. - @return Pyramid version (string) + @return Pyramid version + @rtype str """ if not self.__pyramidVersion: cmd = self.getPyramidCommand("pcreate") @@ -816,6 +825,24 @@ return self.__pyramidVersion + def getPyramidVersion(self): + """ + Public method to get the Pyramid version as a tuple. + + @return Pyramid version + @rtype tuple of int + """ + pyramidVersionStr = self.getPyramidVersionString() + pyramidVersionList = [] + if pyramidVersionStr: + for part in pyramidVersionStr.split("."): + try: + pyramidVersionList.append(int(part)) + except ValueError: + pyramidVersionList.append(part) + + return tuple(pyramidVersionList) + def isSpawningConsole(self, consoleCmd): """ Public method to check, if the given console is a spawning console. @@ -830,6 +857,24 @@ else: return (False, consoleCmd) + def __adjustWorkingDirectory(self, args, wd): + """ + Private method to adjust the working directory in the arguments list. + + @param args list of arguments to be modified + @type list of str + @param wd working directory + @type str + """ + if args[0].endswith("konsole") and "--workdir" in args: + index = args.index("--workdir") + args[index + 1] = wd + elif args[0].endswith(("gnome-terminal", "mate-terminal")): + for index in range(len(args)): + if args[index].startswith("--working-directory="): + args[index] = "--working-directory={0}".format(wd) + break + ################################################################## ## slots below implement creation functions ################################################################## @@ -1096,14 +1141,17 @@ port = config.get("server:main", "port") except (configparser.NoOptionError, configparser.NoSectionError): port = "8080" - url = QUrl("http://localhost:{0}".format(port)) - res = QDesktopServices.openUrl(url) - if not res: - E5MessageBox.critical( - self.__ui, - self.tr('Run Web-Browser'), - self.tr('Could not start the web-browser for the URL' - ' "{0}".').format(url.toString())) + url = "http://localhost:{0}".format(port) + if self.__plugin.getPreferences("UseExternalBrowser"): + res = QDesktopServices.openUrl(QUrl(url)) + if not res: + E5MessageBox.critical( + self.__ui, + self.tr('Run Web-Browser'), + self.tr('Could not start the web-browser for the URL' + ' "{0}".').format(url.toString())) + else: + self.__ui.launchHelpViewer(url) def __runPythonShell(self): """ @@ -1135,6 +1183,7 @@ args.append("--python-shell={0}".format(consoleType)) args.append(os.path.join(projectPath, "development.ini")) + self.__adjustWorkingDirectory(args, projectPath) started, pid = QProcess.startDetached( args[0], args[1:], projectPath) if not started: