ProjectPyramid/Project.py

changeset 106
2086bda4a893
parent 104
3e34b23890af
child 112
916727bdff4d
equal deleted inserted replaced
105:2a2faf098101 106:2086bda4a893
45 45
46 class QProcess(QProcessPyQt): 46 class QProcess(QProcessPyQt):
47 """ 47 """
48 Class transforming the call arguments in case of gnome-terminal. 48 Class transforming the call arguments in case of gnome-terminal.
49 """ 49 """
50 def start(self, cmd, args=[], mode=QProcessPyQt.ReadWrite): 50 def start(self, cmd, args=None, mode=QProcessPyQt.ReadWrite):
51 """ 51 """
52 Public method to start the given program (cmd) in a new process, if 52 Public method to start the given program (cmd) in a new process, if
53 none is already running, passing the command line arguments in args. 53 none is already running, passing the command line arguments in args.
54 54
55 @param cmd start the given program cmd (string) 55 @param cmd start the given program cmd (string)
56 @keyparam args list of parameters (list of strings) 56 @keyparam args list of parameters (list of strings)
57 @keyparam mode access mode (QIODevice.OpenMode) 57 @keyparam mode access mode (QIODevice.OpenMode)
58 """ 58 """
59 if args is None:
60 args = []
61
59 if cmd.endswith(('gnome-terminal', 'konsole', 'xfce4-terminal', 62 if cmd.endswith(('gnome-terminal', 'konsole', 'xfce4-terminal',
60 'mate-terminal')): 63 'mate-terminal')):
61 if '-e' in args: 64 if '-e' in args:
62 index = args.index('-e') + 1 65 index = args.index('-e') + 1
63 cargs = ' '.join(args[index:]) 66 cargs = ' '.join(args[index:])
64 args[index:] = [cargs] 67 args[index:] = [cargs]
65 68
66 super(QProcess, self).start(cmd, args, mode) 69 super(QProcess, self).start(cmd, args, mode)
67 70
68 @staticmethod 71 @staticmethod
69 def startDetached(cmd, args=[], path=''): 72 def startDetached(cmd, args=None, path=''):
70 """ 73 """
71 Public static method to start the given program (cmd) in a new process, 74 Public static method to start the given program (cmd) in a new process,
72 if none is already running, passing the command line arguments in args. 75 if none is already running, passing the command line arguments in args.
73 76
74 @param cmd start the given program cmd (string) 77 @param cmd start the given program cmd (string)
75 @keyparam args list of parameters (list of strings) 78 @keyparam args list of parameters (list of strings)
76 @keyparam path new working directory (string) 79 @keyparam path new working directory (string)
77 @return tuple of successful start and process id (boolean, integer) 80 @return tuple of successful start and process id (boolean, integer)
78 """ 81 """
82 if args is None:
83 args = []
84
79 if cmd.endswith(('gnome-terminal', 'konsole', 'xfce4-terminal', 85 if cmd.endswith(('gnome-terminal', 'konsole', 'xfce4-terminal',
80 'mate-terminal')): 86 'mate-terminal')):
81 if '-e' in args: 87 if '-e' in args:
82 index = args.index('-e') + 1 88 index = args.index('-e') + 1
83 cargs = ' '.join(args[index:]) 89 cargs = ' '.join(args[index:])
498 504
499 dlg = FormSelectionDialog() 505 dlg = FormSelectionDialog()
500 if dlg.exec_() == QDialog.Accepted: 506 if dlg.exec_() == QDialog.Accepted:
501 template = dlg.getTemplateText() 507 template = dlg.getTemplateText()
502 508
503 filter = self.tr( 509 fileFilters = self.tr(
504 "Chameleon Templates (*.pt);;" 510 "Chameleon Templates (*.pt);;"
505 "Chameleon Text Templates (*.txt);;" 511 "Chameleon Text Templates (*.txt);;"
506 "Mako Templates (*.mako);;" 512 "Mako Templates (*.mako);;"
507 "Mako Templates (*.mak);;" 513 "Mako Templates (*.mak);;"
508 "HTML Files (*.html);;" 514 "HTML Files (*.html);;"
510 "All Files (*)") 516 "All Files (*)")
511 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 517 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
512 self.__ui, 518 self.__ui,
513 self.tr("New Form"), 519 self.tr("New Form"),
514 path, 520 path,
515 filter, 521 fileFilters,
516 None, 522 None,
517 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) 523 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
518 if fname: 524 if fname:
519 ext = QFileInfo(fname).suffix() 525 ext = QFileInfo(fname).suffix()
520 if not ext: 526 if not ext:
587 path = os.getenv('PATH') 593 path = os.getenv('PATH')
588 594
589 # environment variable not defined 595 # environment variable not defined
590 if path is not None: 596 if path is not None:
591 dirs = path.split(os.pathsep) 597 dirs = path.split(os.pathsep)
592 for dir in dirs: 598 for directory in dirs:
593 exe = os.path.join(dir, file) 599 exe = os.path.join(directory, file)
594 if os.access(exe, os.X_OK) and exe not in paths: 600 if os.access(exe, os.X_OK) and exe not in paths:
595 paths.append(exe) 601 paths.append(exe)
596 602
597 return paths 603 return paths
598 604

eric ide

mercurial