def reg_hwid(self): # choose mac address as HWID for the moment self.hwid = common.get_mac_addr() print 'hwid:', self.hwid WrtGateway.s_hwid = self.hwid # if hwid has been registered, make sure it won't be registered again if common.is_hwid_existed(self.hwid) == True: return body = '<RegisterHWSN><HWSN>' + self.hwid + \ '</HWSN><User>Admin</User>'\ '<Password>admin</Password></RegisterHWSN>' header = {'Content-type': 'text/xml'} print 'registering hwid...' try: ret = restful.method_post(init.url_registerHW, body, header) if ret.split('>')[2].split('<')[0] == 'true': print 'register hwid ok' common.wr_settings(self.hwid, '', 0) common.wr_settings('', '', 1) except: # repeating registering hwid will raise exception print 'hwid already exists or network off' common.wr_settings(self.hwid, '', 0) common.wr_settings('', '', 1)
def reg_hwid(self): # register hardware id #self.hwid = '200000' self.hwid = common.get_mac_addr() print 'hwid:',self.hwid WrtGateway.s_hwid = self.hwid if common.is_hwid_existed(self.hwid) == True: return body = '<RegisterHWSN><HWSN>' + self.hwid + \ '</HWSN><User>Admin</User>'\ '<Password>admin</Password></RegisterHWSN>' header = {'Content-type':'text/xml'} print 'registering hwid...' try: ret = restful.method_post(init.url_registerHW,body,header) if ret.split('>')[2].split('<')[0] == 'true': print 'register hwid ok' common.wr_settings(self.hwid,'',0) common.wr_settings('','',1) except: # repeating registering hwid will raise exception print 'hwid already exists or network off' common.wr_settings(self.hwid,'',0) common.wr_settings('','',1)
def __init__(self): self.enable_sleep = False if len(sys.argv) > 1 and sys.argv[1] == "--sleep": self.enable_sleep = True self.last_sleep_metric = True # Needs to be true in order to trigger first update of no sleep intent self.can_sleep = False macaddr = common.get_mac_addr() if macaddr == '': logging.error("Could not retrieve mac address of machine") else: logging.info ("Executing: " + self.GMETRIC_PATH + " -n \"MACADDR\" -v \"" + macaddr + "\" -t \"string\"") subprocess.Popen([self.GMETRIC_PATH, '-n', 'MACADDR', '-v', macaddr, '-t', 'string']) self.can_sleep = True