예제 #1
0
 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))
예제 #2
0
 def save(self, slug):
     """Save configuration."""
     try:
         self.request.arguments.pop("_method")
     except Exception:
         pass
     device = Device.from_request_args(slug, self.request.arguments)
     device.save()
예제 #3
0
    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)
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 def list(self):
     """List configuration."""
     devices = Device.get_all()
     self.render('device/list.html', devices=devices)
예제 #7
0
 def get(self):
     """Handle get request."""
     devices = Device.get_connected_devices()
     self.render('index.html', devices=devices)