本文整理汇总了Python中PyQt5.QtCore.QProcessEnvironment类的典型用法代码示例。如果您正苦于以下问题:Python QProcessEnvironment类的具体用法?Python QProcessEnvironment怎么用?Python QProcessEnvironment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QProcessEnvironment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __main_execution
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()
示例2: __init__
def __init__(self, vcs, parent=None):
"""
Constructor
@param vcs reference to the vcs object
@param parent parent widget (QWidget)
"""
super(SvnPropListDialog, self).__init__(parent)
self.setupUi(self)
self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
self.process = QProcess()
env = QProcessEnvironment.systemEnvironment()
env.insert("LANG", "C")
self.process.setProcessEnvironment(env)
self.vcs = vcs
self.propsList.headerItem().setText(self.propsList.columnCount(), "")
self.propsList.header().setSortIndicator(0, Qt.AscendingOrder)
self.process.finished.connect(self.__procFinished)
self.process.readyReadStandardOutput.connect(self.__readStdout)
self.process.readyReadStandardError.connect(self.__readStderr)
self.rx_path = QRegExp(r"Properties on '([^']+)':\s*")
self.rx_prop = QRegExp(r" (.*) *: *(.*)[\r\n]")
self.lastPath = None
self.lastProp = None
self.propBuffer = ""
示例3: run
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)
示例4: init_broker
def init_broker(self):
print "[*] init_broker"
modname = self.input.text().encode('ascii', 'replace')
cmdline = u"\"%s\" -u \"%s\" --idb \"%s\"" % (
os.path.join(PYTHON_PATH, PYTHON_BIN),
BROKER_PATH, modname)
print "[*] init broker,", cmdline
self.broker = Broker(self.parser)
env = QProcessEnvironment.systemEnvironment()
env.insert("IDB_PATH", IDB_PATH)
env.insert("PYTHON_PATH", os.path.realpath(PYTHON_PATH))
env.insert("PYTHON_BIN", PYTHON_BIN)
try:
self.broker.started.connect(self.cb_broker_started)
self.broker.finished.connect(self.cb_broker_finished)
self.broker.setProcessEnvironment(env)
self.broker.start(cmdline)
except Exception as e:
print "[-] failed to start broker: %s\n%s" % (str(e), traceback.format_exc())
return
self.init_hotkeys()
self.broker.worker.name = modname
示例5: startProcess
def startProcess(self, args, workingDir=None, setLanguage=False):
"""
Public slot used to start the process.
@param args list of arguments for the process (list of strings)
@param workingDir working directory for the process (string)
@param setLanguage flag indicating to set the language to "C" (boolean)
@return flag indicating a successful start of the process
"""
self.errorGroup.hide()
self.normal = False
self.intercept = False
self.__hasAddOrDelete = False
self.proc = QProcess()
if setLanguage:
env = QProcessEnvironment.systemEnvironment()
env.insert("LANG", "C")
self.proc.setProcessEnvironment(env)
nargs = []
lastWasPwd = False
for arg in args:
if lastWasPwd:
lastWasPwd = True
continue
nargs.append(arg)
if arg == '--password':
lastWasPwd = True
nargs.append('*****')
self.resultbox.append(' '.join(nargs))
self.resultbox.append('')
self.proc.finished.connect(self.__procFinished)
self.proc.readyReadStandardOutput.connect(self.__readStdout)
self.proc.readyReadStandardError.connect(self.__readStderr)
if workingDir:
self.proc.setWorkingDirectory(workingDir)
self.proc.start('svn', args)
procStarted = self.proc.waitForStarted(5000)
if not procStarted:
self.buttonBox.setFocus()
self.inputGroup.setEnabled(False)
self.inputGroup.hide()
E5MessageBox.critical(
self,
self.tr('Process Generation Error'),
self.tr(
'The process {0} could not be started. '
'Ensure, that it is in the search path.'
).format('svn'))
else:
self.inputGroup.setEnabled(True)
self.inputGroup.show()
return procStarted
示例6: launchQml
def launchQml(self, name):
import_path = self.resolveDataDir(name)
qml = self.resolveQmlFile(name)
process = QProcess(self)
process.error.connect(self.launchError)
env = QProcessEnvironment.systemEnvironment()
env.insert('QML2_IMPORT_PATH', import_path)
process.setProcessEnvironment(env)
executable = QLibraryInfo.location(QLibraryInfo.BinariesPath) + '/qmlscene'
Colors.debug("Launching:", executable)
process.start(executable, [qml])
示例7: __startProcess
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
示例8: open_app
def open_app(self, instance, path, args, vproject):
current_state = instance.state()
if current_state == QProcess.NotRunning:
env = QProcessEnvironment.systemEnvironment()
env.insert('VPROJECT', vproject)
instance.setProcessEnvironment(env)
instance.start('"{}"'.format(path), args)
instance.waitForStarted()
else:
show_dialog(
title='Instance Already Running',
text='A instance of that app is already running!',
icon='Information',
parent=self,
)
示例9: _start
def _start(self, args, env):
"""Actually start the process."""
executable, exec_args = self._executable_args()
if args is None:
args = self._default_args()
procenv = QProcessEnvironment.systemEnvironment()
if env is not None:
for k, v in env.items():
procenv.insert(k, v)
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()
示例10: _run_process
def _run_process(self, cmd, *args, env):
"""Start the given command via QProcess.
Args:
cmd: The command to be started.
*args: The arguments to hand to the command
env: A dictionary of environment variables to add.
"""
self._proc = QProcess(self)
procenv = QProcessEnvironment.systemEnvironment()
procenv.insert('QUTE_FIFO', self._filepath)
if env is not None:
for k, v in env.items():
procenv.insert(k, v)
self._proc.setProcessEnvironment(procenv)
self._proc.error.connect(self.on_proc_error)
self._proc.finished.connect(self.on_proc_finished)
self._proc.start(cmd, args)
示例11: prepareProcess
def prepareProcess(proc, encoding="", language=""):
"""
Public function to prepare the given process.
@param proc reference to the proces to be prepared (QProcess)
@param encoding encoding to be used by the process (string)
@param language language to be set (string)
"""
env = QProcessEnvironment.systemEnvironment()
env.insert("HGPLAIN", '1')
# set the encoding for the process
if encoding:
env.insert("HGENCODING", encoding)
# set the language for the process
if language:
env.insert("LANGUAGE", language)
proc.setProcessEnvironment(env)
示例12: qtDesignerStart
def qtDesignerStart():
""" Set widgets/plugins paths and start QtDesigner """
# Get base path and QProcess system environment
base = os.path.dirname(__file__)
env = QProcessEnvironment.systemEnvironment()
# Path for tell python where it can find the widgets directory
pybase = os.path.join(base, 'python')
# Path for tell QtDesigner where it can find the plugins directory
wbase = os.path.join(base, 'widgets')
# Insert paths to QProcess system environment
env.insert('PYQTDESIGNERPATH', pybase)
env.insert('PYTHONPATH', wbase)
# inform user
inform('env add "PYQTDESIGNERPATH" plugins path - ' + pybase)
inform('env add "PYTHONPATH" widgets path - ' + wbase)
# Create QProcess and set environment
designer = QProcess()
designer.setProcessEnvironment(env)
# Get QtDesigner binaries path
designer_bin = QLibraryInfo.location(QLibraryInfo.BinariesPath)
# Platform specefic
if sys.platform == 'darwin':
designer_bin += '/Designer.app/Contents/MacOS/Designer'
else:
designer_bin += '/designer'
# inform user
inform('designer bin - ' + designer_bin)
inform('start QtDesigner...')
# Start QtDesigner
designer.start(designer_bin)
designer.waitForFinished(-1)
sys.exit(designer.exitCode())
示例13: launchExample
def launchExample(self, name):
executable = self.resolveExeFile(name)
process = QProcess(self)
process.error.connect(self.launchError)
if sys.platform == 'win32':
# Make sure it finds the DLLs on Windows.
env = QProcessEnvironment.systemEnvironment()
env.insert('PATH',
QLibraryInfo.location(QLibraryInfo.BinariesPath) + ';' +
env.value('PATH'))
process.setProcessEnvironment(env)
if self.info[name]['changedirectory'] != 'false':
workingDirectory = self.resolveDataDir(name)
process.setWorkingDirectory(workingDirectory)
Colors.debug("Setting working directory:", workingDirectory)
Colors.debug("Launching:", executable)
process.start(sys.executable, [executable])
示例14: __init__
def __init__(self, what, *, verbose=False, additional_env=None, parent=None):
super().__init__(parent)
self._what = what
self.verbose = verbose
self._started = False
self.cmd = None
self.args = None
self._proc = QProcess(self)
self._proc.error.connect(self.on_error)
self._proc.error.connect(self.error)
self._proc.finished.connect(self.on_finished)
self._proc.finished.connect(self.finished)
self._proc.started.connect(self.on_started)
self._proc.started.connect(self.started)
if additional_env is not None:
procenv = QProcessEnvironment.systemEnvironment()
for k, v in additional_env.items():
procenv.insert(k, v)
self._proc.setProcessEnvironment(procenv)
示例15: flashDataPathForOS
def flashDataPathForOS():
"""
Function to determine the OS dependent path where Flash cookies
are stored.
@return Flash data path
@rtype str
"""
# On Microsoft Windows NT 5.x and 6.x, they are stored in:
# %APPDATA%\Macromedia\Flash Player\#SharedObjects\
# %APPDATA%\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys\
# On Mac OS X, they are stored in:
# ~/Library/Preferences/Macromedia/Flash Player/#SharedObjects/
# ~/Library/Preferences/Macromedia/Flash Player/macromedia.com/support/⏎
# flashplayer/sys/
# On Linux or Unix, they are stored in:
# ~/.macromedia/Flash_Player/#SharedObjects/
# ~/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys/
# For Linux and Unix systems, if the open-source Gnash plugin is being used
# instead of the official Adobe Flash, they will instead be found at:
# ~/.gnash/SharedObjects/
flashPath = ""
if Globals.isWindowsPlatform():
appData = QProcessEnvironment.systemEnvironment().value("APPDATA")
appData = appData.replace("\\", "/")
flashPath = appData + "/Macromedia/Flash Player"
elif Globals.isMacPlatform():
flashPath = os.path.expanduser(
"~/Library/Preferences/Macromedia/Flash Player")
else:
if os.path.exists(os.path.expanduser("~/.macromedia")):
flashPath = os.path.expanduser("~/.macromedia/Flash_Player")
elif os.path.exists(os.path.expanduser("~/.gnash")):
flashPath = os.path.expanduser("~/.gnash")
return flashPath