Example #1
0
    def __init__(self, swap_settings=None):
        """
        Class constructor

        @param file_name: name of the HEX file        
        @param swap_settings: path to the main SWAP configuration file
        """
        # Main configuration file
        self.swap_settings = swap_settings
        # Print SWAP activity
        self._print_swap = False
        # Server started flag
        self.server_started = False

        try:
            # Superclass call
            SwapInterface.__init__(self, swap_settings)
        except SwapException as ex:
            ex.display()
        except:
            pass

        # Disable verbose
        self.server.verbose = False

        self.verbose = False

        # Firmware image
        self.hexfile = None
        # Progress bar
        self.progress = None
        # Number of line being queried
        self.hexfile_line = 0
        # Address of node being programmed
        self.prog_address = None
Example #2
0
    def __init__(self, swap_settings=None):
        """
        Class constructor
        
        @param swap_settings: path to the main SWAP configuration file
        @param verbose: Print out SWAP frames or not
        @param monitor: Print out network events or not
        """
       
        # Main configuration file
        self.swap_settings = swap_settings
        # Print SWAP activity
        self._print_swap = False
        
        try:
            self.main_settings = XmlSettings(self.swap_settings)
            # Set log file to trace lagarto exceptions
            LagartoException.error_file = XmlSettings.error_file
            # Superclass call
            SwapInterface.__init__(self, swap_settings)
        except:
            raise

        # Lagarto server constructor
        LagartoServer.__init__(self, working_dir)

        if XmlSettings.debug == 2:
            self._print_swap = True
            
        self.lagarto_config = XmlLagarto(os.path.join(config_dir, "lagarto.xml"))
Example #3
0
    def __init__(self, settings=None):
        """
        Class constructor
        
        @param settings: path to the main configuration file
        """
        # Callbacks not being used
        self.registerValueChanged = None

        # wxPython app
        self.app = wx.App(False)

        # Start SWAP server
        try:
            # Superclass call
            SwapInterface.__init__(self, settings, False)
            # Clear error file
            SwapException.clear()
        except SwapException as ex:
            ex.display()
            ex.log()

        # Open SWAP Device Management Tool
        self.dmtframe = MainFrame("SWAP Device Management Tool",
                                  self,
                                  server=self.server)
        #self.dmtframe.SetSize(wx.Size(370,500))
        self.app.SetTopWindow(self.dmtframe)
        self.dmtframe.CenterOnScreen()
        self.dmtframe.Show(True)

        self.app.MainLoop()
Example #4
0
    def __init__(self, swap_settings=None):
        """
        Class constructor
        
        @param swap_settings: path to the main SWAP configuration file
        @param verbose: Print out SWAP frames or not
        @param monitor: Print out network events or not
        """

        # Main configuration file
        self.swap_settings = swap_settings
        # Print SWAP activity
        self._print_swap = False

        try:
            self.main_settings = XmlSettings(self.swap_settings)
            # Set log file to trace lagarto exceptions
            LagartoException.error_file = XmlSettings.error_file
            # Superclass call
            SwapInterface.__init__(self, swap_settings)
        except:
            raise

        # Lagarto process constructor
        LagartoProcess.__init__(self, working_dir)

        if XmlSettings.debug == 2:
            self._print_swap = True

        self.lagarto_config = XmlLagarto(
            os.path.join(config_dir, "lagarto.xml"))
Example #5
0
    def __init__(self, swap_settings=None, abort_call=None):
        """
        Class constructor
        
        @param swap_settings: path to the main SWAP configuration file
        @param verbose: Print out SWAP frames or not
        @param monitor: Print out network events or not
        @param abort_call: Call in case of abrupt hang mode
        """
        self.parent_abort_call = abort_call
        # MAin configuration file
        self.swap_settings = swap_settings
        # Print SWAP activity
        self._print_swap = False

        try:
            # Superclass call
            SwapInterface.__init__(self, swap_settings, abort_call=self.abort_call)
        except:
            raise

        # Lagarto server constructor
        LagartoServer.__init__(self, working_dir)

        if XmlSettings.debug == 2:
            self._print_swap = True
Example #6
0
    def __init__(self, swap_settings=None):
        """
        Class constructor
        
        @param swap_settings: path to the main SWAP configuration file
        @param verbose: Print out SWAP frames or not
        @param monitor: Print out network events or not
        """
        # MAin configuration file
        self.swap_settings = swap_settings
        # Print SWAP activity
        self._print_swap = False
        
        try:
            # Superclass call
            SwapInterface.__init__(self, swap_settings)
        except:
            raise

        # Lagarto server constructor
        LagartoServer.__init__(self, working_dir)

        if XmlSettings.debug == 2:
            self._print_swap = True
        self.log("Logging enabled")
