14 import contextlib |
14 import contextlib |
15 |
15 |
16 from PyQt6.QtCore import QThread, pyqtSignal, QProcess |
16 from PyQt6.QtCore import QThread, pyqtSignal, QProcess |
17 from PyQt6.QtWidgets import QDialog, QApplication, QMenu |
17 from PyQt6.QtWidgets import QDialog, QApplication, QMenu |
18 |
18 |
19 from E5Gui.E5Application import e5App |
19 from E5Gui.EricApplication import ericApp |
20 from E5Gui import E5MessageBox |
20 from E5Gui import EricMessageBox |
21 from E5Gui.E5ProgressDialog import E5ProgressDialog |
21 from E5Gui.EricProgressDialog import EricProgressDialog |
22 |
22 |
23 from .ProjectBrowserModel import ( |
23 from .ProjectBrowserModel import ( |
24 ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem, |
24 ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem, |
25 ProjectBrowserDirectoryItem, ProjectBrowserProtocolsType |
25 ProjectBrowserDirectoryItem, ProjectBrowserProtocolsType |
26 ) |
26 ) |
537 @type QProcess.ExitStatus |
537 @type QProcess.ExitStatus |
538 @param grpc flag indicating to compile as gRPC files |
538 @param grpc flag indicating to compile as gRPC files |
539 @type bool |
539 @type bool |
540 """ |
540 """ |
541 self.__compileRunning = False |
541 self.__compileRunning = False |
542 ui = e5App().getObject("UserInterface") |
542 ui = ericApp().getObject("UserInterface") |
543 if exitStatus == QProcess.ExitStatus.NormalExit and exitCode == 0: |
543 if exitStatus == QProcess.ExitStatus.NormalExit and exitCode == 0: |
544 path = os.path.dirname(self.__protoFile) |
544 path = os.path.dirname(self.__protoFile) |
545 fileList = glob.glob(os.path.join(path, "*_pb2.py")) |
545 fileList = glob.glob(os.path.join(path, "*_pb2.py")) |
546 if grpc: |
546 if grpc: |
547 fileList += glob.glob(os.path.join(path, "*_pb2_grpc.py")) |
547 fileList += glob.glob(os.path.join(path, "*_pb2_grpc.py")) |
578 @param fn filename of the .proto file to be compiled |
578 @param fn filename of the .proto file to be compiled |
579 @type str |
579 @type str |
580 @param noDialog flag indicating silent operations |
580 @param noDialog flag indicating silent operations |
581 @type bool |
581 @type bool |
582 @param progress reference to the progress dialog |
582 @param progress reference to the progress dialog |
583 @type E5ProgressDialog |
583 @type EricProgressDialog |
584 @param grpc flag indicating to compile as gRPC files |
584 @param grpc flag indicating to compile as gRPC files |
585 @type bool |
585 @type bool |
586 @return reference to the compile process |
586 @return reference to the compile process |
587 @rtype QProcess |
587 @rtype QProcess |
588 """ |
588 """ |
614 return self.compileProc |
614 return self.compileProc |
615 else: |
615 else: |
616 self.__compileRunning = False |
616 self.__compileRunning = False |
617 if progress is not None: |
617 if progress is not None: |
618 progress.cancel() |
618 progress.cancel() |
619 E5MessageBox.critical( |
619 EricMessageBox.critical( |
620 self, |
620 self, |
621 self.tr('Process Generation Error'), |
621 self.tr('Process Generation Error'), |
622 self.tr( |
622 self.tr( |
623 '<p>Could not start {0}.<br>' |
623 '<p>Could not start {0}.<br>' |
624 'Ensure that it is in the search path.</p>' |
624 'Ensure that it is in the search path.</p>' |
625 ).format(exe)) |
625 ).format(exe)) |
626 return None |
626 return None |
627 else: |
627 else: |
628 E5MessageBox.critical( |
628 EricMessageBox.critical( |
629 self, |
629 self, |
630 self.tr('Compiler Invalid'), |
630 self.tr('Compiler Invalid'), |
631 self.tr('The configured compiler is invalid.')) |
631 self.tr('The configured compiler is invalid.')) |
632 return None |
632 return None |
633 |
633 |
651 @param grpc flag indicating to compile as gRPC files |
651 @param grpc flag indicating to compile as gRPC files |
652 @type bool |
652 @type bool |
653 """ |
653 """ |
654 if self.__getCompilerCommand(grpc)[0] is not None: |
654 if self.__getCompilerCommand(grpc)[0] is not None: |
655 numProtos = len(self.project.pdata["PROTOCOLS"]) |
655 numProtos = len(self.project.pdata["PROTOCOLS"]) |
656 progress = E5ProgressDialog( |
656 progress = EricProgressDialog( |
657 self.tr("Compiling Protocols..."), |
657 self.tr("Compiling Protocols..."), |
658 self.tr("Abort"), 0, numProtos, |
658 self.tr("Abort"), 0, numProtos, |
659 self.tr("%v/%m Protocols"), self) |
659 self.tr("%v/%m Protocols"), self) |
660 progress.setModal(True) |
660 progress.setModal(True) |
661 progress.setMinimumDuration(0) |
661 progress.setMinimumDuration(0) |
686 items = self.getSelectedItems() |
686 items = self.getSelectedItems() |
687 |
687 |
688 files = [self.project.getRelativePath(itm.fileName()) |
688 files = [self.project.getRelativePath(itm.fileName()) |
689 for itm in items] |
689 for itm in items] |
690 numProtos = len(files) |
690 numProtos = len(files) |
691 progress = E5ProgressDialog( |
691 progress = EricProgressDialog( |
692 self.tr("Compiling Protocols..."), |
692 self.tr("Compiling Protocols..."), |
693 self.tr("Abort"), 0, numProtos, |
693 self.tr("Abort"), 0, numProtos, |
694 self.tr("%v/%m Protocols"), self) |
694 self.tr("%v/%m Protocols"), self) |
695 progress.setModal(True) |
695 progress.setModal(True) |
696 progress.setMinimumDuration(0) |
696 progress.setMinimumDuration(0) |