def list_credential(self): return list_credential_template.render({ 'title': "Odoo's IoT Box - List credential", 'breadcrumb': 'List credential', 'db_uuid': helpers.read_file_first_line('odoo-db-uuid.conf'), 'enterprise_code': helpers.read_file_first_line('odoo-enterprise-code.conf'), })
def send_alldevices(self): """ This method send IoT Box and devices informations to Odoo database """ server = helpers.get_odoo_server_url() if server: subject = helpers.read_file_first_line('odoo-subject.conf') if subject: domain = helpers.get_ip().replace('.', '-') + subject.strip('*') else: domain = helpers.get_ip() iot_box = { 'name': socket.gethostname(), 'identifier': helpers.get_mac_address(), 'ip': domain, 'token': helpers.get_token(), 'version': helpers.get_version(), } devices_list = {} for device in iot_devices: identifier = iot_devices[device].device_identifier devices_list[identifier] = { 'name': iot_devices[device].device_name, 'type': iot_devices[device].device_type, 'manufacturer': iot_devices[device].device_manufacturer, 'connection': iot_devices[device].device_connection, } data = { 'params': { 'iot_box': iot_box, 'devices': devices_list, } } # disable certifiacte verification urllib3.disable_warnings() http = urllib3.PoolManager(cert_reqs='CERT_NONE') try: http.request( 'POST', server + "/iot/setup", body=json.dumps(data).encode('utf8'), headers={ 'Content-type': 'application/json', 'Accept': 'text/plain', }, ) except Exception as e: _logger.error('Could not reach configured server') _logger.error('A error encountered : %s ' % e) else: _logger.warning('Odoo server not set')
def get_six_terminal(self): terminal_id = helpers.read_file_first_line('odoo-six-payment-terminal.conf') return terminal_id or 'Not Configured'
eftapi.EFT_QueryStatus(self.mpd_session) eftapi.EFT_Complete(self.mpd_session, 1) # Needed to read messages from driver device_status = ctypes.c_long() eftapi.EFT_GetDeviceStatusCode(self.mpd_session, ctypes.byref(device_status)) return device_status.value in [0, 1] conn = cups_connection() PPDs = conn.getPPDs() printers = conn.getPrinters() cups_lock = Lock() # We can only make one call to Cups at a time mpdm = MPDManager() terminal_id = helpers.read_file_first_line('odoo-six-payment-terminal.conf') if terminal_id: try: subprocess.check_output(["pidof", "eftdvs"]) # Check if MPD server is running except subprocess.CalledProcessError: subprocess.Popen(["eftdvs", "/ConfigDir", "/usr/share/eftdvs/"]) # Start MPD server eftapi = ctypes.CDLL("eftapi.so") # Library given by Six mpdm.daemon = True mpdm.start() else: try: subprocess.check_call(["pkill", "-9", "eftdvs"]) # Check if MPD server is running except subprocess.CalledProcessError: