def _cbCvtReply(self, msg, returnSignature): """ Converts a remote method call reply message into an appropriate callback value. """ if msg is None: return None if returnSignature != _NO_CHECK_RETURN: if not returnSignature: if msg.signature: raise error.RemoteError( 'Unexpected return value signature') else: if not msg.signature or msg.signature != returnSignature: msg = 'Expected "%s". Received "%s"' % ( str(returnSignature), str(msg.signature)) raise error.RemoteError( 'Unexpected return value signature: %s' % (msg, )) if msg.body is None or len(msg.body) == 0: return None # if not ( # isinstance(msg.body[0], six.string_types) and # msg.body[0].startswith('<!D') # ): # print('RET SIG', msg.signature, 'BODY:', msg.body) if len(msg.body) == 1 and not msg.signature[0] == '(': return msg.body[0] else: return msg.body
def RemoveInterface(self, interface_path): for i, path in enumerate(self._created_interfaces[:]): if path == interface_path: del self._created_interfaces[i] break else: raise error.RemoteError('fi.w1.wpa_supplicant1.InterfaceUnknown')
def CreateInterface(self, cfg): if not isinstance(cfg, dict): raise error.RemoteError('fi.w1.wpa_supplicant1.InvalidArgs') interface_name = cfg.get('Ifname', None) # required argument if interface_name is None: raise error.RemoteError('fi.w1.wpa_supplicant1.InvalidArgs') iface_path = self._valid_interfaces.get(interface_name) if not iface_path: raise error.RemoteError('fi.w1.wpa_supplicant1.UnknownError') if iface_path in self._created_interfaces: raise error.RemoteError('fi.w1.wpa_supplicant1.InterfaceExists') self._created_interfaces.append(iface_path) return iface_path
def errorReceived(self, merr): """ Called when an error message is received """ d, timeout = self._pendingCalls.get(merr.reply_serial, (None, None)) if timeout: timeout.cancel() if d: del self._pendingCalls[merr.reply_serial] e = error.RemoteError(merr.error_name) e.message = '' e.values = [] if merr.body: if isinstance(merr.body[0], six.string_types): e.message = merr.body[0] e.values = merr.body d.errback(e)
def GetInterface(self, interface_name): if interface_name in self._valid_interfaces: return self._valid_interfaces.get(interface_name) else: raise error.RemoteError('fi.w1.wpa_supplicant1.InterfaceUnknown')
def Disconnect(self): if self._current_network is None: raise error.RemoteError('fi.w1.wpa_supplicant1.NotConnected') else: self._current_network = None
def RemoveNetwork(self, network_path): if network_path in self._networks: del self._networks[network_path] else: raise error.RemoteError('fi.w1.wpa_supplicant1.NetworkUnknown')