Esempio n. 1
0
File: main.py Progetto: Vauxoo/odoo
    def load_drivers(self):
        subprocess.check_call("sudo mount -o remount,rw /", shell=True)
        subprocess.check_call("sudo mount -o remount,rw /root_bypass_ramdisks", shell=True)

        mac = subprocess.check_output("/sbin/ifconfig eth0 |grep -Eo ..\(\:..\){5}", shell=True).decode('utf-8').split('\n')[0]

        #response = requests.get(url, auth=(username, db_uuid.split('\n')[0]), stream=True)
        server = get_odoo_server_url()
        if server:
            urllib3.disable_warnings()
            pm = urllib3.PoolManager(cert_reqs='CERT_NONE')
            resp = False
            server = server + '/iot/get_drivers'
            try:
                resp = pm.request('POST',
                                   server,
                                   fields={'mac': mac})
            except Exception as e:
                _logger.error('Could not reach configured server')
                _logger.error('A error encountered : %s ' % e)
            if resp and resp.data:
                zip_file = zipfile.ZipFile(io.BytesIO(resp.data))
                zip_file.extractall(get_resource_path('hw_drivers', 'drivers'))
        subprocess.check_call("sudo service odoo restart", shell=True)
        subprocess.check_call("sudo mount -o remount,ro /", shell=True)
        subprocess.check_call("sudo mount -o remount,ro /root_bypass_ramdisks", shell=True)

        return "<meta http-equiv='refresh' content='20; url=http://" + get_ip() + ":8069/list_drivers'>"
Esempio n. 2
0
    def load_drivers(self):
        subprocess.check_call("sudo mount -o remount,rw /", shell=True)
        subprocess.check_call("sudo mount -o remount,rw /root_bypass_ramdisks",
                              shell=True)

        mac = subprocess.check_output(
            "/sbin/ifconfig eth0 |grep -Eo ..\(\:..\){5}",
            shell=True).decode('utf-8').split('\n')[0]

        #response = requests.get(url, auth=(username, db_uuid.split('\n')[0]), stream=True)
        server = get_odoo_server_url()
        if server:
            urllib3.disable_warnings()
            pm = urllib3.PoolManager(cert_reqs='CERT_NONE')
            resp = False
            server = server + '/iot/get_drivers'
            try:
                resp = pm.request('POST', server, fields={'mac': mac})
            except Exception as e:
                _logger.error('Could not reach configured server')
                _logger.error('A error encountered : %s ' % e)
            if resp and resp.data:
                zip_file = zipfile.ZipFile(io.BytesIO(resp.data))
                zip_file.extractall(get_resource_path('hw_drivers', 'drivers'))
        subprocess.check_call("sudo service odoo restart", shell=True)
        subprocess.check_call("sudo mount -o remount,ro /", shell=True)
        subprocess.check_call("sudo mount -o remount,ro /root_bypass_ramdisks",
                              shell=True)

        return "<meta http-equiv='refresh' content='20; url=http://" + get_ip(
        ) + ":8069/list_drivers'>"
Esempio n. 3
0
File: main.py Progetto: wpareja/odoo
 def add_six_payment_terminal(self, terminal_id):
     subprocess.check_call(["sudo", "mount", "-o", "remount,rw", "/"])
     path = Path.home() / 'odoo-six-payment-terminal.conf'
     path.write_text(terminal_id)
     subprocess.check_call(["sudo", "service", "odoo", "restart"])
     subprocess.check_call(["sudo", "mount", "-o", "remount,ro", "/"])
     return 'http://' + get_ip() + ':8069'
Esempio n. 4
0
    def clear_drivers_list(self):
        os.system(
            get_resource_path(
                'point_of_sale',
                'tools/posbox/configuration/clear_drivers_list.sh'))

        return "<meta http-equiv='refresh' content='0; url=http://" + get_ip(
        ) + ":8069/list_drivers'>"
Esempio n. 5
0
File: main.py Progetto: wpareja/odoo
 def clear_six_payment_terminal(self):
     subprocess.check_call(["sudo", "mount", "-o", "remount,rw", "/"])
     path = Path.home() / 'odoo-six-payment-terminal.conf'
     if path.exists():
         path.unlink()
     subprocess.check_call(["sudo", "service", "odoo", "restart"])
     subprocess.check_call(["sudo", "mount", "-o", "remount,ro", "/"])
     return "<meta http-equiv='refresh' content='0; url=http://" + get_ip(
     ) + ":8069'>"
Esempio n. 6
0
File: main.py Progetto: wpareja/odoo
    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 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': get_ip(),
            'mac': ":".join(i + next(h) for i in h),
            'iot_device_status': iot_device,
            'server_status': get_odoo_server_url() or 'Not Configured',
            'six_terminal': self.get_six_terminal(),
            'network_status': network,
        }
Esempio n. 7
0
 def connect_to_server(self, token, iotname):
     url = token.split('|')[0]
     token = token.split('|')[1]
     reboot = 'reboot'
     subprocess.check_call([
         get_resource_path(
             'point_of_sale',
             'tools/posbox/configuration/connect_to_server.sh'), url,
         iotname, token, reboot
     ])
     return 'http://' + get_ip() + ':8069'
Esempio n. 8
0
File: main.py Progetto: Vauxoo/odoo
    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 access_point():
                network = 'Wifi access point'
            else:
                network = 'Wifi : ' + ssid
        else:
            network = 'Not Connected'

        pos_device = self.get_pos_device_status()
        iot_device = []
        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': get_ip(),
            'mac': ":".join(i + next(h) for i in h),
            'iot_device_status': iot_device,
            'server_status': get_odoo_server_url() or 'Not Configured',
            'network_status': network,
            }
Esempio n. 9
0
File: main.py Progetto: Vauxoo/odoo
def access_point():
    return get_ip() == '10.11.12.1'
Esempio n. 10
0
File: main.py Progetto: Vauxoo/odoo
 def connect_to_server(self, token, iotname):
     url = token.split('|')[0]
     token = token.split('|')[1]
     reboot = 'reboot'
     subprocess.check_call([get_resource_path('point_of_sale', 'tools/posbox/configuration/connect_to_server.sh'), url, iotname, token, reboot])
     return 'http://' + get_ip() + ':8069'
Esempio n. 11
0
File: main.py Progetto: Vauxoo/odoo
    def clear_drivers_list(self):
        os.system(get_resource_path('point_of_sale', 'tools/posbox/configuration/clear_drivers_list.sh'))

        return "<meta http-equiv='refresh' content='0; url=http://" + get_ip() + ":8069/list_drivers'>"
Esempio n. 12
0
def access_point():
    return get_ip() == '10.11.12.1'