16 import shutil |
16 import shutil |
17 import errno |
17 import errno |
18 import fnmatch |
18 import fnmatch |
19 import os.path |
19 import os.path |
20 |
20 |
21 from PyQt4.QtCore import pyqtSlot, QProcess, QTimer, QThread, pyqtSignal |
21 from PyQt5.QtCore import pyqtSlot, QProcess, QTimer, QThread, pyqtSignal |
22 from PyQt4.QtGui import QDialog, QDialogButtonBox, QAbstractButton |
22 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton |
23 |
23 |
24 from E5Gui import E5MessageBox |
24 from E5Gui import E5MessageBox |
25 |
25 |
26 from .Ui_CxfreezeExecDialog import Ui_CxfreezeExecDialog |
26 from .Ui_CxfreezeExecDialog import Ui_CxfreezeExecDialog |
27 |
27 |
84 |
84 |
85 self.process.readyReadStandardOutput.connect(self.__readStdout) |
85 self.process.readyReadStandardOutput.connect(self.__readStdout) |
86 self.process.readyReadStandardError.connect(self.__readStderr) |
86 self.process.readyReadStandardError.connect(self.__readStderr) |
87 self.process.finished.connect(self.__finishedFreeze) |
87 self.process.finished.connect(self.__finishedFreeze) |
88 |
88 |
89 self.setWindowTitle(self.trUtf8('{0} - {1}').format( |
89 self.setWindowTitle(self.tr('{0} - {1}').format( |
90 self.cmdname, script)) |
90 self.cmdname, script)) |
91 self.contents.insertPlainText(' '.join(args) + '\n\n') |
91 self.contents.insertPlainText(' '.join(args) + '\n\n') |
92 self.contents.ensureCursorVisible() |
92 self.contents.ensureCursorVisible() |
93 |
93 |
94 program = args.pop(0) |
94 program = args.pop(0) |
95 self.process.start(program, args) |
95 self.process.start(program, args) |
96 procStarted = self.process.waitForStarted() |
96 procStarted = self.process.waitForStarted() |
97 if not procStarted: |
97 if not procStarted: |
98 E5MessageBox.critical( |
98 E5MessageBox.critical( |
99 self, |
99 self, |
100 self.trUtf8('Process Generation Error'), |
100 self.tr('Process Generation Error'), |
101 self.trUtf8( |
101 self.tr( |
102 'The process {0} could not be started. ' |
102 'The process {0} could not be started. ' |
103 'Ensure, that it is in the search path.' |
103 'Ensure, that it is in the search path.' |
104 ).format(program)) |
104 ).format(program)) |
105 return procStarted |
105 return procStarted |
106 |
106 |
134 if self.copyProcess is not None: |
134 if self.copyProcess is not None: |
135 self.copyProcess.terminate() |
135 self.copyProcess.terminate() |
136 self.copyProcess = None |
136 self.copyProcess = None |
137 |
137 |
138 self.contents.insertPlainText( |
138 self.contents.insertPlainText( |
139 self.trUtf8('\n{0} aborted.\n').format(self.cmdname)) |
139 self.tr('\n{0} aborted.\n').format(self.cmdname)) |
140 |
140 |
141 self.__enableButtons() |
141 self.__enableButtons() |
142 |
142 |
143 def __finishedFreeze(self): |
143 def __finishedFreeze(self): |
144 """ |
144 """ |
148 the user pressed the cancel button. |
148 the user pressed the cancel button. |
149 """ |
149 """ |
150 self.process = None |
150 self.process = None |
151 |
151 |
152 self.contents.insertPlainText( |
152 self.contents.insertPlainText( |
153 self.trUtf8('\n{0} finished.\n').format(self.cmdname)) |
153 self.tr('\n{0} finished.\n').format(self.cmdname)) |
154 |
154 |
155 self.copyProcess = CopyAdditionalFiles(self) |
155 self.copyProcess = CopyAdditionalFiles(self) |
156 self.copyProcess.insertPlainText.connect(self.contents.insertPlainText) |
156 self.copyProcess.insertPlainText.connect(self.contents.insertPlainText) |
157 self.copyProcess.finished.connect(self.__enableButtons) |
157 self.copyProcess.finished.connect(self.__enableButtons) |
158 self.copyProcess.start() |
158 self.copyProcess.start() |
297 """ |
297 """ |
298 self.insertPlainText.emit('----\n') |
298 self.insertPlainText.emit('----\n') |
299 os.chdir(self.ppath) |
299 os.chdir(self.ppath) |
300 for fn in self.additionalFiles: |
300 for fn in self.additionalFiles: |
301 self.insertPlainText.emit( |
301 self.insertPlainText.emit( |
302 self.trUtf8('\nCopying {0}: ').format(fn)) |
302 self.tr('\nCopying {0}: ').format(fn)) |
303 |
303 |
304 # on linux normpath doesn't replace backslashes to slashes. |
304 # on linux normpath doesn't replace backslashes to slashes. |
305 fn = fn.replace('\\', '/') |
305 fn = fn.replace('\\', '/') |
306 fn = os.path.abspath(os.path.normpath(fn)) |
306 fn = os.path.abspath(os.path.normpath(fn)) |
307 dst = os.path.join(self.ppath, self.targetDirectory) |
307 dst = os.path.join(self.ppath, self.targetDirectory) |
315 # already exists |
315 # already exists |
316 raise err |
316 raise err |
317 |
317 |
318 try: |
318 try: |
319 self.__copytree(fn, dst) |
319 self.__copytree(fn, dst) |
320 self.insertPlainText.emit(self.trUtf8('ok')) |
320 self.insertPlainText.emit(self.tr('ok')) |
321 except IOError as err: |
321 except IOError as err: |
322 self.insertPlainText.emit( |
322 self.insertPlainText.emit( |
323 self.trUtf8('failed: {0}').format(err.strerror)) |
323 self.tr('failed: {0}').format(err.strerror)) |