Esempio n. 1
0
    def __init__(self, output_directory):
        super(Converter, self).__init__()
        assert output_directory is not None
        self.output_directory = output_directory
        self.latex_source = ""
        self._latex_process = None
        self._convert_process = None
        self.logs_parser = LogsParser()
        self._stopping_conversion = False

        self.unique_random_file_name = unicode(uuid4())
        self.base_file_path = os.path.join(self.output_directory,
                                           self.unique_random_file_name)
        self.source_file_path = "%s.tex" % self.base_file_path
        self.pdf_file_path = "%s.pdf" % self.base_file_path
        self.png_file_path = "%s.png" % self.base_file_path

        self._initProcesses()
Esempio n. 2
0
	def __init__(self, output_directory):
		super(Converter, self).__init__()
		assert output_directory is not None
		self.output_directory = output_directory
		self.latex_source = ""
		self._latex_process = None
		self._convert_process = None
		self.logs_parser = LogsParser()
		self._stopping_conversion = False

		self.unique_random_file_name = unicode(uuid4())
		self.base_file_path = os.path.join(self.output_directory, self.unique_random_file_name)
		self.source_file_path = "%s.tex" % self.base_file_path
		self.pdf_file_path = "%s.pdf" % self.base_file_path
		self.png_file_path = "%s.png" % self.base_file_path

		self._initProcesses()
Esempio n. 3
0
class Converter(QObject):
    """
	Converts LaTeX source to image file
	"""

    convertedSignal = pyqtSignal(LatexToImageConversion)
    conversionAbortedSignal = pyqtSignal()

    def __init__(self, output_directory):
        super(Converter, self).__init__()
        assert output_directory is not None
        self.output_directory = output_directory
        self.latex_source = ""
        self._latex_process = None
        self._convert_process = None
        self.logs_parser = LogsParser()
        self._stopping_conversion = False

        self.unique_random_file_name = unicode(uuid4())
        self.base_file_path = os.path.join(self.output_directory,
                                           self.unique_random_file_name)
        self.source_file_path = "%s.tex" % self.base_file_path
        self.pdf_file_path = "%s.pdf" % self.base_file_path
        self.png_file_path = "%s.png" % self.base_file_path

        self._initProcesses()

    def _initProcesses(self):
        self._latex_process = QProcess()
        self._latex_process.setWorkingDirectory(self.output_directory)
        self._latex_process.finished.connect(self._latexTypesettingFinished)
        self._latex_process.error.connect(self._latexTypesettingError)
        self._convert_process = QProcess()
        self._convert_process.setWorkingDirectory(self.output_directory)
        self._convert_process.error.connect(self._pdfToImageConversionError)
        self._convert_process.finished.connect(
            self._pdfToImageConversionFinished)

    def stopConversion(self):
        self._stopping_conversion = True
        self._killProcesses()
        self._stopping_conversion = False

    def isStoppingConversion(self):
        return self._stopping_conversion

    def _killProcesses(self):
        self._latex_process.kill()
        self._latex_process.waitForFinished()
        self._convert_process.kill()
        self._convert_process.waitForFinished()

    def convertLatexToImage(self, source):
        self.stopConversion()
        try:
            self.logs_parser.clearLogsAndErrors()
            self.latex_source = source
            self._writeSourceCodeToFile()
            self._startConversion()
        except Exception, e:
            self.logs_parser.addErrorMessage(unicode(e))
            self._parseErrorsFromLogs()
            self._emitConversionSignalWithImagePath(None)
            self.conversionAbortedSignal.emit()
Esempio n. 4
0
class Converter(QObject):
	"""
	Converts LaTeX source to image file
	"""

	convertedSignal = pyqtSignal(LatexToImageConversion)
	conversionAbortedSignal = pyqtSignal()

	def __init__(self, output_directory):
		super(Converter, self).__init__()
		assert output_directory is not None
		self.output_directory = output_directory
		self.latex_source = ""
		self._latex_process = None
		self._convert_process = None
		self.logs_parser = LogsParser()
		self._stopping_conversion = False

		self.unique_random_file_name = unicode(uuid4())
		self.base_file_path = os.path.join(self.output_directory, self.unique_random_file_name)
		self.source_file_path = "%s.tex" % self.base_file_path
		self.pdf_file_path = "%s.pdf" % self.base_file_path
		self.png_file_path = "%s.png" % self.base_file_path

		self._initProcesses()

	def _initProcesses(self):
		self._latex_process = QProcess()
		self._latex_process.setWorkingDirectory(self.output_directory)
		self._latex_process.finished.connect(self._latexTypesettingFinished)
		self._latex_process.error.connect(self._latexTypesettingError)
		self._convert_process = QProcess()
		self._convert_process.setWorkingDirectory(self.output_directory)
		self._convert_process.error.connect(self._pdfToImageConversionError)
		self._convert_process.finished.connect(self._pdfToImageConversionFinished)

	def stopConversion(self):
		self._stopping_conversion = True
		self._killProcesses()
		self._stopping_conversion = False

	def isStoppingConversion(self):
		return self._stopping_conversion

	def _killProcesses(self):
		self._latex_process.kill()
		self._latex_process.waitForFinished()
		self._convert_process.kill()
		self._convert_process.waitForFinished()

	def convertLatexToImage(self, source):
		self.stopConversion()
		try:
			self.logs_parser.clearLogsAndErrors()
			self.latex_source = source
			self._writeSourceCodeToFile()
			self._startConversion()
		except Exception, e:
			self.logs_parser.addErrorMessage(unicode(e))
			self._parseErrorsFromLogs()
			self._emitConversionSignalWithImagePath(None)
			self.conversionAbortedSignal.emit()