コード例 #1
0
ファイル: XAnoS.py プロジェクト: prjemian/XAnoS
 def launch_ASAXSWidget(self):
     if not self.ASAXS_Widget_running:
         QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
         self.ASAXS_Widget = QProcess()
         self.ASAXS_Widget.start('python ./XAnoS_Components.py')
         self.ASAXS_Widget_running = True
         self.Start_ASAXS_Reducer_PushButton.setText('Running')
         self.ASAXS_Widget.finished.connect(self.stop_ASAXSWidget)
         QApplication.restoreOverrideCursor()
コード例 #2
0
ファイル: XAnoS.py プロジェクト: prjemian/XAnoS
 def launch_FitWidget(self):
     if not self.Fit_Widget_running:
         QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
         self.Fit_Widget = QProcess()
         self.Fit_Widget.start('python ./XAnoS_Fit.py')
         self.Fit_Widget_running = True
         self.Start_Data_Fitting_PushButton.setText('Running')
         self.Fit_Widget.finished.connect(self.stop_FitWidget)
         QApplication.restoreOverrideCursor()
コード例 #3
0
ファイル: XAnoS.py プロジェクト: prjemian/XAnoS
 def launch_Data_Reduction_Client(self):
     if not self.Data_Reduction_Client_running:
         QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
         self.Data_Reduction_Client = QProcess()
         self.Data_Reduction_Client.start('python ./XAnoS_Reducer.py')
         self.Data_Reduction_Client_running = True
         self.Start_Data_Reduction_Client_PushButton.setText('Running')
         self.Data_Reduction_Client.finished.connect(
             self.stop_Data_Reduction_Client)
         QApplication.restoreOverrideCursor()
コード例 #4
0
ファイル: XAnoS.py プロジェクト: prjemian/XAnoS
 def launch_Data_Collector_Server(self):
     if not self.Data_Collector_Server_running:
         QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
         self.Data_Collector_Server = QProcess()
         self.Data_Collector_Server.start('python ./XAnoS_Collector.py')
         self.Data_Collector_Server_running = True
         self.Start_Data_Collector_Server_PushButton.setText('Running')
         self.Data_Collector_Server.finished.connect(
             self.stop_Data_Collector_Server)
         QApplication.restoreOverrideCursor()
コード例 #5
0
ファイル: XAnoS.py プロジェクト: prjemian/XAnoS
 def launch_ASAXS_Batch_Processor_1(self):
     if not self.ASAXS_Batch_Processor_1_running:
         QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
         self.ASAXS_Batch_Processor_1 = QProcess()
         self.ASAXS_Batch_Processor_1.start(
             'python ./XAnoS_Batch_Processor_1.py')
         self.ASAXS_Batch_Processor_1_running = True
         self.Start_ASAXS_Batch_Processor_1_PushButton.setText('Running')
         self.ASAXS_Batch_Processor_1.finished.connect(
             self.stop_ASAXS_Batch_Processor_1)
         QApplication.restoreOverrideCursor()
コード例 #6
0
ファイル: Compress.py プロジェクト: ZhongHuaRong/Downloader
    def __init__(self,parent = None):
        super(Compress,self).__init__(parent)
        self.createList()
        
        self._process = QProcess(self)
        self._thread = QThread()
        self.moveToThread(self._thread)
        self._thread.start()

        self._fileName = ""
        self._outPath = ""

        self.startRunning.connect(self.startCompress)
        self._process.readyReadStandardOutput.connect(self.readMsg)
        self._process.readyReadStandardError.connect(self.readError)
        self._process.finished.connect(self.finished)
