Python PyQt5.QtCore.QProcess() Examples

The following are 18 code examples of PyQt5.QtCore.QProcess(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore , or try the search function .
Example #1
Source File: ssh_add.py    From restatic with GNU General Public License v3.0 6 votes vote down vote up
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", ""]
            ) 
Example #2
Source File: optionwidgets.py    From kawaii-player with GNU General Public License v3.0 6 votes vote down vote up
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)) 
Example #3
Source File: __main__.py    From pip-gui with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #4
Source File: terminal.py    From pychemqt with GNU General Public License v3.0 6 votes vote down vote up
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") 
Example #5
Source File: ssh_dialog.py    From vorta with GNU General Public License v3.0 6 votes vote down vote up
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', '']) 
Example #6
Source File: main.py    From Hydra with GNU General Public License v3.0 6 votes vote down vote up
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)) 
Example #7
Source File: updatescontroller.py    From Artemis with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #8
Source File: stubs.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #9
Source File: updater.py    From Artemis with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #10
Source File: start.py    From Python-Application with GNU General Public License v3.0 5 votes vote down vote up
def open(self):
        fname = self.get_file()
        # 文件名非空
        if fname:
            process = QProcess()
            process.startDetached('python', [fname])
            #subprocess.run(['python', fname], shell=True)
            #qApp.quit()
            
    # 重写关闭事件 
Example #11
Source File: mybutton.py    From Python-Application with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        # 执行程序
        if self.state:
            process = QProcess()
            process.startDetached('python', [self.fname]) 
Example #12
Source File: main.py    From xqemu-manager with GNU General Public License v2.0 5 votes vote down vote up
def isRunning(self):
		return self._p is not None and self._p.state() == QtCore.QProcess.Running 
Example #13
Source File: main.py    From xqemu-manager with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
		self._p = QtCore.QProcess()
		self._qmp = None 
Example #14
Source File: ApplyDialog.py    From Resetter with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #15
Source File: CustomApplyDialog.py    From Resetter with GNU General Public License v3.0 5 votes vote down vote up
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']) 
Example #16
Source File: basic_operation.py    From Pythonic with GNU General Public License v3.0 4 votes vote down vote up
def openCustomEditor(self, cmd, code_input):
        logging.debug('ExecOp::openCustomEditor() called')
        filename = '{}_{}_{}.py'.format(self.row, alphabet[self.column], int(random.random() * 1e7))
        filename = os.path.join(tempfile.gettempdir(), filename)
        logging.debug('ExecOp::openCustomEditor() filename: {}'.format(filename))


        
        if cmd:
            try:
                # create new file
                with open(filename, 'w') as f:
                    if code_input:
                        f.write(code_input)
            except Exception as e:
                # not writeable?
                return e

            cmd = cmd.replace('$FILENAME', filename)
        else:
            logging.debug('ExecOp::openCustomEditor() no command specified - returning')
            return

        logging.debug('ExecOp::openCustomEditor() cmd: {}'.format(cmd))
        logging.debug('ExecOp::openCustomEditor() subprocess called')
        edit_proc = QProcess()
        edit_proc.start(cmd)
        edit_proc.waitForFinished(-1)

        logging.debug('ExecOp::openCustomEditor() subprocess ended')

        try:
            # create new file
            with open(filename, 'r') as f:
                code_input = f.read()
        except Exception as e:
            # not writeable?
            return e

        self.code_input.setPlainText(code_input)
        logging.debug('ExecOp::openCustomEditor() removing temporary file')
        os.remove(filename) 
