本文整理汇总了Python中PyQt5.QtCore.QProcessEnvironment.insert方法的典型用法代码示例。如果您正苦于以下问题:Python QProcessEnvironment.insert方法的具体用法?Python QProcessEnvironment.insert怎么用?Python QProcessEnvironment.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QProcessEnvironment
的用法示例。
在下文中一共展示了QProcessEnvironment.insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from PyQt5.QtCore import QProcessEnvironment [as 别名]
# 或者: from PyQt5.QtCore.QProcessEnvironment import insert [as 别名]
def run(self, *args, cwd=None):
env = QProcessEnvironment().systemEnvironment()
for k, v in self.get_subprocess_env().items():
env.insert(k, v)
self.process = QProcess(self)
self.process.setProcessEnvironment(env)
if cwd:
self.process.setWorkingDirectory(cwd)
# self.process.stateChanged.connect(self.stateChanged)
self.process.readyReadStandardOutput.connect(self.on_stdout_read)
self.process.readyReadStandardError.connect(self.on_stderr_read)
self.process.finished.connect(self.on_process_end)
self.clear()
self.process.start(args[0], args[1:], QIODevice.ReadWrite)
示例2: __main_execution
# 需要导入模块: from PyQt5.QtCore import QProcessEnvironment [as 别名]
# 或者: from PyQt5.QtCore.QProcessEnvironment import insert [as 别名]
def __main_execution(self):
self.__elapsed.start()
self.__current_process = self.main_process
if not self.only_text:
# In case a text is executed and not a file or project
file_directory = file_manager.get_folder(self.filename)
self.main_process.setWorkingDirectory(file_directory)
self.main_process.setProgram(self.python_exec)
self.main_process.setArguments(self.arguments)
environment = QProcessEnvironment()
system_environment = self.main_process.systemEnvironment()
for env in system_environment:
key, value = env.split("=", 1)
environment.insert(key, value)
self.main_process.setProcessEnvironment(environment)
self.main_process.start()
示例3: __startProcess
# 需要导入模块: from PyQt5.QtCore import QProcessEnvironment [as 别名]
# 或者: from PyQt5.QtCore.QProcessEnvironment import insert [as 别名]
def __startProcess(self, program, arguments, environment=None):
"""
Private method to start the debugger client process.
@param program name of the executable to start (string)
@param arguments arguments to be passed to the program (list of string)
@param environment dictionary of environment settings to pass
(dict of string)
@return the process object (QProcess) or None
"""
proc = QProcess()
if environment is not None:
env = QProcessEnvironment()
for key, value in list(environment.items()):
env.insert(key, value)
proc.setProcessEnvironment(env)
args = []
for arg in arguments:
args.append(arg)
proc.start(program, args)
if not proc.waitForStarted(10000):
proc = None
return proc
示例4: _start
# 需要导入模块: from PyQt5.QtCore import QProcessEnvironment [as 别名]
# 或者: from PyQt5.QtCore.QProcessEnvironment import insert [as 别名]
def _start(self, args, env):
"""Actually start the process."""
executable, exec_args = self._executable_args()
if args is None:
args = self._default_args()
if env is None:
procenv = QProcessEnvironment.systemEnvironment()
else:
procenv = QProcessEnvironment()
for k, v in env.items():
procenv.insert(k, v)
passthrough_vars = ['DISPLAY', 'HOME'] # so --no-xvfb works
for var in passthrough_vars:
if var in os.environ:
procenv.insert(var, os.environ[var])
self.proc.readyRead.connect(self.read_log)
self.proc.setProcessEnvironment(procenv)
self.proc.start(executable, exec_args + args)
ok = self.proc.waitForStarted()
assert ok
assert self.is_running()
示例5: __main_execution
# 需要导入模块: from PyQt5.QtCore import QProcessEnvironment [as 别名]
# 或者: from PyQt5.QtCore.QProcessEnvironment import insert [as 别名]
def __main_execution(self):
"""Execute the project."""
self.output.setCurrentCharFormat(self.output.plain_format)
message = ''
if self.__preScriptExecuted:
self.__preScriptExecuted = False
message = _translate("RunWidget",
"Pre Execution Script Successfully executed.\n\n")
self.output.setPlainText(message + 'Running: %s (%s)\n\n' %
(self.fileName, time.ctime()))
self.output.moveCursor(QTextCursor.Down)
self.output.moveCursor(QTextCursor.Down)
self.output.moveCursor(QTextCursor.Down)
#runner.run_code_from_file(fileName)
if not self.pythonPath:
self.pythonPath = settings.PYTHON_PATH
#change the working directory to the fileName dir
file_directory = file_manager.get_folder(self.fileName)
self._proc.setWorkingDirectory(file_directory)
#force python to unbuffer stdin and stdout
options = ['-u'] + settings.EXECUTION_OPTIONS.split()
self.currentProcess = self._proc
env = QProcessEnvironment()
system_environemnt = self._proc.systemEnvironment()
for e in system_environemnt:
key, value = e.split('=', 1)
env.insert(key, value)
if self.PYTHONPATH:
envpaths = [path for path in self.PYTHONPATH.splitlines()]
for path in envpaths:
env.insert('PYTHONPATH', path)
env.insert('PYTHONIOENCODING', 'utf-8')
self._proc.setProcessEnvironment(env)
self._proc.start(self.pythonPath, options + [self.fileName] +
[p.strip() for p in self.programParams.split(',') if p])