コード例 #7
0
    def prince_convert(self):
        '''
        Call the actual Prince command to convert to PDF
        '''
        from os import makedirs
        from os.path import dirname, join, exists
        from calibre.ptempfile import PersistentTemporaryFile
        from calibre.constants import DEBUG

        # All files are relative to the OPF location
        opf_dir = dirname(self.opf)
        base_dir = dirname(self.pdf_file)
        base_dir = join(opf_dir, base_dir)
        try:
            makedirs(base_dir)
        except BaseException:
            if not exists(base_dir): raise

        # Create a temporary CSS file with the box contents
        custom_CSS = PersistentTemporaryFile()
        custom_CSS.write(unicode(self.css1.toPlainText()))
        custom_CSS.close()
        # Create a temporary file with the list of input files
        file_list = PersistentTemporaryFile()
        for item in self.oeb.spine:
            file_list.write(item.href + "\n")
        file_list.close()
        # Build the command line
        command = prefs['prince_exe']
        args = ['-v']
        if self.prince_file:
            args.append('-s')
            args.append(self.prince_file)
        args.append('-s')
        args.append(custom_CSS.name)
        args.append('-l')
        args.append(file_list.name)
        args.append('-o')
        args.append(self.pdf_file)

        # Hide the convert button and show a busy indicator
        self.convert.setEnabled(False)
        self.progress_bar = QProgressBar()
        self.progress_bar.setRange(0,0)
        self.progress_bar.setValue(0)
        self.l.addWidget(self.progress_bar)

        # Run the command and return the path to the PDF file
        if DEBUG: print(_('Converting book...'))
        process = QProcess(self)
        process.setWorkingDirectory(opf_dir)
        process.setProcessChannelMode(QProcess.MergedChannels);
        process.error.connect(self.error)
        process.finished.connect(self.end)
        self.process = process
        process.start(command, args)
コード例 #8
0
 def startPrivateBrowsing(self, startUrl=QUrl()):
     url = startUrl
     act = self.sender()
     if isinstance(act, QAction):
         url = QUrl(act.data())
     args = [const.MAIN_PATH]
     args.append('--private-browsing')
     args.append('--profile=%s' % ProfileManager.currentProfile())
     if not url.isEmpty():
         args.append(url.toEncoded().data().decode())
     if not QProcess.startDetached(self.applicationFilePath(), args):
         print(
             'MainApplication: Cannot start new browser process for private browsing!'
             ' %s %s' % (self.applicationFilePath(), args),
             file=stderr)
コード例 #9
0
ファイル: AppTools.py プロジェクト: zy-sunshine/falkon-pyqt5
    def startExternalProcess(self, executable, args):
        '''
        @param: executable QString
        @param: args QString
        @return: bool
        '''
        arguments = self.splitCommandArguments(args)

        success = QProcess.startDetached(executable, arguments)

        if not success:
            info = '<ul><li><b>%s</b>%s</li><li><b>%s</b>%s</li></ul>' % \
                (_('Executable: '), executable, _('Arguments:'), ' '.join(arguments))
            QMessageBox.critical(None, _('Cannot start external program'),
                    _('Cannot start external program! %s') % info)

        return success
