def __init__(self, serial_port, parent): """Init process.""" Process.__init__(self) self.exit = Event() self.serial_port = serial_port self.device = Device.get(Device.get_identifier_from_serial(serial_port)) self.get_port_list() self.ser = None self.parent = parent self.parent.set_datas(self.serial_port, dict(self.value))
def edit(self, slug): """Show configuration form for device.""" device = Device.get(Device.get_identifier_from_serial(slug)) cards = Card.get_all() sensors = Sensor.get_all() if device is None: device = Device.get_config(slug) if device is None: self.redirect(self.redirect_url + '/create', permanent=False) settings = dict() settings['method'] = 'put' settings['cards'] = cards settings['card'] = device.card settings['sensors'] = sensors settings['device'] = device settings['method'] = 'put' self.render('device/config.html', **settings)
def create(self, slug): """Show configuration form for device.""" cards = Card.get_all() sensors = Sensor.get_all() device = Device.get(slug) if 'card' in self.request.arguments: card = Card.get(self.get_argument('card')) else: card = None settings = dict() settings['method'] = 'post' settings['cards'] = cards settings['card'] = card settings['sensors'] = sensors settings['device'] = device settings['slug'] = slug settings['method'] = 'post' self.render('device/config.html', **settings)
def show(self, slug): """Show device.""" device = Device.get(Device.get_identifier_from_serial(slug)) if device is None: device = Device.get_config(slug) if device is None: self.redirect(self.redirect_url + '/create', permanent=False) else: settings = dict() settings['device'] = device settings['slug'] = slug self.render('device/show.html', **settings) else: settings = dict() settings['port'] = SSL_PORT settings['slug'] = slug settings['device'] = device self.render('device/communicate.html', **settings)