Python PyQt4.QtCore 模块,QProcess() 实例源码

我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用PyQt4.QtCore.QProcess()

项目:pip-gui    作者:GDGVIT    | 项目源码 | 文件源码
def initUI(self):
        # Layout are better for placing widgets
        layout = QtGui.QHBoxLayout()
        self.runButton = QtGui.QPushButton('Run')
        self.runButton.clicked.connect(self.callProgram)
        self.output = QtGui.QTextEdit()
        layout.addWidget(self.output)
        layout.addWidget(self.runButton)
        centralWidget = QtGui.QWidget()
        centralWidget.setLayout(layout)
        self.setCentralWidget(centralWidget)
        # 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)
        # Just to prevent accidentally running multiple times
        # Disable the button when process starts, and enable it when it finishes
        self.process.started.connect(lambda: self.runButton.setEnabled(False))
        self.process.finished.connect(lambda: self.runButton.setEnabled(True))


#Function Main Start
项目:olive-gui    作者:dturevski    | 项目源码 | 文件源码
def onRun(self):
        self.setActionEnabled(False)
        self.output.clear()

        handle, self.temp_filename = tempfile.mkstemp()

        input = self.input.toPlainText().toAscii()

        os.write(handle, input)
        os.close(handle)

        self.chestProc = QtCore.QProcess()
        self.chestProc.readyReadStandardOutput.connect(self.onOut)
        self.chestProc.readyReadStandardError.connect(self.onError)
        self.chestProc.finished.connect(self.onFinished)

        chest_exe = self.Conf.chest['path']
        params = self.Conf.chest['options'].split()
        params.append(self.temp_filename)

        self.chestProc.error.connect(self.onFailed)
        self.chestProc.start(chest_exe, params)
项目:olive-gui    作者:dturevski    | 项目源码 | 文件源码
def runPopeyeInGui(self, input):
        self.setActionEnabled(False)

        self.reset()
        self.entry_copy = copy.deepcopy(Mainframe.model.cur())

        Mainframe.sigWrapper.sigFocusOnPopeye.emit()

        # writing input to temporary file
        handle, self.temp_filename = tempfile.mkstemp()
        os.write(handle, input)
        os.close(handle)

        self.process = QtCore.QProcess()
        self.process.readyReadStandardOutput.connect(self.onOut)
        self.process.readyReadStandardError.connect(self.onError)
        self.process.finished.connect(self.onFinished)
        # self.process.closeWriteChannel()
        py_exe = Conf.popeye['path']
        params = ['-maxmem', str(Conf.popeye['memory']) + 'M']
        params.append(self.temp_filename)
        #print py_exe, params
        self.process.error.connect(self.onFailed)
        self.process.start(py_exe, params)
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(CommandWidget,self).__init__(*args, **kwargs)
        ui.load('commandwidget.ui', self)

        self._process = QtCore.QProcess(self)
        QtCore.QObject.connect(self._process, QtCore.SIGNAL('readyReadStandardOutput()'), self.readStandardOutput)
        QtCore.QObject.connect(self._process, QtCore.SIGNAL('readyReadStandardError()'), self.readStandardError)
        QtCore.QObject.connect(self._process, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.processExited)
        QtCore.QObject.connect(self._process, QtCore.SIGNAL('stateChanged(QProcess::ProcessState)'), self.processStateChanged)
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def processExited(self, exitCode, exitStatus):
        self.setConsoleColor('gray')
        if exitStatus == QtCore.QProcess.NormalExit:
            self.consoleView.appendPlainText('<exited with status %d>' % exitCode)
        else:
            self.consoleView.appendPlainText('<terminated>')
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def processStateChanged(self, state):
        if state == QtCore.QProcess.Running:
            self.terminateButton.setEnabled(True)
        else:
            self.terminateButton.setEnabled(False)
项目:core-framework    作者:RedhawkSDR    | 项目源码 | 文件源码
def processActive(self):
        return self._process.state() != QtCore.QProcess.NotRunning