コード例 #10
0
ファイル: XAnoS.py プロジェクト: prjemian/XAnoS
class XAnoS(QMainWindow):
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent=parent)
        loadUi('UI_Forms/XAnoS.ui', self)
        self.init_UI()
        self.init_signals()

    def init_UI(self):
        self.ASAXS_Widget_running = False
        self.Fit_Widget_running = False
        self.ASAXS_Batch_Processor_1_running = False
        self.ASAXS_Batch_Processor_2_running = False
        self.Data_Reduction_Client_running = False
        self.Data_Collector_Server_running = False

    def init_signals(self):
        self.Start_Data_Collector_Server_PushButton.clicked.connect(
            self.launch_Data_Collector_Server)
        self.Stop_Data_Collector_Server_PushButton.clicked.connect(
            self.stop_Data_Collector_Server)
        self.Start_Data_Reduction_Client_PushButton.clicked.connect(
            self.launch_Data_Reduction_Client)
        self.Stop_Data_Reduction_Client_PushButton.clicked.connect(
            self.stop_Data_Reduction_Client)
        self.Start_ASAXS_Batch_Processor_1_PushButton.clicked.connect(
            self.launch_ASAXS_Batch_Processor_1)
        self.Stop_ASAXS_Batch_Processor_1_PushButton.clicked.connect(
            self.stop_ASAXS_Batch_Processor_1)
        self.Start_ASAXS_Batch_Processor_2_PushButton.clicked.connect(
            self.launch_ASAXS_Batch_Processor_2)
        self.Stop_ASAXS_Batch_Processor_2_PushButton.clicked.connect(
            self.stop_ASAXS_Batch_Processor_2)
        self.Start_ASAXS_Reducer_PushButton.clicked.connect(
            self.launch_ASAXSWidget)
        self.Stop_ASAXS_Reducer_PushButton.clicked.connect(
            self.stop_ASAXSWidget)
        self.Start_Data_Fitting_PushButton.clicked.connect(
            self.launch_FitWidget)
        self.Stop_Data_Fitting_PushButton.clicked.connect(self.stop_FitWidget)

    def launch_Data_Collector_Server(self):
        if not self.Data_Collector_Server_running:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            self.Data_Collector_Server = QProcess()
            self.Data_Collector_Server.start('python ./XAnoS_Collector.py')
            self.Data_Collector_Server_running = True
            self.Start_Data_Collector_Server_PushButton.setText('Running')
            self.Data_Collector_Server.finished.connect(
                self.stop_Data_Collector_Server)
            QApplication.restoreOverrideCursor()

    def stop_Data_Collector_Server(self):
        if self.Data_Collector_Server_running:
            self.Data_Collector_Server.close()
        self.Data_Collector_Server_running = False
        self.Start_Data_Collector_Server_PushButton.setText('Start')

    def launch_Data_Reduction_Client(self):
        if not self.Data_Reduction_Client_running:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            self.Data_Reduction_Client = QProcess()
            self.Data_Reduction_Client.start('python ./XAnoS_Reducer.py')
            self.Data_Reduction_Client_running = True
            self.Start_Data_Reduction_Client_PushButton.setText('Running')
            self.Data_Reduction_Client.finished.connect(
                self.stop_Data_Reduction_Client)
            QApplication.restoreOverrideCursor()

    def stop_Data_Reduction_Client(self):
        if self.Data_Reduction_Client_running:
            self.Data_Reduction_Client.close()
        self.Data_Reduction_Client_running = False
        self.Start_Data_Reduction_Client_PushButton.setText('Start')

    def launch_ASAXS_Batch_Processor_1(self):
        if not self.ASAXS_Batch_Processor_1_running:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            self.ASAXS_Batch_Processor_1 = QProcess()
            self.ASAXS_Batch_Processor_1.start(
                'python ./XAnoS_Batch_Processor_1.py')
            self.ASAXS_Batch_Processor_1_running = True
            self.Start_ASAXS_Batch_Processor_1_PushButton.setText('Running')
            self.ASAXS_Batch_Processor_1.finished.connect(
                self.stop_ASAXS_Batch_Processor_1)
            QApplication.restoreOverrideCursor()

    def stop_ASAXS_Batch_Processor_1(self):
        if self.ASAXS_Batch_Processor_1_running:
            self.ASAXS_Batch_Processor_1.close()
        self.ASAXS_Batch_Processor_1_running = False
        self.Start_ASAXS_Batch_Processor_1_PushButton.setText('Start')

    def launch_ASAXS_Batch_Processor_2(self):
        if not self.ASAXS_Batch_Processor_2_running:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            self.ASAXS_Batch_Processor_2 = QProcess()
            self.ASAXS_Batch_Processor_2.start(
                'python ./XAnoS_Batch_Processor_2.py')
            self.ASAXS_Batch_Processor_2_running = True
            self.Start_ASAXS_Batch_Processor_2_PushButton.setText('Running')
            self.ASAXS_Batch_Processor_2.finished.connect(
                self.stop_ASAXS_Batch_Processor_2)
            QApplication.restoreOverrideCursor()

    def stop_ASAXS_Batch_Processor_2(self):
        if self.ASAXS_Batch_Processor_2_running:
            self.ASAXS_Batch_Processor_2.close()
        self.ASAXS_Batch_Processor_2_running = False
        self.Start_ASAXS_Batch_Processor_2_PushButton.setText('Start')

    def launch_ASAXSWidget(self):
        if not self.ASAXS_Widget_running:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            self.ASAXS_Widget = QProcess()
            self.ASAXS_Widget.start('python ./XAnoS_Components.py')
            self.ASAXS_Widget_running = True
            self.Start_ASAXS_Reducer_PushButton.setText('Running')
            self.ASAXS_Widget.finished.connect(self.stop_ASAXSWidget)
            QApplication.restoreOverrideCursor()

    def stop_ASAXSWidget(self):
        if self.ASAXS_Widget_running:
            self.ASAXS_Widget.close()
        self.ASAXS_Widget_running = False
        self.Start_ASAXS_Reducer_PushButton.setText('Start')

    def launch_FitWidget(self):
        if not self.Fit_Widget_running:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            self.Fit_Widget = QProcess()
            self.Fit_Widget.start('python ./XAnoS_Fit.py')
            self.Fit_Widget_running = True
            self.Start_Data_Fitting_PushButton.setText('Running')
            self.Fit_Widget.finished.connect(self.stop_FitWidget)
            QApplication.restoreOverrideCursor()

    def stop_FitWidget(self):
        if self.Fit_Widget_running:
            self.Fit_Widget.close()
        self.Fit_Widget_running = False
        self.Start_Data_Fitting_PushButton.setText('Start')