Example #17
Source File: optionwidgets.py    From kawaii-player with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, parent, uiwidget, home_dir, mw):
        super(MySlider, self).__init__(parent)
        global home, ui, MainWindow
        ui = uiwidget
        home = home_dir
        MainWindow = mw
        self.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        version = QtCore.QT_VERSION_STR
        self.version = tuple([int(i) for i in version.split('.')])
        if self.version >= (5, 9, 0):
            self.tooltip = MyToolTip(ui)
        else:
            self.tooltip = None
        self.parent = parent
        self.preview_process = QtCore.QProcess()
        self.counter = 0
        self.preview_pending = []
        self.lock = False
        self.preview_counter = 0
        self.mousemove = False
        #self.tooltip_widget = ToolTipWidget(ui, parent)
        self.tooltip_widget = QtWidgets.QWidget(MainWindow)
        self.v = QtWidgets.QVBoxLayout(self.tooltip_widget)
        self.v.setContentsMargins(0, 0, 0, 0)
        self.pic = QLabelPreview(self)
        self.pic.set_globals(ui)
        self.pic.setScaledContents(True)
        self.v.insertWidget(0, self.pic)
        self.txt = QtWidgets.QLabel(self)
        self.v.insertWidget(1, self.txt)
        self.txt.setAlignment(QtCore.Qt.AlignCenter)
        self.tooltip_widget.setMouseTracking(True)
        self.tooltip_widget.hide()
        self.txt.setStyleSheet('color:white;background:black;')
        self.tooltip_timer = QtCore.QTimer()
        self.tooltip_timer.timeout.connect(self.update_tooltip)
        self.tooltip_timer.setSingleShot(True)
        self.final_url = None
        self.half_size = int(ui.label.maximumWidth()/2)
        self.upper_limit = self.parent.x() + self.parent.width()
        self.lower_limit = self.parent.x()
        self.file_type = 'video'
        self.enter = False
        self.empty_preview_dir = False
        self.check_dimension_again = False
        self.preview_dir = None
        self.time_format = lambda val: time.strftime('%H:%M:%S', time.gmtime(int(val)))
        self.preview_lock = Lock()
        #self.setTickPosition(QtWidgets.QSlider.TickPosition.TicksAbove)
        #self.setTickInterval(100)
        self.valueChanged.connect(self.set_value)
        locale.setlocale(locale.LC_NUMERIC, 'C')
        self.mpv = MPV(vo="image", ytdl="no", quiet=True, aid="no", sid="no", frames=1, idle=True)
        self.preview_thread_list = []
        self.final_point = (0, 0)
        self.ui = ui 
Example #18
Source File: browser.py    From kawaii-player with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, ui, home, screen_width, quality, site, epnArrList):
        super(Browser, self).__init__()
        self.epn_name_in_list = ''
        self.wait_player = False
        self.home = home
        self.ui = ui
        self.quality = quality
        self.site = site
        self.epnArrList = epnArrList
        self.pg = MyPage()
        self.setPage(self.pg)
        yt_url = False
        try:
            row = ui.list2.currentRow()
            url_name = self.epnArrList[row].split('	')[1]
            if 'youtube.com' in url_name or self.ui.review_site_code == 'yt':
                yt_url = True
        except Exception as err:
            self.ui.logger.error(err)
        if self.ui.btnWebReviews.currentText().lower() == 'youtube' or yt_url:
            self.hdr = 'Mozilla/5.0 (Linux; Android 4.4.4; SM-G928X Build/LMY47X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36'
        else:
            self.hdr = 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:61.0) Gecko/20100101 Firefox/61.0'
        self.page().profile().setHttpUserAgent(self.hdr)
        p = NetManager(parent=self.pg, default_block=True)
        self.page().profile().setRequestInterceptor(p)
        cache_path = os.path.join(self.ui.tmp_download_folder, 'CacheBrowser')
        if not os.path.exists(cache_path):
            os.makedirs(cache_path)
        self.page().profile().setCachePath(cache_path)
        self.page().profile().setPersistentStoragePath(cache_path)
        self.page().linkHovered.connect(self.custom_links)
        self.urlChanged.connect(self.url_changed)
        self.hoveredLink = ''
        self.media_url = ''
        self.titleChanged.connect(self.title_changed)
        self.loadProgress.connect(self.load_progress)
        self.current_link = ''
        self.title_page = ''
        self.ui.tab_2.setMaximumWidth(screen_width)
        self.url_arr = []
        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.player_wait)
        self.timer.setSingleShot(True)
        self.urlSignal.connect(self.final_found)
        self.gotHtmlSignal.connect(self.got_curl_html)
        self.playlist_obtained_signal.connect(self.got_playlist_html)
        self.playlist_dict = {}
        self.get_playlist = False
        self.playlist_name = ''
        self.sub_url = ''
        self.yt_sub_folder = os.path.join(home, 'External-Subtitle')
        if not os.path.exists(self.yt_sub_folder):
            os.makedirs(self.yt_sub_folder)
        self.yt_process = QtCore.QProcess()
        self.yt_process.started.connect(self.yt_process_started)
        self.yt_process.finished.connect(self.yt_process_finished)