本文整理汇总了Python中spyderlib.qt.QtCore.QProcess.kill方法的典型用法代码示例。如果您正苦于以下问题:Python QProcess.kill方法的具体用法?Python QProcess.kill怎么用?Python QProcess.kill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtCore.QProcess
的用法示例。
在下文中一共展示了QProcess.kill方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PylintWidget
# 需要导入模块: from spyderlib.qt.QtCore import QProcess [as 别名]
# 或者: from spyderlib.qt.QtCore.QProcess import kill [as 别名]
#.........这里部分代码省略.........
hlayout2.addWidget(self.log_button)
layout = QVBoxLayout()
layout.addLayout(hlayout1)
layout.addLayout(hlayout2)
layout.addWidget(self.treewidget)
self.setLayout(layout)
self.process = None
self.set_running_state(False)
if PYLINT_PATH is None:
for widget in (self.treewidget, self.filecombo,
self.start_button, self.stop_button):
widget.setDisabled(True)
if os.name == 'nt' \
and programs.is_module_installed("pylint"):
# Pylint is installed but pylint script is not in PATH
# (AFAIK, could happen only on Windows)
text = _('Pylint script was not found. Please add "%s" to PATH.')
text = to_text_string(text) % osp.join(sys.prefix, "Scripts")
else:
text = _('Please install <b>pylint</b>:')
url = 'http://www.logilab.fr'
text += ' <a href=%s>%s</a>' % (url, url)
self.ratelabel.setText(text)
else:
self.show_data()
def analyze(self, filename):
if PYLINT_PATH is None:
return
filename = to_text_string(filename) # filename is a QString instance
self.kill_if_running()
index, _data = self.get_data(filename)
if index is None:
self.filecombo.addItem(filename)
self.filecombo.setCurrentIndex(self.filecombo.count()-1)
else:
self.filecombo.setCurrentIndex(self.filecombo.findText(filename))
self.filecombo.selected()
if self.filecombo.is_valid():
self.start()
def select_file(self):
self.redirect_stdio.emit(False)
filename, _selfilter = getopenfilename(self, _("Select Python file"),
getcwd(), _("Python files")+" (*.py ; *.pyw)")
self.redirect_stdio.emit(True)
if filename:
self.analyze(filename)
def remove_obsolete_items(self):
"""Removing obsolete items"""
self.rdata = [(filename, data) for filename, data in self.rdata
if is_module_or_package(filename)]
def get_filenames(self):
return [filename for filename, _data in self.rdata]
def get_data(self, filename):
filename = osp.abspath(filename)
for index, (fname, data) in enumerate(self.rdata):
if fname == filename:
return index, data
else:
示例2: ProfilerWidget
# 需要导入模块: from spyderlib.qt.QtCore import QProcess [as 别名]
# 或者: from spyderlib.qt.QtCore.QProcess import kill [as 别名]
#.........这里部分代码省略.........
hlayout2.addWidget(self.expand_button)
hlayout2.addStretch()
hlayout2.addWidget(self.datelabel)
hlayout2.addStretch()
hlayout2.addWidget(self.log_button)
layout = QVBoxLayout()
layout.addLayout(hlayout1)
layout.addLayout(hlayout2)
layout.addWidget(self.datatree)
self.setLayout(layout)
self.process = None
self.set_running_state(False)
self.start_button.setEnabled(False)
if not is_profiler_installed():
# This should happen only on certain GNU/Linux distributions
# or when this a home-made Python build because the Python
# profilers are included in the Python standard library
for widget in (self.datatree, self.filecombo,
self.start_button, self.stop_button):
widget.setDisabled(True)
url = 'http://docs.python.org/library/profile.html'
text = '%s <a href=%s>%s</a>' % (_('Please install'), url,
_("the Python profiler modules"))
self.datelabel.setText(text)
else:
pass # self.show_data()
def analyze(self, filename, wdir=None, args=None, pythonpath=None):
if not is_profiler_installed():
return
self.kill_if_running()
#index, _data = self.get_data(filename)
index = None # FIXME: storing data is not implemented yet
if index is None:
self.filecombo.addItem(filename)
self.filecombo.setCurrentIndex(self.filecombo.count()-1)
else:
self.filecombo.setCurrentIndex(self.filecombo.findText(filename))
self.filecombo.selected()
if self.filecombo.is_valid():
if wdir is None:
wdir = osp.dirname(filename)
self.start(wdir, args, pythonpath)
def select_file(self):
self.emit(SIGNAL('redirect_stdio(bool)'), False)
filename, _selfilter = getopenfilename(self, _("Select Python script"),
getcwd(), _("Python scripts")+" (*.py ; *.pyw)")
self.emit(SIGNAL('redirect_stdio(bool)'), False)
if filename:
self.analyze(filename)
def show_log(self):
if self.output:
TextEditor(self.output, title=_("Profiler output"),
readonly=True, size=(700, 500)).exec_()
def show_errorlog(self):
if self.error_output:
TextEditor(self.error_output, title=_("Profiler output"),
readonly=True, size=(700, 500)).exec_()
def start(self, wdir=None, args=None, pythonpath=None):
示例3: PluginClient
# 需要导入模块: from spyderlib.qt.QtCore import QProcess [as 别名]
# 或者: from spyderlib.qt.QtCore.QProcess import kill [as 别名]
class PluginClient(QObject):
"""
A class which handles a connection to a plugin through a QProcess.
"""
# Emitted when the plugin has initialized.
initialized = Signal()
# Emitted when the plugin has failed to load.
errored = Signal()
# Emitted when a request response is received.
request_handled = Signal(object)
def __init__(self, plugin_name, executable=None):
super(PluginClient, self).__init__()
self.plugin_name = plugin_name
self.executable = executable or sys.executable
self.start()
def start(self):
"""Start a new connection with the plugin.
"""
self._initialized = False
plugin_name = self.plugin_name
self.sock, server_port = connect_to_port()
self.sock.listen(2)
QApplication.instance().aboutToQuit.connect(self.close)
self.process = QProcess(self)
self.process.setWorkingDirectory(os.path.dirname(__file__))
processEnvironment = QProcessEnvironment()
env = self.process.systemEnvironment()
python_path = imp.find_module('spyderlib')[1]
# Use the current version of the plugin provider if possible.
try:
provider_path = imp.find_module(self.plugin_name)[1]
python_path = os.sep.join([python_path, provider_path])
except ImportError:
pass
env.append("PYTHONPATH=%s" % python_path)
for envItem in env:
envName, separator, envValue = envItem.partition('=')
processEnvironment.insert(envName, envValue)
self.process.setProcessEnvironment(processEnvironment)
p_args = ['-u', 'plugin_server.py', str(server_port), plugin_name]
self.listener = PluginListener(self.sock)
self.listener.request_handled.connect(self.request_handled.emit)
self.listener.initialized.connect(self._on_initialized)
self.listener.start()
self.process.start(self.executable, p_args)
self.process.finished.connect(self._on_finished)
running = self.process.waitForStarted()
if not running:
raise IOError('Could not start plugin %s' % plugin_name)
def send(self, request):
"""Send a request to the plugin.
"""
if not self._initialized:
return
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("127.0.0.1", self.client_port))
request['plugin_name'] = self.plugin_name
write_packet(sock, request)
sock.close()
def close(self):
self.process.kill()
self.process.waitForFinished(200)
self.sock.close()
def _on_initialized(self, port):
debug_print('Initialized %s' % self.plugin_name)
self._initialized = True
self.client_port = port
self.initialized.emit()
def _on_finished(self):
debug_print('finished %s %s' % (self.plugin_name, self._initialized))
if self._initialized:
self.start()
else:
self._initialized = False
debug_print(self.process.readAllStandardOutput())
debug_print(self.process.readAllStandardError())
self.errored.emit()