Beispiel #1
0
    def post(self, uid, tid):
        if self.req_user and self.req_user['myself'] is False:
            raise HTTPError(400, "No operation permission")
        thing_key = self.temp['key']
        wio = Wio(thing_key)
        try:
            result = yield wio.add_ota(self.temp['board_type_id'])
        except Exception as e:
            gen_log.error(e)
            raise HTTPError(400, "Trigger OTA is failure, {}".format(str(e)))

        ota = yield self.db_temp.update_ota(
            tid, {
                "status": result['status'],
                "status_text": result['status_text']
            })
        self.set_status(202)
        self.add_header("Location", "")  # TODO, get status url
        self.finish(jsonify(ota))

        IOLoop.current().add_callback(self.get_ota, tid, thing_key)
Beispiel #2
0
    def post(self, uid, tid):
        temp = yield self.db_temp.get_temp(tid)
        if temp is None:
            gen_log.error("Not this temp")
            self.set_status(400)
            self.finish({"error": "Not this temp"})
            return

        thing_key = temp['key']
        wio = Wio(thing_key)
        try:
            result = yield wio.add_ota()
        except Exception as e:
            gen_log.error(e)
            self.set_status(400)
            self.finish({"error": "Trigger OTA is failure."})
            return

        ota = yield self.db_temp.update_ota(tid, {"status": result['status'], "status_text": result['status_text']})
        self.set_status(202)
        self.add_header("Location", "")  # TODO, get status url
        self.finish(jsonify(ota))

        IOLoop.current().add_callback(self.get_ota, tid, thing_key)