def get_env_variable(variable): from PyQt4.QtCore import QProcessEnvironment env = QProcessEnvironment.systemEnvironment() if env.contains(variable): return str(env.value(variable)) else: return None
def __init__(self, name, project, **kwargs): super(BatchFileSync, self).__init__(name, project) self.cmd = kwargs['cmd'] if self.project: self.rootfolder = os.path.abspath(self.project.folder) else: self.rootfolder = kwargs['rootfolder'] self.project = project self.closeproject = kwargs.get("close_project", False) self.process = QProcess() self.parser = kwargs.get("parser", None) self.parsermodule = None variables = kwargs.get("variables", {}) env = QProcessEnvironment.systemEnvironment() for varname, value in variables.iteritems(): env.insert(varname, str(value)) self.process.setProcessEnvironment(env) self.process.setWorkingDirectory(os.path.dirname(os.path.realpath(self.cmd))) self.process.finished.connect(self.complete) self.process.started.connect(self.syncStarted) self.process.readyReadStandardError.connect(self.error) self.process.readyReadStandardOutput.connect(self.readOutput) self._output = "" self.haserror = False
def __init__(self, name, project, **kwargs): super(BatchFileSync, self).__init__(name, project) self.cmd = kwargs['cmd'] if self.project: self.rootfolder = os.path.abspath(self.project.folder) else: self.rootfolder = kwargs['rootfolder'] self.project = project self.closeproject = kwargs.get("close_project", False) self.process = QProcess() self.parser = kwargs.get("parser", None) self.parsermodule = None variables = kwargs.get("variables", {}) env = QProcessEnvironment.systemEnvironment() for varname, value in variables.iteritems(): env.insert(varname, str(value)) self.process.setProcessEnvironment(env) self.process.setWorkingDirectory( os.path.dirname(os.path.realpath(self.cmd))) self.process.finished.connect(self.complete) self.process.started.connect(self.syncStarted) self.process.readyReadStandardError.connect(self.error) self.process.readyReadStandardOutput.connect(self.readOutput) self._output = "" self.haserror = False
def __init__(self): super(EjecutarWidget, self).__init__() layoutV = QVBoxLayout(self) layoutV.setContentsMargins(0, 0, 0, 0) layoutV.setSpacing(0) self.output = output_compiler.SalidaCompilador(self) layoutV.addWidget(self.output) self.setLayout(layoutV) # Flag self._compilation_failed = False # Procesos self.build_process = QProcess(self) if not sys.platform.startswith('linux'): self._envgcc = QProcessEnvironment.systemEnvironment() self._envgcc.insert("PATH", ENV_GCC) self.build_process.setProcessEnvironment(self._envgcc) self.execution_process = QProcess(self) # Conexiones self.build_process.readyReadStandardError.connect( self.output.stderr_output) self.build_process.finished[int, QProcess.ExitStatus].connect( self._compilation_finished) self.build_process.error[QProcess.ProcessError].connect( self._compilation_error) self.execution_process.finished[int, QProcess.ExitStatus].connect( self._execution_finished)
def set_process_env(process): dirname = os.path.dirname(os.path.abspath(__file__)) env = QProcessEnvironment.systemEnvironment() env.insert("ITK_AUTOLOAD_PATH", os.path.join(dirname, "win32", "plugin")) # Add an environment variable env.insert("PATH", os.path.join(dirname, "win32", "bin") + ";" + env.value("Path")) process.setProcessEnvironment(env)
def __init__(self, name, **kwargs): super(BatchFileSync, self).__init__(name) self.cmd = kwargs['cmd'] self.process = QProcess() variables = kwargs.get("variables", {}) env = QProcessEnvironment.systemEnvironment() for varname, value in variables.iteritems(): env.insert(varname, value) self.process.setProcessEnvironment(env) self.process.setWorkingDirectory(os.path.dirname(os.path.realpath(self.cmd))) self.process.finished.connect(self.complete) self.process.started.connect(self.syncStarted) self.process.readyReadStandardError.connect(self.error) self.process.readyReadStandardOutput.connect(self.readOutput) self._output = "" self.haserror = False
def _updateProcessEnvironment(self): """Called internally; initializes the environment for the process.""" se = QProcessEnvironment.systemEnvironment() for k, v in self.environment.items(): se.remove(k) if v is None else se.insert(k, v) self._process.setProcessEnvironment(se)
def main(argv): path = None first_arg = None second_arg = None config = None apath = None print("QT VERSION %s" % QT_VERSION_STR ) try: first_arg = argv[1] second_arg = argv[2] except IndexError: pass if first_arg is not None: if first_arg == "-c": config = True if second_arg is not None: path = second_arg else: path = first_arg try: #app = QApplication(argv) app = MyApp(argv) QCoreApplication.setOrganizationDomain('www.trickplay.com'); QCoreApplication.setOrganizationName('Trickplay'); QCoreApplication.setApplicationName('Trickplay Debugger'); QCoreApplication.setApplicationVersion('0.0.1'); s = QProcessEnvironment.systemEnvironment().toStringList() for item in s: k , v = str( item ).split( "=" , 1 ) if k == 'PWD': apath = v apath = os.path.join(apath, os.path.dirname(str(argv[0]))) main = MainWindow(app, apath) main.config = config main.show() main.raise_() wizard = Wizard() app.main = main path = wizard.start(path) if path: settings = QSettings() settings.setValue('path', path) app.setActiveWindow(main) main.start(path, wizard.filesToOpen()) main.show() sys.exit(app.exec_()) # TODO, better way of doing this for 'clean' exit... except KeyboardInterrupt: exit("Exited")
def main(argv): path = None first_arg = None second_arg = None config = None apath = None print("QT VERSION %s" % QT_VERSION_STR) try: first_arg = argv[1] second_arg = argv[2] except IndexError: pass if first_arg is not None: if first_arg == "-c": config = True if second_arg is not None: path = second_arg else: path = first_arg try: #app = QApplication(argv) app = MyApp(argv) QCoreApplication.setOrganizationDomain('www.trickplay.com') QCoreApplication.setOrganizationName('Trickplay') QCoreApplication.setApplicationName('Trickplay Debugger') QCoreApplication.setApplicationVersion('0.0.1') s = QProcessEnvironment.systemEnvironment().toStringList() for item in s: k, v = str(item).split("=", 1) if k == 'PWD': apath = v apath = os.path.join(apath, os.path.dirname(str(argv[0]))) main = MainWindow(app, apath) main.config = config main.show() main.raise_() wizard = Wizard() app.main = main path = wizard.start(path) if path: settings = QSettings() settings.setValue('path', path) app.setActiveWindow(main) main.start(path, wizard.filesToOpen()) main.show() sys.exit(app.exec_()) # TODO, better way of doing this for 'clean' exit... except KeyboardInterrupt: exit("Exited")
def _update_process_environment(self): """(internal) initializes the environment for the process.""" se = QProcessEnvironment.systemEnvironment() for k, v in self.environment.items(): se.remove(k) if v is None else se.insert(k, v) self._process.setProcessEnvironment(se)