def run(self):
        auxDir = os.path.dirname(os.path.realpath(__file__)) + "/aux"
        os.chdir(auxDir)
        for writeup in self._writeups:
            self._logMessage("Processing: " + writeup.filename)
            writeup.texFile = writeup.filename.split('/')[-1]
            os.system('cp {0} {1}'.format(writeup.filename, "{0}/{1}".format(auxDir, writeup.texFile)))
            if self._pdf:
                self._logMessage("Creating PDF/A")
                writeup.generatePDF(html=True)
            # Get reduced html
            if self._html:
                self._logMessage("Creating HTML")
                writeup.generateHTML()

            writeup.texFile = "finalTEX/" + writeup.texFile
            os.system('mv aux.tex ../{0}'.format(writeup.texFile))

            #Copying files to public place
            os.system('scp -P 3121 ../{0} cernlib@cernlib-share:/home/cernlib/ShortWriteUps/PDF/.'.format(writeup.pdfFile))
            writeup.pdfFile = 'http://cernlib-share/code/ShortWriteUps/PDF/{0}'.format(writeup.pdfFile.split('/')[-1])
            os.system('scp -P 3121 ../{0} cernlib@cernlib-share:/home/cernlib/ShortWriteUps/HTML/.'.format(writeup.htmlFile))
            writeup.htmlFile = 'http://cernlib-share/code/ShortWriteUps/HTML/{0}'.format(writeup.htmlFile.split('/')[-1])
            os.system('scp -P 3121 ../{0} cernlib@cernlib-share:/home/cernlib/ShortWriteUps/HTML/.'.format(writeup.reducedHTMLFile))
            writeup.reducedHTMLFile = 'http://cernlib-share/code/ShortWriteUps/HTML/{0}'.format(writeup.reducedHTMLFile.split('/')[-1])

            # Cleaning files
            self._logMessage("Cleaning auxiliar files")
            os.system('rm {0}/*'.format(auxDir))
            # Saving in database
            if self._persist:
                DataManager.saveShortWriteUp(writeup)
        # Sending signal when finished
        self.emit(QtCore.SIGNAL('backProcessFinished()'))
Exemplo n.º 2
0
    def _processWriteUp(self):
        pdf = self.ui.PDFCheckBox.isChecked()
        html = self.ui.HTMLCheckBox.isChecked()
        persist = self.ui.persistCheckBox.isChecked()
        if self.ui.tabWidget.currentIndex() == 0:  # Short WriteUp
            if self.ui.tabWidget_2.currentIndex() == 0:  # Single File
                if self._writeup is None:
                    logger.info("No write up ready for processing")
                else:
                    self._writeup.process(pdf, html)
                    if self.ui.persistCheckBox.isChecked:
                        DataManager.saveShortWriteUp(self._writeup)
            else:  # Multiple File
                logger.info("Start processing " + str(len(self._writeups)) +
                            " writeups")
                #TODO: Compare what to do. If multiple workers or just one
                # Working in background

                self.bp = BackgroundProcessor(self._writeups, pdf, html,
                                              persist)
                self.connect(self.bp, QtCore.SIGNAL("backLogMessage(QString)"),
                             self._backProccessorMessage)
                self.connect(self.bp, QtCore.SIGNAL("backProcessFinished()"),
                             self._backProccessorFinished)
                self.bp.start()
                logger.info("Multiple files processing done")
        else:  # Long WriteUp
            ID = self.ui.idLongTb.text()
            # if ID == '':
            #     logger.info("Not ID given. All fields required")
            #     return
            title = self.ui.titleLongTb.text()
            # if title == '':
            #     logger.info("Not title given. All fields required")
            #     return
            author = self.ui.authorLongTb.text()
            # if author == '':
            #     logger.info("Not author given. All fields required")
            #     return
            version = self.ui.versionLongTb.text()
            # if version == '':
            #     logger.info("Not version given. All fields required")
            #     return
            copyright = self.ui.copyrightLongTb.text()
            # if copyright == '':
            #     logger.info("Not copyright given. All fields required")
            #     return
            texFile = self.ui.texFileLongTb.toPlainText()
            self._writeup = LongWriteUp(ID, title, version, author, copyright,
                                        texFile)
            inyectShortDoc = self.ui.inyectCheckBox.isChecked()
            self._writeup.process(pdf, html, inyectShortDoc)
            if persist:
                DataManager.saveLongWriteUp(self._writeup)
    def _processWriteUp(self):
        pdf = self.ui.PDFCheckBox.isChecked()
        html = self.ui.HTMLCheckBox.isChecked()
        persist = self.ui.persistCheckBox.isChecked()
        if self.ui.tabWidget.currentIndex() == 0: # Short WriteUp
            if self.ui.tabWidget_2.currentIndex() == 0: # Single File
                if self._writeup is None:
                    logger.info("No write up ready for processing")
                else:
                    self._writeup.process(pdf, html)
                    if self.ui.persistCheckBox.isChecked:
                        DataManager.saveShortWriteUp(self._writeup)
            else: # Multiple File
                logger.info("Start processing " + str(len(self._writeups)) + " writeups")
                #TODO: Compare what to do. If multiple workers or just one
                # Working in background

                self.bp = BackgroundProcessor(self._writeups, pdf, html, persist)
                self.connect(self.bp, QtCore.SIGNAL("backLogMessage(QString)"), self._backProccessorMessage)
                self.connect(self.bp, QtCore.SIGNAL("backProcessFinished()"), self._backProccessorFinished)
                self.bp.start()
                logger.info("Multiple files processing done")
        else: # Long WriteUp
            ID = self.ui.idLongTb.text()
            # if ID == '':
            #     logger.info("Not ID given. All fields required")
            #     return
            title = self.ui.titleLongTb.text()
            # if title == '':
            #     logger.info("Not title given. All fields required")
            #     return
            author = self.ui.authorLongTb.text()
            # if author == '':
            #     logger.info("Not author given. All fields required")
            #     return
            version = self.ui.versionLongTb.text()
            # if version == '':
            #     logger.info("Not version given. All fields required")
            #     return
            copyright = self.ui.copyrightLongTb.text()
            # if copyright == '':
            #     logger.info("Not copyright given. All fields required")
            #     return
            texFile = self.ui.texFileLongTb.toPlainText()
            self._writeup = LongWriteUp(ID, title, version, author, copyright, texFile)
            inyectShortDoc = self.ui.inyectCheckBox.isChecked()
            self._writeup.process(pdf, html, inyectShortDoc)
            if persist:
                DataManager.saveLongWriteUp(self._writeup)