コード例 #11
0
 def open_directory(self):
     abs_path = os.getcwd()
     our_path = os.path.join(abs_path, 'Выгрузка')
     process = QProcess(MainWindow)
     process.start(f"explorer.exe {our_path}")
     MainWindow.close()
コード例 #12
0
ファイル: convert.py プロジェクト: Jellby/PrincePDF
    def prince_convert(self):
        '''
        Call the actual Prince command to convert to PDF
        '''
        from os import makedirs
        from os.path import dirname, join, exists
        from calibre.ptempfile import PersistentTemporaryFile
        from calibre.constants import DEBUG
        from shlex import split as shsplit

        # All files are relative to the OPF location
        opf_dir = dirname(self.opf)
        base_dir = dirname(self.pdf_file)
        base_dir = join(opf_dir, base_dir)
        try:
            makedirs(base_dir)
        except BaseException:
            if not exists(base_dir): raise

        # Create a temporary CSS file with the box contents
        custom_CSS = PersistentTemporaryFile(mode='w+')
        custom_CSS.write(unicode(self.css1.toPlainText()))
        custom_CSS.close()
        # Create a temporary file with the list of input files
        file_list = PersistentTemporaryFile(mode='w+')
        for item in self.oeb.spine:
            file_list.write(item.href + "\n")
        file_list.close()
        # Build the command line
        command = prefs['prince_exe']
        args = ['-v']
        if self.prince_file:
            args.append('-s')
            args.append(self.prince_file)
        args.append('-s')
        args.append(custom_CSS.name)
        args.append('-l')
        args.append(file_list.name)
        args.append('-o')
        args.append(self.pdf_file)
        # Additional command-line arguments
        args.extend(shsplit(self.args.text()))

        # Hide the convert button and show a busy indicator
        self.convert.setEnabled(False)
        self.progress_bar = QProgressBar()
        self.progress_bar.setRange(0, 0)
        self.progress_bar.setValue(0)
        self.l.addWidget(self.progress_bar)

        # Run the command and return the path to the PDF file
        if DEBUG: print(_('Converting book...'))
        process = QProcess(self)
        process.setWorkingDirectory(opf_dir)
        process.setProcessChannelMode(QProcess.MergedChannels)
        process.error.connect(self.error)
        process.finished.connect(self.end)
        self.process = process
        if DEBUG:
            from subprocess import list2cmdline
            line = list2cmdline([command] + args)
            print(_('Command line: %s') % line)
        process.start(command, args)