项目:pip-gui    作者:GDGVIT    | 项目源码 | 文件源码
def __init__(self):
        msgInt = int()
        super(ProgressWindow, self).__init__()
        self.setupUi(self)
        self.setWindowIcon(QtGui.QIcon('pip_gui/Resource_Files/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.btnContinue.clicked.connect(self.continueFn)
项目:pip-gui    作者:GDGVIT    | 项目源码 | 文件源码
def callProgram(self):
        #for i in ['flask', '1337', 'pymouse']:
            #self.process.state()
            #process = QtCore.QProcess(self)
            #process.start('pip', ['install', i])
        #QtCore.QProcess(self).start('pip', ['install', 'flask'])
        #self.process.start('pip', ['uninstall', 'flask', '-y', '1337', '-y'])
        self.process.start('pip', ['install', 'flask', '1337'])
        #self.QtCore.QProcess(self).start('y', [])
项目:Cfd    作者:qingfengxia    | 项目源码 | 文件源码
def test_bash_QProcess():
    from PyQt4 import QtCore
    process = QtCore.QProcess()
    process.setProcessChannelMode(QtCore.QProcess.MergedChannels)
    #process.finished.connect()
    #QProcess works wtih `bash -l -c` but not `bash -i -c`
    #process.start('bash', ['-l', '-c', 'echo $WM_PROJECT_DIR'])  # work if start in gnome-terminal
    #~/.bashrc is not recognized, need a full path to the etc file
    process.start('bash', ['-c', '"source ~/.bashrc && echo $WM_PROJECT_DIR"'])  #
    print('Test in QProcess')
    if process.waitForFinished():
        print(process.readAll())
    print('End of Test in QProcess')
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def infoWgetM(self,command):
        wget = QtCore.QProcess()
        wget.started.connect(self.startedM)
        wget.finished.connect(self.finishedM)
        QtCore.QTimer.singleShot(1000, partial(wget.start, command))
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def infoWget(self,command,src):
        global wget

        wget = QtCore.QProcess()
        wget.setProcessChannelMode(QtCore.QProcess.MergedChannels)


        wget.started.connect(self.startedW)
        wget.readyReadStandardOutput.connect(partial(self.dataReadyW,wget))
        #self.tab_5.setFocus()
        wget.finished.connect(lambda x=src : self.finishedW(src))
        QtCore.QTimer.singleShot(1000, partial(wget.start, command))
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def infoPlay(self,command):
        global mpvplayer,Player,site,new_epn

        if mpvplayer:
            if mpvplayer.pid()>0:
                mpvplayer.kill()
        mpvplayer = QtCore.QProcess()
        mpvplayer.setProcessChannelMode(QtCore.QProcess.MergedChannels)
        mpvplayer.started.connect(self.started)
        mpvplayer.readyReadStandardOutput.connect(partial(self.dataReady,mpvplayer))
        #self.tab_5.setFocus()
        mpvplayer.finished.connect(self.finished)
        QtCore.QTimer.singleShot(1000, partial(mpvplayer.start, command))
项目:attify-badge    作者:attify    | 项目源码 | 文件源码
def __init__(self,dialog,parent=None):
                Ui_MainWindow.__init__(self)
        self.ser=serial.Serial()
                self.setupUi(dialog)
        self.UART_getports()
#       self.actionExit.mousePressEvent.connect(exit())
        self.pushButton_UartRefresh.clicked.connect(self.UART_getports)
                self.pushButton_UartConnect.clicked.connect(self.UART_connect)
        self.lineEdit_UartInput.returnPressed.connect(self.UART_send)
        self.pushButton_SpiRun.clicked.connect(self.SPI_run)
        self.SPI_process = QtCore.QProcess()
        self.SPI_process.readyRead.connect(self.SPI_dataReady)
        self.ft232h=0
        self.gpio_init=0
        try:
            self.FTDI_setup()
            self.GPIO_setup()
        except:
            print("[*] FTDI Board not detected " )
            self.checkBox_d0.clicked.connect(lambda: self.GPIO_handler(0))
                self.checkBox_d1.clicked.connect(lambda: self.GPIO_handler(1))
                self.checkBox_d2.clicked.connect(lambda: self.GPIO_handler(2))
                self.checkBox_d3.clicked.connect(lambda: self.GPIO_handler(3))
                self.checkBox_d4.clicked.connect(lambda: self.GPIO_handler(4))
                self.checkBox_d5.clicked.connect(lambda: self.GPIO_handler(5))
                self.checkBox_d6.clicked.connect(lambda: self.GPIO_handler(6))
                self.checkBox_d7.clicked.connect(lambda: self.GPIO_handler(7))
        self.InputMonitor=None
                self.pushButton_GpioStartInputMonitor.clicked.connect(self.GPIO_startmonitor)
        self.pushButton_I2cRun.clicked.connect(self.I2C_run)
        self.pushButton_JtagStartServer.clicked.connect(self.JTAG_startserver)
                self.JTAG_getcfg()
        self.pushButton_JtagConnect.clicked.connect(self.JTAG_telnetconnect)
        self.pushButton_JtagRunGdb.clicked.connect(self.JTAG_rungdb)
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def mpvNextEpnList(self):
        global mpvplayer,epn,curR,Player,epnArrList,site

        if mpvplayer.pid() > 0:
            print ("-----------inside-------")
            if curR == self.list2.count() - 1:
                curR = 0
                if site == "Music" and not self.playerPlaylist_setLoop_var:
                    r1 = self.list1.currentRow()
                    it1 = self.list1.item(r1)
                    if it1:
                        if r1 < self.list1.count():
                            r2 = r1+1
                        else:
                            r2 = 0
                        self.list1.setCurrentRow(r2)
                        self.listfound()
            else:
                curR = curR + 1

            self.list2.setCurrentRow(curR)
            if site != "PlayLists" and not self.queue_url_list:
                try:
                    if '    ' in epnArrList[curR]:
                        epn = epnArrList[curR].split('  ')[1]
                    else:
                        epn = self.list2.currentItem().text()
                    epn = epn.replace('#','')
                except:
                    pass

            if site == "Local" or site == "Music" or site == "Video" or site == "None" or site == "PlayLists":
                if len(self.queue_url_list)>0:
                    self.getQueueInList()
                else:
                    self.localGetInList()
            else:
                if Player == "mpv":
                    mpvplayer.kill()
                    del mpvplayer
                    mpvplayer = QtCore.QProcess()
                    self.getNextInList()
                else:
                    print(mpvplayer.state())
                    subprocess.call(['killall','mplayer'])
                    del mpvplayer
                    mpvplayer = QtCore.QProcess()
                    print (mpvplayer.pid(),'--mpvnext---')

                    self.getNextInList()
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def mpvPrevEpnList(self):
        #global mpvplayer,epn,curR
        global mpvplayer,epn,curR,Player,epnArrList,site

        if mpvplayer.pid() > 0:
            print ("inside")

            if curR == 0:
                curR = self.list2.count() - 1
                if site == "Music" and not self.playerPlaylist_setLoop_var:
                    r1 = self.list1.currentRow()
                    it1 = self.list1.item(r1)
                    if it1:
                        if r1 > 0:
                            r2 = r1-1
                        else:
                            r2 = self.list2.count()-1
                        self.list1.setCurrentRow(r2)
                        self.listfound()
                        curR = self.list2.count() - 1
            else:
                curR = curR - 1
            self.list2.setCurrentRow(curR)
            if site != "PlayLists" and not self.queue_url_list:
                try:
                    if '    ' in epnArrList[curR]:
                        epn = epnArrList[curR].split('  ')[1]
                    else:
                        epn = self.list2.currentItem().text()
                    epn = epn.replace('#','')
                except:
                    pass

            if site == "Local" or site == "Music" or site == "Video" or site == "None" or site == "PlayLists":
                if len(self.queue_url_list)>0:
                    pass
                else:
                    self.localGetInList()
            else:
                if Player == "mpv":
                    mpvplayer.kill()
                    del mpvplayer
                    mpvplayer = QtCore.QProcess()
                    self.getNextInList()
                else:
                    print(mpvplayer.state())
                    subprocess.call(['killall','mplayer'])
                    del mpvplayer
                    mpvplayer = QtCore.QProcess()
                    print (mpvplayer.pid(),'--mpvnext---')

                    self.getNextInList()