Ejemplo n.º 1
0
 def __setTerminals(self):
           
     if self.__cmdAgent.commandServiceIsConnected() == True:                                 
         Command.createCallbackTerminal(Terminal())
         logging.debug('Creating terminal for command callbacks...')
         
     if self.__tmParamAgent.paramServiceIsConnected() == True:
         TMParameter.createParamNotificationTerminal(Terminal())
         logging.debug('Creating terminal for parameter callbacks...')
         
     if self.__tmPacketAgent.packetServiceIsConnected() == True:
         TMPacket.createPacketNotificationTerminal(Terminal())
         logging.debug('Creating terminal for packet callbacks...')
Ejemplo n.º 2
0
 def __createViewInterfaces(self):      
     
     if self.__cmdAgent.commandServiceIsConnected() == True: 
         self.__cmdAgent.createCmdInjMngrView(CommandInjectMngrView())  
         logging.debug('Successfully created command view interface...')
         
     if self.__tmParamAgent.paramServiceIsConnected() == True:
         tmParamView = self.__tmParamAgent.createParamView(ParameterView())
         TMParameter.setParamView(tmParamView)
         logging.debug('Successfully created parameter view interface...')
         
     if self.__tmPacketAgent.packetServiceIsConnected() == True:
         tmPacketView = self.__tmPacketAgent.createPacketView(PacketView())
         TMPacket.setPacketView(tmPacketView)
         logging.debug('Successfully created packet view interface...')      
Ejemplo n.º 3
0
    def writeParameterLog(self, path):
        
        print('Writing parameter log...', 
              end='' if self.__verbLevel == 2 else '\n')
        logging.debug('Writing parameter log...')
        
        with open(path, 'w') as log:
            for param in TMParameter.getGlobalParamList():
                log.write(str(param) + '\n')
                
                if param == TMParameter.getGlobalParamList()[-1]:
                    log.write('\n' + '=' * 95 + '\nEnd of log\n' + '=' * 95 + '\n')

        if self.__verbLevel == 2:            
            print('done') 
        elif self.__verbLevel == 1:
            print('Finished writing parameter log...')          
        
        logging.debug('Finished writing parameter log...')
        self.__flush()    
Ejemplo n.º 4
0
 def setVerbosity(self, verbLevel, terminal=None):
     
     if verbLevel in [2, 1]:
         self.__verbLevel = verbLevel
         
         if verbLevel == 2 and terminal == None:
             print(Fore.RED + Style.BRIGHT + '\nError: ' + Style.RESET_ALL + f'Please set terminal type for verbosity level 2')
             logging.error(f'Error: Terminal type for verbosity level 2 is not set', exc_info=False)
             sys.exit(1)                
         elif verbLevel == 2:
             Command.setTerminalType(terminal)
             TMParameter.setTerminalType(terminal)
             TMPacket.setTerminalType(terminal)
         
         Command.setVerbosityLevel(verbLevel)
         TMParameter.setVerbosityLevel(verbLevel)
         TMPacket.setVerbosityLevel(verbLevel)
                                 
     else:
         print(Fore.RED + Style.BRIGHT + '\nError: ' + Style.RESET_ALL + f'Verbosity level must be 1 or 2, not {verbLevel}')
         logging.error(f'Error: Verbosity level must be 1 or 2, not {verbLevel}', exc_info=False)
         sys.exit(1)
Ejemplo n.º 5
0
 def notifyParameter(self, key, value):
     TMParameter.getParameterNotification(key, value)
Ejemplo n.º 6
0
 def __exit__(self, type, value, traceback):
                          
     if type == KeyboardInterrupt:
         self.exitScr(1, keybInterrupt=True)
     elif Command.getExecutionError() == False and TMParameter.getExecutionError() == False and TMPacket.getExecutionError() == False:
         self.exitScr(0)
Ejemplo n.º 7
0
 def unregisterAllTmParameters(self):
     
     TMParameter.unregisterAllTmParameters()
Ejemplo n.º 8
0
    def registerTMParameter(self, paramName, **paramKwargs):

        try:        
            paramDef = self.__mibAgent.parameterMIBDefinition(paramName)
            
            parameter = TMParameter(paramDef.m_name, paramDef.m_description, **paramKwargs)
            parameter.setParameterDef(paramDef)
            parameter.getParameterFromServer(self.__tmParamAgent.getSingleTMParamMngr())
            parameter.registerParameter()
                                                   
            return parameter

        except Exception as exception: 
            print(Fore.RED + Style.BRIGHT + '\nException during parameter reception: ' + Style.RESET_ALL + f'{exception}')            
            logging.exception(f'Exception during parameter reception: {exception}', exc_info=False)
            if 'parameter' is locals() and parameter.getViewKey() != 0:
                parameter.unregisterParamView()