Example #7
0
    def __init__(self, swap_settings=None):
        """
        Class constructor

        @param file_name: name of the HEX file        
        @param swap_settings: path to the main SWAP configuration file
        """
        # Main configuration file
        self.swap_settings = swap_settings
        # Print SWAP activity
        self._print_swap = False
        # Server started flag
        self.server_started = False

        try:
            # Superclass call
            SwapInterface.__init__(self, swap_settings)
        except SwapException as ex:
            ex.display()
        except:
            pass

        # Disable verbose
        self.server.verbose = False

        self.verbose = False

        # Firmware image
        self.hexfile = None
        # Progress bar
        self.progress = None
        # Number of line being queried
        self.hexfile_line = 0
        # Address of node being programmed
        self.prog_address = None
Example #8
0
    def __init__(self, settings=None):
        """
        Class constructor
        
        @param settings: path to the main configuration file
        """
        # Callbacks not being used
        self.registerValueChanged = None

        # wxPython app
        self.app = wx.App(False)
               
        # Start SWAP server
        try:
            # Superclass call
            SwapInterface.__init__(self, settings, False)  
            # Clear error file
            SwapException.clear()         
        except SwapException as ex:
            ex.display()
            ex.log()

        # Open SWAP Device Management Tool
        self.dmtframe = MainFrame("SWAP Device Management Tool", self, server=self.server)
        #self.dmtframe.SetSize(wx.Size(370,500))
        self.app.SetTopWindow(self.dmtframe)
        self.dmtframe.CenterOnScreen()
        self.dmtframe.Show(True)

        self.app.MainLoop()
 def __init__(self, swap_settings=None):
     """
     Class constructor
     
     @param swap_settings: path to the main SWAP configuration file
     """
     
     # MAin configuration file
     self.swap_settings = swap_settings
     
     # Print SWAP activity
     DEBUG = False
     
     #Setup MQTT client
     self.mqttc = mosquitto.Mosquitto("LIB-PI_"+str(MQTT.pi_id)+str(random.randrange(10000)))
     self.mqttc.on_connect = self.on_connect
     self.mqttc.on_publish = self.on_publish
     self.mqttc.on_message = self.on_message
     self.mqttc.connect(MQTT.server, 1883)
     
     try:
         # Superclass call
         SwapInterface.__init__(self, swap_settings)
         
         # Start MQTT client loop
         self.mqttc.loop_forever()
     except:
         e = sys.exc_info()[0]
         print ("<__init__> Error: %s" % e )
         self.shell_command("sudo svc -t /etc/service/lib/")
Example #10
0
 def __init__(self, *args, **kwargs):
     self.log = logging.getLogger(type(self).__name__) # needed as this does not require a new thread
     self.server = None
     # Prepare config files
     try:
         tmp = re.sub('<port>(.*)</port>', '<port>%s</port>' % self.config.get('serial'), open(os.path.join(Swap.baseDir, 'serial.xml')).read())
         open(os.path.join(Swap.baseDir, 'serial.xml'), 'w').write(tmp)
         SwapInterface.__init__(self, *args, settings=os.path.join(Swap.baseDir, 'settings.xml'), start=False, **kwargs)
         self.server.setDaemon(True)
     except Exception, E:
         self.log.error('Cannot initialize: %s' % E.message)
Example #11
0
 def __init__(self, verbose=False, monitor=False):
     """
     Class constructor
     
     'verbose'  Print out SWAP frames or not
     'monitor'  Print out network events or not
     """
     # Superclass call
     SwapInterface.__init__(self, None, verbose)        
     # Print SWAP activity
     self._printSWAP = monitor
     # Mote address in SYNC mode
     self._addrInSyncMode = None
Example #12
0
 def __init__(self, *args, **kwargs):
     self.log = logging.getLogger(type(
         self).__name__)  # needed as this does not require a new thread
     self.server = None
     # Prepare config files
     try:
         tmp = re.sub('<port>(.*)</port>',
                      '<port>%s</port>' % self.config.get('serial'),
                      open(os.path.join(Swap.baseDir, 'serial.xml')).read())
         open(os.path.join(Swap.baseDir, 'serial.xml'), 'w').write(tmp)
         SwapInterface.__init__(self,
                                *args,
                                settings=os.path.join(
                                    Swap.baseDir, 'settings.xml'),
                                start=False,
                                **kwargs)
         self.server.setDaemon(True)
     except Exception, E:
         self.log.error('Cannot initialize: %s' % E.message)
Example #13
0
    def __init__(self, swap_settings=None):
        """
        Class constructor
        
        @param swap_settings: path to the main SWAP configuration file
        @param verbose: Print out SWAP frames or not
        @param monitor: Print out network events or not
        """
        # MAin configuration file
        self.swap_settings = swap_settings
        # Print SWAP activity
        self._print_swap = False

        try:
            # Superclass call
            SwapInterface.__init__(self, swap_settings)
        except:
            raise

        # Lagarto server constructor
        LagartoServer.__init__(self, working_dir)

        if XmlSettings.debug == 2:
            self._print_swap = True
Example #14
0
 def __init__(self, verbose=False):
     """
     Class constructor
     """    
     SwapInterface.__init__(self, verbose)