Exemplo n.º 4
0
    def run(self):
        auxDir = os.path.dirname(os.path.realpath(__file__)) + "/aux"
        os.chdir(auxDir)
        for writeup in self._writeups:
            self._logMessage("Processing: " + writeup.filename)
            writeup.texFile = writeup.filename.split('/')[-1]
            os.system('cp {0} {1}'.format(
                writeup.filename, "{0}/{1}".format(auxDir, writeup.texFile)))
            if self._pdf:
                self._logMessage("Creating PDF/A")
                writeup.generatePDF(html=True)
            # Get reduced html
            if self._html:
                self._logMessage("Creating HTML")
                writeup.generateHTML()

            writeup.texFile = "finalTEX/" + writeup.texFile
            os.system('mv aux.tex ../{0}'.format(writeup.texFile))

            #Copying files to public place
            os.system(
                'scp -P 3121 ../{0} cernlib@cernlib-share:/home/cernlib/ShortWriteUps/PDF/.'
                .format(writeup.pdfFile))
            writeup.pdfFile = 'http://cernlib-share/code/ShortWriteUps/PDF/{0}'.format(
                writeup.pdfFile.split('/')[-1])
            os.system(
                'scp -P 3121 ../{0} cernlib@cernlib-share:/home/cernlib/ShortWriteUps/HTML/.'
                .format(writeup.htmlFile))
            writeup.htmlFile = 'http://cernlib-share/code/ShortWriteUps/HTML/{0}'.format(
                writeup.htmlFile.split('/')[-1])
            os.system(
                'scp -P 3121 ../{0} cernlib@cernlib-share:/home/cernlib/ShortWriteUps/HTML/.'
                .format(writeup.reducedHTMLFile))
            writeup.reducedHTMLFile = 'http://cernlib-share/code/ShortWriteUps/HTML/{0}'.format(
                writeup.reducedHTMLFile.split('/')[-1])

            # Cleaning files
            self._logMessage("Cleaning auxiliar files")
            os.system('rm {0}/*'.format(auxDir))
            # Saving in database
            if self._persist:
                DataManager.saveShortWriteUp(writeup)
        # Sending signal when finished
        self.emit(QtCore.SIGNAL('backProcessFinished()'))