Project/ProjectProtocolsBrowser.py

changeset 5974
dfb291b5b620
parent 5970
411f7ba577d5
child 5984
bc7ec03158fc
equal deleted inserted replaced
5973:54aba06fefe2 5974:dfb291b5b620
95 self.sourceMenu.addAction( 95 self.sourceMenu.addAction(
96 self.tr('Compile all protocols'), 96 self.tr('Compile all protocols'),
97 self.__compileAllProtocols) 97 self.__compileAllProtocols)
98 self.sourceMenu.addSeparator() 98 self.sourceMenu.addSeparator()
99 self.sourceMenu.addAction( 99 self.sourceMenu.addAction(
100 self.tr('Compile protocol as grpc'), 100 self.tr('Compile protocol as gRPC'),
101 lambda: self.__compileProtocol(grpc=True)) 101 lambda: self.__compileProtocol(grpc=True))
102 self.sourceMenu.addAction( 102 self.sourceMenu.addAction(
103 self.tr('Compile all protocols as grpc'), 103 self.tr('Compile all protocols as gRPC'),
104 lambda: self.__compileAllProtocols(grpc=True)) 104 lambda: self.__compileAllProtocols(grpc=True))
105 self.sourceMenu.addSeparator() 105 self.sourceMenu.addSeparator()
106 self.sourceMenu.addAction(self.tr('Open'), self._openItem) 106 self.sourceMenu.addAction(self.tr('Open'), self._openItem)
107 self.sourceMenu.addSeparator() 107 self.sourceMenu.addSeparator()
108 act = self.sourceMenu.addAction( 108 act = self.sourceMenu.addAction(
139 self.menu.addAction( 139 self.menu.addAction(
140 self.tr('Compile all protocols'), 140 self.tr('Compile all protocols'),
141 self.__compileAllProtocols) 141 self.__compileAllProtocols)
142 self.menu.addSeparator() 142 self.menu.addSeparator()
143 self.menu.addAction( 143 self.menu.addAction(
144 self.tr('Compile protocol as grpc'), 144 self.tr('Compile protocol as gRPC'),
145 lambda: self.__compileProtocol(grpc=True)) 145 lambda: self.__compileProtocol(grpc=True))
146 self.menu.addAction( 146 self.menu.addAction(
147 self.tr('Compile all protocols as grpc'), 147 self.tr('Compile all protocols as gRPC'),
148 lambda: self.__compileAllProtocols(grpc=True)) 148 lambda: self.__compileAllProtocols(grpc=True))
149 self.menu.addSeparator() 149 self.menu.addSeparator()
150 self.menu.addAction(self.tr('Open'), self._openItem) 150 self.menu.addAction(self.tr('Open'), self._openItem)
151 self.menu.addSeparator() 151 self.menu.addSeparator()
152 self.menu.addAction( 152 self.menu.addAction(
168 self.backMenu.addAction( 168 self.backMenu.addAction(
169 self.tr('Compile all protocols'), 169 self.tr('Compile all protocols'),
170 self.__compileAllProtocols) 170 self.__compileAllProtocols)
171 self.backMenu.addSeparator() 171 self.backMenu.addSeparator()
172 self.backMenu.addAction( 172 self.backMenu.addAction(
173 self.tr('Compile all protocols as grpc'), 173 self.tr('Compile all protocols as gRPC'),
174 lambda: self.__compileAllProtocols(grpc=True)) 174 lambda: self.__compileAllProtocols(grpc=True))
175 self.backMenu.addSeparator() 175 self.backMenu.addSeparator()
176 self.backMenu.addAction( 176 self.backMenu.addAction(
177 self.tr('Add protocols...'), self.project.addProtoFiles) 177 self.tr('Add protocols...'), self.project.addProtoFiles)
178 self.backMenu.addAction( 178 self.backMenu.addAction(
193 self.multiMenu.addAction( 193 self.multiMenu.addAction(
194 self.tr('Compile protocols'), 194 self.tr('Compile protocols'),
195 self.__compileSelectedProtocols) 195 self.__compileSelectedProtocols)
196 self.multiMenu.addSeparator() 196 self.multiMenu.addSeparator()
197 self.multiMenu.addAction( 197 self.multiMenu.addAction(
198 self.tr('Compile protocols as grpc'), 198 self.tr('Compile protocols as gRPC'),
199 lambda: self.__compileSelectedProtocols(grpc=True)) 199 lambda: self.__compileSelectedProtocols(grpc=True))
200 self.multiMenu.addSeparator() 200 self.multiMenu.addSeparator()
201 self.multiMenu.addAction(self.tr('Open'), self._openItem) 201 self.multiMenu.addAction(self.tr('Open'), self._openItem)
202 self.multiMenu.addSeparator() 202 self.multiMenu.addSeparator()
203 act = self.multiMenu.addAction( 203 act = self.multiMenu.addAction(
220 self.dirMenu.addAction( 220 self.dirMenu.addAction(
221 self.tr('Compile all protocols'), 221 self.tr('Compile all protocols'),
222 self.__compileAllProtocols) 222 self.__compileAllProtocols)
223 self.dirMenu.addSeparator() 223 self.dirMenu.addSeparator()
224 self.dirMenu.addAction( 224 self.dirMenu.addAction(
225 self.tr('Compile all protocols as grpc'), 225 self.tr('Compile all protocols as gRPC'),
226 lambda: self.__compileAllProtocols(grpc=True)) 226 lambda: self.__compileAllProtocols(grpc=True))
227 act = self.dirMenu.addAction( 227 act = self.dirMenu.addAction(
228 self.tr('Remove from project'), self._removeFile) 228 self.tr('Remove from project'), self._removeFile)
229 self.dirMenuActions.append(act) 229 self.dirMenuActions.append(act)
230 act = self.dirMenu.addAction( 230 act = self.dirMenu.addAction(
253 self.dirMultiMenu.addAction( 253 self.dirMultiMenu.addAction(
254 self.tr('Compile all protocols'), 254 self.tr('Compile all protocols'),
255 self.__compileAllProtocols) 255 self.__compileAllProtocols)
256 self.dirMultiMenu.addSeparator() 256 self.dirMultiMenu.addSeparator()
257 self.dirMultiMenu.addAction( 257 self.dirMultiMenu.addAction(
258 self.tr('Compile all protocols as grpc'), 258 self.tr('Compile all protocols as gRPC'),
259 lambda: self.__compileAllProtocols(grpc=True)) 259 lambda: self.__compileAllProtocols(grpc=True))
260 self.dirMultiMenu.addAction( 260 self.dirMultiMenu.addAction(
261 self.tr('Add protocols...'), self.project.addProtoFiles) 261 self.tr('Add protocols...'), self.project.addProtoFiles)
262 self.dirMultiMenu.addAction( 262 self.dirMultiMenu.addAction(
263 self.tr('Add protocols directory...'), self.project.addProtoDir) 263 self.tr('Add protocols directory...'), self.project.addProtoDir)
458 458
459 def __getCompilerCommand(self, grpc): 459 def __getCompilerCommand(self, grpc):
460 """ 460 """
461 Private method to get the compiler command. 461 Private method to get the compiler command.
462 462
463 @param grpc flag indicating to get a grpc command 463 @param grpc flag indicating to get a gRPC command
464 @type bool 464 @type bool
465 @return tuple giving the executable and its parameter list 465 @return tuple giving the executable and its parameter list
466 @rtype tuple of (str, list of str) 466 @rtype tuple of (str, list of str)
467 """ 467 """
468 exe = None 468 exe = None
523 523
524 @param exitCode exit code of the process 524 @param exitCode exit code of the process
525 @type int 525 @type int
526 @param exitStatus exit status of the process 526 @param exitStatus exit status of the process
527 @type QProcess.ExitStatus 527 @type QProcess.ExitStatus
528 @param grpc flag indicating to compile as grpc files 528 @param grpc flag indicating to compile as gRPC files
529 @type bool 529 @type bool
530 """ 530 """
531 self.__compileRunning = False 531 self.__compileRunning = False
532 ui = e5App().getObject("UserInterface") 532 ui = e5App().getObject("UserInterface")
533 if exitStatus == QProcess.NormalExit and exitCode == 0: 533 if exitStatus == QProcess.NormalExit and exitCode == 0:
574 @type str 574 @type str
575 @param noDialog flag indicating silent operations 575 @param noDialog flag indicating silent operations
576 @type bool 576 @type bool
577 @param progress reference to the progress dialog 577 @param progress reference to the progress dialog
578 @type E5ProgressDialog 578 @type E5ProgressDialog
579 @param grpc flag indicating to compile as grpc files 579 @param grpc flag indicating to compile as gRPC files
580 @type bool 580 @type bool
581 @return reference to the compile process 581 @return reference to the compile process
582 @rtype QProcess 582 @rtype QProcess
583 """ 583 """
584 exe, exeArgs = self.__getCompilerCommand(grpc) 584 exe, exeArgs = self.__getCompilerCommand(grpc)
628 628
629 def __compileProtocol(self, grpc=False): 629 def __compileProtocol(self, grpc=False):
630 """ 630 """
631 Private method to compile a protocol to Python. 631 Private method to compile a protocol to Python.
632 632
633 @param grpc flag indicating to compile as grpc files 633 @param grpc flag indicating to compile as gRPC files
634 @type bool 634 @type bool
635 """ 635 """
636 if self.__getCompilerCommand(grpc)[0] is not None: 636 if self.__getCompilerCommand(grpc)[0] is not None:
637 itm = self.model().item(self.currentIndex()) 637 itm = self.model().item(self.currentIndex())
638 fn2 = itm.fileName() 638 fn2 = itm.fileName()
641 641
642 def __compileAllProtocols(self, grpc=False): 642 def __compileAllProtocols(self, grpc=False):
643 """ 643 """
644 Private method to compile all protocols to Python. 644 Private method to compile all protocols to Python.
645 645
646 @param grpc flag indicating to compile as grpc files 646 @param grpc flag indicating to compile as gRPC files
647 @type bool 647 @type bool
648 """ 648 """
649 if self.__getCompilerCommand(grpc)[0] is not None: 649 if self.__getCompilerCommand(grpc)[0] is not None:
650 numProtos = len(self.project.pdata["PROTOCOLS"]) 650 numProtos = len(self.project.pdata["PROTOCOLS"])
651 progress = E5ProgressDialog( 651 progress = E5ProgressDialog(
675 675
676 def __compileSelectedProtocols(self, grpc=False): 676 def __compileSelectedProtocols(self, grpc=False):
677 """ 677 """
678 Private method to compile selected protocols to Python. 678 Private method to compile selected protocols to Python.
679 679
680 @param grpc flag indicating to compile as grpc files 680 @param grpc flag indicating to compile as gRPC files
681 @type bool 681 @type bool
682 """ 682 """
683 if self.__getCompilerCommand(grpc)[0] is not None: 683 if self.__getCompilerCommand(grpc)[0] is not None:
684 items = self.getSelectedItems() 684 items = self.getSelectedItems()
685 685

eric ide

mercurial