Beispiel #1
0
 def index(self):
     wifi = Path.home() / 'wifi_network.txt'
     remote_server = Path.home() / 'odoo-remote-server.conf'
     if (wifi.exists() == False or remote_server.exists() == False) and helpers.access_point():
         return "<meta http-equiv='refresh' content='0; url=http://" + helpers.get_ip() + ":8069/steps'>"
     else:
         return homepage_template.render(self.get_homepage_data())
Beispiel #2
0
    def get_homepage_data(self):
        hostname = str(socket.gethostname())
        ssid = helpers.get_ssid()
        wired = subprocess.check_output(['cat', '/sys/class/net/eth0/operstate']).decode('utf-8').strip('\n')
        if wired == 'up':
            network = 'Ethernet'
        elif ssid:
            if helpers.access_point():
                network = 'Wifi access point'
            else:
                network = 'Wifi : ' + ssid
        else:
            network = 'Not Connected'

        iot_device = []
        for device in iot_devices:
            iot_device.append({
                'name': iot_devices[device].device_name + ' : ' + str(iot_devices[device].data['value']),
                'type': iot_devices[device].device_type.replace('_', ' '),
                'message': iot_devices[device].device_identifier + iot_devices[device].get_message()
            })

        return {
            'hostname': hostname,
            'ip': helpers.get_ip(),
            'mac': helpers.get_mac_address(),
            'iot_device_status': iot_device,
            'server_status': helpers.get_odoo_server_url() or 'Not Configured',
            'six_terminal': self.get_six_terminal(),
            'network_status': network,
            'version': helpers.get_version(),
            }
 def run(self):
     if not helpers.get_odoo_server_url() and not helpers.access_point():
         end_time = datetime.now() + timedelta(minutes=5)
         while (datetime.now() < end_time):
             self._connect_box()
             time.sleep(10)
         self.pairing_code = False
         self.pairing_uuid = False
         self._refresh_displays()
Beispiel #4
0
    def get_homepage_data(self):
        hostname = str(socket.gethostname())
        mac = get_mac()
        h = iter(hex(mac)[2:].zfill(12))
        ssid = subprocess.check_output(
            'iwconfig 2>&1 | grep \'ESSID:"\' | sed \'s/.*"\\(.*\\)"/\\1/\'',
            shell=True).decode('utf-8').rstrip()
        wired = subprocess.check_output('cat /sys/class/net/eth0/operstate',
                                        shell=True).decode('utf-8').strip('\n')
        if wired == 'up':
            network = 'Ethernet'
        elif ssid:
            if helpers.access_point():
                network = 'Wifi access point'
            else:
                network = 'Wifi : ' + ssid
        else:
            network = 'Not Connected'

        pos_device = self.get_pos_device_status()
        iot_device = []

        if not iot_devices:
            for status in pos_device:
                if pos_device[status]['status'] == 'connected':
                    iot_device.append({
                        'name':
                        status,
                        'type':
                        'device',
                        'message':
                        ' '.join(pos_device[status]['messages'])
                    })

        for device in iot_devices:
            iot_device.append({
                'name':
                iot_devices[device].device_name + ' : ' +
                str(iot_devices[device].data['value']),
                'type':
                iot_devices[device].device_type,
                'message':
                iot_devices[device].device_identifier +
                iot_devices[device].get_message()
            })

        return {
            'hostname': hostname,
            'ip': helpers.get_ip(),
            'mac': ":".join(i + next(h) for i in h),
            'iot_device_status': iot_device,
            'server_status': helpers.get_odoo_server_url() or 'Not Configured',
            'six_terminal': self.get_six_terminal(),
            'network_status': network,
            'version': helpers.get_version(),
        }
Beispiel #5
0
 def index(self):
     wifi = Path.home() / 'wifi_network.txt'
     remote_server = Path.home() / 'odoo-remote-server.conf'
     if (wifi.exists() == False or remote_server.exists() == False) and helpers.access_point():
         return configure_wizard_template.render({
             'title': 'Configure IoT Box',
             'breadcrumb': 'Configure IoT Box',
             'loading_message': 'Configuring your IoT Box',
             'ssid': helpers.get_wifi_essid(),
             'server': helpers.get_odoo_server_url(),
             'hostname': subprocess.check_output('hostname').decode('utf-8'),
             })
     else:
         return homepage_template.render(self.get_homepage_data())