Exemplo n.º 1
0
    def load_conf(self, filename):
        config = ConfigParser.SafeConfigParser()
        try:
            config.read(filename)
            sections = config.sections()
            if len(sections):
                device = DeviceGPS()
                device.name = sections[0]
                device.type = config.getint(sections[0], 'type')
                device.resource = config.get(sections[0], 'resource')
                if device.type == DeviceGPS.NMEA_SERIAL:
                    if config.has_option(sections[0], 'baud'):
                        device.baud = config.getint(sections[0], 'baud')
                    if config.has_option(sections[0], 'bits'):
                        device.bytes = config.getint(sections[0], 'bits')
                    if config.has_option(sections[0], 'parity'):
                        device.parity = config.get(sections[0], 'parity')
                    if config.has_option(sections[0], 'stops'):
                        device.stops = config.getint(sections[0], 'stops')
                    if config.has_option(sections[0], 'soft'):
                        device.soft = config.getboolean(sections[0], 'soft')

                self.devicesGps.append(device)
                return self.__check_conf_serial(device)

        except ConfigParser.Error as e:
            return e.message
        except ValueError as e:
            return e.message
Exemplo n.º 2
0
 def __load_devices_gps(self):
     self.devicesGps = []
     self.cfg.SetPath("/DevicesGPS")
     group = self.cfg.GetFirstGroup()
     while group[0]:
         self.cfg.SetPath("/DevicesGPS/" + group[1])
         device = DeviceGPS()
         device.name = group[1]
         device.type = self.cfg.ReadInt("type", device.type)
         device.resource = self.cfg.Read("resource", device.resource)
         device.baud = self.cfg.ReadInt("baud", device.baud)
         device.bytes = self.cfg.ReadInt("bytes", device.bytes)
         device.parity = self.cfg.Read("parity", device.parity)
         device.stops = self.cfg.ReadInt("stops", device.stops)
         device.soft = self.cfg.ReadBool("soft", device.soft)
         self.devicesGps.append(device)
         self.cfg.SetPath("/DevicesGPS")
         group = self.cfg.GetNextGroup(group[2])
Exemplo n.º 3
0
 def __load_devices_gps(self):
     self.devicesGps = []
     self.cfg.SetPath("/DevicesGPS")
     group = self.cfg.GetFirstGroup()
     while group[0]:
         self.cfg.SetPath("/DevicesGPS/" + group[1])
         device = DeviceGPS()
         device.name = group[1]
         device.type = self.cfg.ReadInt('type', device.type)
         device.resource = self.cfg.Read('resource', device.resource)
         device.baud = self.cfg.ReadInt('baud', device.baud)
         device.bytes = self.cfg.ReadInt('bytes', device.bytes)
         device.parity = self.cfg.Read('parity', device.parity)
         device.stops = self.cfg.ReadInt('stops', device.stops)
         device.soft = self.cfg.ReadBool('soft', device.soft)
         self.devicesGps.append(device)
         self.cfg.SetPath("/DevicesGPS")
         group = self.cfg.GetNextGroup(group[2])