class Run(object): def __init__(self, token): self.rP = RpCloud() self.arp = Arp() self.sys = SysRp() # Inicia la app self.start(token) def start(self, token): checked = self.rP.checkLogin(token) if (checked): # Consultamos el JSON actual (peticion ARP) generatedJson = self.sys.generateJson(token) # Ejecuta un hilo para montar y comprimir la imagen en el servidor threadOverHead1 = ThreadOverHead( token, "/mnt/img/uploads/minimalRaspyCloud.img") threadOverHead1.start() for pi in generatedJson.get("raspberryPi"): # Crea un hilo por cada raspberryPi hThread1 = Thread(token, pi.get("hostname"), pi.get("ip")) hThread1.start() return "Done" else: return "Invalid Token"
def application(request): # get the request path # print(request.path) # get the request host # print(request.host) # get the request method print(request.args.get('PATH_INFO')) arpObject = Arp() rpCloudObject = RpCloud() sysRpObject = SysRp() # Dispatcher is dictionary {<method_name>: callable} dispatcher['scanARP'] = arpObject.update dispatcher['getArpTable'] = arpObject.getTable dispatcher['login'] = rpCloudObject.login dispatcher['checkPassword'] = rpCloudObject.checkPassword dispatcher['checkLogin'] = rpCloudObject.checkLogin dispatcher['logout'] = rpCloudObject.logout dispatcher['getHostname'] = sysRpObject.getHostname dispatcher['reboot'] = sysRpObject.reboot dispatcher['setHostname'] = sysRpObject.setHostname dispatcher['generateJson'] = sysRpObject.generateJson dispatcher['storageJson'] = sysRpObject.storageJson response = JSONRPCResponseManager.handle(request.data, dispatcher) return Response(response.json, mimetype='application/json')
def __init__(self, token): self.rP = RpCloud() self.arp = Arp() self.sys = SysRp() # Inicia la app self.start(token)
def apiRegister(firstName, lastName, email, password): return RpCloud().register(firstName, lastName, email, password)
def apiLogin(email, password): return RpCloud().checkLogin(email, password)
def __init__(self): self.rP = RpCloud() # Lo ejecutamos siempre, cada vez que instanciamos el objeto Arp self.update()
def __init__(self): self.conn = RaspberryDB() self.rP = RpCloud() self.arp = Arp()