def net_resource_run(self, rrid): """ Calls and executes net resource args: rrid : network resource ID calls : /rest/networking/resources/<rrid> """ rid = self._net_resource_get_id(rrid) if rid is None: raise IsyValueError("net_resource_run : bad network resources ID : " + rrid) xurl = "/rest/networking/resources/{!s}".format(rid) if self.debug & 0x02: print("wol : xurl = " + xurl) resp = self._getXMLetree(xurl) # self._printXML(resp) if resp is None or resp.attrib["succeeded"] != 'true': raise IsyResponseError("ISY network resources error : rid=" + str(rid))
def net_wol(self, wid): """ Send Wake On LAN to registared wol ID args: wid : WOL resource ID calls : /rest/networking/wol/<wol_id> """ wol_id = self._net_wol_get_id(wid) # wol_id = str(wid).upper() if wol_id is None: raise IsyValueError("bad wol ID : " + wid) xurl = "/rest/networking/wol/" + wol_id if self.debug & 0x02: print("wol : xurl = " + xurl) resp = self._getXMLetree(xurl) # self._printXML(resp) if resp.attrib["succeeded"] != 'true': raise IsyResponseError("ISY command error : cmd=wol wol_id=" \ + str(wol_id))
def format_node_addr(naddr): if not isinstance(naddr, str): raise IsyValueError("{0} arg not string".format(__name__)) addr_el = naddr.upper().split() a = "{0:0>2}' '{1:0>2}' '{2:0>2}' ".format(*addr_el) return a
def soapcomm(self, cmd, **kwargs): """ takes a command name and a list of keyword arguments. each keyword is converted into a xml element """ if not isinstance(cmd, str) or not len(cmd): raise IsyValueError("SOAP Method name missing") if self.debug & 0x02: print("sendcomm: ", cmd) soap_cmd = self._gensoap(cmd, **kwargs) xurl = self.baseurl + "/services" if self.debug & 0x02: print("xurl = ", xurl) print("soap_cmd = ", soap_cmd) req = URLRequest(xurl, soap_cmd, {'Content-Type': 'application/xml; charset="utf-8"'}) data = "" try: res = self._opener.open(req, None) data = res.read() if self.debug & 0x200: print("res.getcode() ", res.getcode(), len(data)) print("data ", data) res.close() except HTTPError as e: self.error_str = str("Reponse Code: {0} : {1} {2}").format( e.code, xurl, cmd) if ((cmd == "DiscoverNodes" and e.code == 803) or (cmd == "CancelNodesDiscovery" and e.code == 501) # or (cmd == "RemoveNode" and e.code == 501) ): if self.debug & 0x02: print("spacial case: {0} : {1}".format(cmd, e.code)) print("e.code = ", e.code) print("e.msg = ", e.msg) print("e.hdrs = ", e.hdrs) print("e.filename = ", e.filename) print("e.code = ", type(e.code), e.code) print("\n") return e.read() if self.debug & 0x202: print("e.code = ", type(e.code), e.code) # print "e.read = ", e.read() print("e = ", e) print("data = ", data) mess = "{!s}: {!s}: {!s}".format(cmd, kwargs, e.code) # This a messy and should change raise IsySoapError(mess, httperr=e) else: if len(self.error_str): self.error_str = "" if self.debug & 0x200: print(data) return data