コード例 #13
0
ファイル: Compress.py プロジェクト: ZhongHuaRong/Downloader
class Compress(QObject):
    startRunning = pyqtSignal(str,str,str)

    def __init__(self,parent = None):
        super(Compress,self).__init__(parent)
        self.createList()
        
        self._process = QProcess(self)
        self._thread = QThread()
        self.moveToThread(self._thread)
        self._thread.start()

        self._fileName = ""
        self._outPath = ""

        self.startRunning.connect(self.startCompress)
        self._process.readyReadStandardOutput.connect(self.readMsg)
        self._process.readyReadStandardError.connect(self.readError)
        self._process.finished.connect(self.finished)
            
    def __del__(self):
        if self._thread.isRunning:
            self._thread.exit()
            self._thread.wait()
        if self._process.isOpen():
            self._process.close()
            self._process.waitForFinished()
        del self._thread
        del self._process
        self.deleteLater()

    #生成压缩包类型list
    def createList(self):
        self._typeList = []
        self._typeList.append("rar")
        self._typeList.append("7z")
        self._typeList.append("zip")
        self._typeList.append("tgz")

        self._pwList = []
        self._pwIndex = 0

    #生成密码列表
    def createPWList(self,pw):
        self._pwList = pw.split(";")
        self._pwIndex = 0
        print("密码集",self._pwList)

    #文件是否存在
    def isFileExist(self,path,filename):
        dir = QDir(path)
        return filename in dir.entryList()

    #文件是否是压缩包
    def isCompress(self,name):
        _list = name.split('.')
        if len(_list) < 2:
            return False
        _type = _list[-1].lower()
        return _type in self._typeList

    @pyqtSlot(str,str,str)
    #槽里面开始运行7z,因为是多线程
    def startCompress(self,filename,outputPath,password):
        cur = QDir.current()
        if not self.isFileExist(cur.path(),"7z.exe"):
            cur.cdUp()
        currPath = cur.path() + "\\7z.exe"
        if not len(outputPath):
            outputPath = "./"
        args = list( [ "x" , "-y" ] )
        args.append("-o" + outputPath)
        #密码判断
        if len(password) != 0:
            args.append("-p" + password)
            self._pwIndex += 1
            print("使用密码'" + password + "'解压")
        args.append(filename)
        self._process.start(currPath,args)
        print(self._process.arguments())
    
    @pyqtSlot(str,str,str)
    #外部接口
    def compressFile(self,filename,outputPath,pwList):
        self.createPWList(pwList)
        self._fileName = filename
        self._outPath = outputPath
        if self.isCompress(filename):
            #第一次解压默认不加密码
            self.startRunning.emit(self._fileName,self._outPath,"")

    @pyqtSlot()
    def readMsg(self):
        s = str(self._process.readAllStandardOutput())
        logging.info("readMsg:" + s)
        print("readMsg:" + s)
        if "Enter password" in s:
            self._process.kill()

    @pyqtSlot()
    def readError(self):
        s = str(self._process.readAllStandardError())
        logging.info("readError:" + s)
        print("readError:" + s)
    
    @pyqtSlot(int,"QProcess::ExitStatus")
    def finished(self,code,status):
        print("解压结束,exitCode:" + str(code))
        logging.info("解压结束,exitCode:" + str(code))

        #解压失败,尝试使用密码遍历解压
        if code != 0:
            if len(self._pwList) != 0 and len(self._pwList) > self._pwIndex:
                self.startRunning.emit(self._fileName,self._outPath,self._pwList[self._pwIndex])