本文整理汇总了Python中PyQt5.QtCore.QProcess方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QProcess方法的具体用法?Python QtCore.QProcess怎么用?Python QtCore.QProcess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore
的用法示例。
在下文中一共展示了QtCore.QProcess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_key
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def generate_key(self):
format = self.formatSelect.currentData()
length = self.lengthSelect.currentData()
if format == "rsa":
length = length[0]
else:
length = length[1]
output_path = os.path.expanduser(self.outputFileTextBox.text())
if os.path.isfile(output_path):
self.errors.setText("Key file already exists. Not overwriting.")
else:
self.sshproc = QProcess(self)
self.sshproc.finished.connect(self.generate_key_result)
self.sshproc.start(
"ssh-keygen", ["-t", format, "-b", length, "-f", output_path, "-N", ""]
)
示例2: info_preview
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def info_preview(self, command, picn, length, change_aspect, tsec, counter, x, y, use_existing=None, lock=None):
if self.preview_process.processId() != 0:
self.preview_process.kill()
if self.preview_process.processId() == 0 and lock is False and not use_existing:
ui.logger.debug('\npreview_generating - {} - {}\n'.format(length, tsec))
self.preview_process = QtCore.QProcess()
self.preview_process.finished.connect(partial(self.preview_generated, picn, length, change_aspect, tsec, counter, x, y))
QtCore.QTimer.singleShot(1, partial(self.preview_process.start, command))
elif use_existing:
newpicn = os.path.join(self.preview_dir, "{}.jpg".format(int(tsec)))
if ui.live_preview == 'fast':
self.apply_pic(newpicn, x, y, length)
ui.logger.debug('\n use existing preview image \n')
else:
self.preview_process = QtCore.QProcess()
command = 'echo "hello"'
self.preview_process.finished.connect(partial(self.preview_generated, picn, length, change_aspect, tsec, counter, x, y))
QtCore.QTimer.singleShot(1, partial(self.preview_process.start, command))
示例3: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def __init__(self):
super(ProgressWindow, self).__init__()
self.setupUi(self)
self.setWindowIcon(
QtGui.QIcon(pkg_resources.resource_filename('pipgui', ASSETS_DIR + 'googledev.png')))
# QProcess object for external app
self.process = QtCore.QProcess(self)
# QProcess emits `readyRead` when there is data to be read
self.process.readyRead.connect(self.dataReady)
self.process.started.connect(
lambda: self.btnContinue.setEnabled(False))
self.process.finished.connect(
lambda: self.btnContinue.setEnabled(True))
self.process.finished.connect(self.onFinished)
self.btnContinue.clicked.connect(self.continueFn)
示例4: show_term
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def show_term(self):
term = self.config.get("Applications", 'Shell')
args = [
"-bg", self.config.get("Applications", "backgroundColor"),
"-fg", self.config.get("Applications", "foregroundColor"),
# blink cursor
"-bc",
# title
"-T", QtWidgets.QApplication.translate(
"pychemqt", "pychemqt python console")]
if self.config.getboolean("Applications", "maximized"):
args.append("-maximized")
if self.config.getboolean("Applications", 'ipython') and \
which("ipython"):
args.append("ipython3")
else:
args.append("python3")
self.start(term, args)
if self.error() == QtCore.QProcess.FailedToStart:
print("xterm not installed")
示例5: generate_key
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def generate_key(self):
format = self.formatSelect.currentData()
length = self.lengthSelect.currentData()
if format == 'rsa':
length = length[0]
else:
length = length[1]
output_path = os.path.expanduser(self.outputFileTextBox.text())
if os.path.isfile(output_path):
self.errors.setText(self.tr('Key file already exists. Not overwriting.'))
else:
self.sshproc = QProcess(self)
self.sshproc.finished.connect(self.generate_key_result)
self.sshproc.start('ssh-keygen', ['-t', format, '-b', length, '-f', output_path, '-N', ''])
示例6: generateTagFile
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def generateTagFile(self, directoryLocation: str) -> bool:
location = shutil.which("ctags")
appDir = os.getcwd()
if location is None:
print("Please download universal ctags from the website https://github.com/universal-ctags/ctags")
return False
else:
os.chdir(directoryLocation)
generateProcess = QProcess(self)
command = [location, "-R"]
generateProcess.start(" ".join(command))
self.tagInfo.setText("Generating tags file...")
self.status.addWidget(self.tagInfo, Qt.AlignRight)
generateProcess.finished.connect(lambda: self.afterTagGeneration(appDir))
示例7: fake_qprocess
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def fake_qprocess():
"""Factory for a QProcess mock which has the QProcess enum values."""
m = mock.Mock(spec=QProcess)
for name in ['NormalExit', 'CrashExit', 'FailedToStart', 'Crashed',
'Timedout', 'WriteError', 'ReadError', 'UnknownError']:
setattr(m, name, getattr(QProcess, name))
return m
示例8: fixBroken
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def fixBroken(self):
self.labels[(3, 1)].setMovie(self.movie)
self.movie.start()
self.lbl1.setText("Cleaning up...")
self.logger.info("Cleaning up...")
self.progress2.setRange(0, 0)
self.setCursor(QtCore.Qt.BusyCursor)
process = QtCore.QProcess()
process.finished.connect(lambda: self.onFinished(process.exitCode(), process.exitStatus()))
process.start('bash', ['/usr/lib/resetter/data/scripts/fix-broken.sh'])
示例9: fixBroken
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def fixBroken(self):
self.labels[(3, 1)].setMovie(self.movie)
self.movie.start()
self.lbl1.setText("Cleaning up...")
self.logger.info("Cleaning up...")
self.progress.setRange(0, 0)
self.setCursor(QtCore.Qt.BusyCursor)
self.process = QtCore.QProcess()
self.process.start('bash', ['/usr/lib/resetter/data/scripts/fix-broken.sh'])
self.process.finished.connect(self.onFinished)
示例10: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def __init__(self):
self._p = QtCore.QProcess()
self._qmp = None
示例11: isRunning
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def isRunning(self):
return self._p is not None and self._p.state() == QtCore.QProcess.Running
示例12: run
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def run(self):
# 执行程序
if self.state:
process = QProcess()
process.startDetached('python', [self.fname])
示例13: open
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def open(self):
fname = self.get_file()
# 文件名非空
if fname:
process = QProcess()
process.startDetached('python', [fname])
#subprocess.run(['python', fname], shell=True)
#qApp.quit()
# 重写关闭事件
示例14: start_main_program
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def start_main_program(self):
"""Restart the (updated) main program and close the updater."""
self.download_window.setVisible(False)
artemis = QProcess()
try:
artemis.startDetached(Constants.EXECUTABLE_NAME)
except BaseException:
pass
qApp.quit()
示例15: _check_new_version
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QProcess [as 别名]
def _check_new_version(self):
"""Check whether there is a new software version available.
Does something only if the running program is a compiled version."""
if not IS_BINARY:
return None
latest_version = self.version_controller.software.version
if latest_version is None:
return False
if latest_version == self._current_version:
return False
answer = pop_up(
self._owner,
title=Messages.NEW_VERSION_AVAILABLE,
text=Messages.NEW_VERSION_MSG(latest_version),
informative_text=Messages.DOWNLOAD_SUGG_MSG,
is_question=True,
).exec()
if answer == QMessageBox.Yes:
if IS_MAC:
webbrowser.open(self.version_controller.software.url)
else:
updater = QProcess()
command = Constants.UPDATER_SOFTWARE + " " + \
self.version_controller.software.url + \
" " + self.version_controller.software.hash_code + \
" " + str(self.version_controller.software.size)
try:
updater.startDetached(command)
except BaseException:
logging.error("Unable to start updater")
pass
else:
qApp.quit()
return True