示例#1
0
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"
示例#2
0
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')
示例#3
0
 def __init__(self, token):
     self.rP = RpCloud()
     self.arp = Arp()
     self.sys = SysRp()
     # Inicia la app
     self.start(token)
示例#4
0
def apiRegister(firstName, lastName, email, password):
    return RpCloud().register(firstName, lastName, email, password)
示例#5
0
def apiLogin(email, password):
    return RpCloud().checkLogin(email, password)
示例#6
0
 def __init__(self):
     self.rP = RpCloud()
     # Lo ejecutamos siempre, cada vez que instanciamos el objeto Arp
     self.update()
示例#7
0
 def __init__(self):
     self.conn = RaspberryDB()
     self.rP = RpCloud()
     self.arp = Arp()