コード例 #1
0
    def get(self):
        op_log_dao = self.settings["op_log_dao"]
        #ret = {}
        start_time = None
        end_time = None
        try:
            imei = self.get_argument("imei")
            start = self.get_argument("start")
            end = self.get_argument("end", None)
            start_time = utils.str2datetime(start, "%Y-%m-%d %H:%M:%S")
            if end is not None:
                end_time = utils.str2datetime(end, "%Y-%m-%d %H:%M:%S")
        except Exception as e:
            self.write("arg error ")
            return

        op_ret = yield op_log_dao.get_log_info(start_time, end_time, imei,
                                               ("imei", "content", "log_time"))
        ret = "<html>"
        for item in op_ret:
            ret += " 【log_time】:%s 【imei】:%s 【content】:%s <br><br>" % (
                utils.date2str(
                    item["log_time"]), item["imei"], item["content"])
            #ret
        ret += "</html>"
        self.write(ret)
コード例 #2
0
    def _deal_request(self):
        logging.debug("GetActivityInfo, %s", self.dump_req())

        self.set_header("Content-Type", "application/json; charset=utf-8")
        pet_dao = self.settings["pet_dao"]
        conf = self.settings["appconfig"]

        res = {"status": error_codes.EC_SUCCESS}

        uid = None
        token = None
        pet_id = -1
        start_date = None
        end_date = None

        try:
            uid = int(self.get_argument("uid"))
            token = self.get_argument("token")
            st = yield self.check_token("GetActivityInfo", res, uid, token)
            if not st:
                return

            pet_id = int(self.get_argument("pet_id", -1))
            start_date = self.get_argument("start_date", "2015-04-12")
            if start_date is not None:
                start_date = utils.str2datetime(start_date + " 00:00:00",
                                                "%Y-%m-%d %H:%M:%S")
            end_date = self.get_argument("end_date", "2015-05-12")
            if end_date is not None:
                end_date = utils.str2datetime(end_date + " 23:59:59",
                                              "%Y-%m-%d %H:%M:%S")
        except Exception, e:
            logging.warning("GetActivityInfo, invalid args, %s",
                            self.dump_req())
            res["status"] = error_codes.EC_INVALID_ARGS
            self.res_and_fini(res)
            return
コード例 #3
0
    def get(self):
        op_log_dao = self.settings["op_log_dao"]
        #ret = {}
        start_time = None
        end_time = None
        try:
            imei = self.get_argument("imei")
            start = self.get_argument("start")
            end = self.get_argument("end", None)
            start_time = utils.str2datetime(start, "%Y-%m-%d %H:%M:%S")
            if end is not None:
                end_time = utils.str2datetime(end, "%Y-%m-%d %H:%M:%S")
            else:
                end_time = start_time + datetime.timedelta(days=1)

        except Exception as e:
            self.render('log.htm',
                        host=self.settings["proc_conf"].get("log_host", None),
                        servers=self.settings["proc_conf"].get(
                            "log_servers", None))
            logger.warning("arg error,error:%s", str(e))
            #self.write("arg error ")
            return

        self.set_header("Access-Control-Allow-Origin", "*")

        op_ret = yield op_log_dao.get_log_info(start_time, end_time, imei,
                                               ("imei", "content", "log_time"))
        ret = "<html>"
        for item in op_ret:
            ret += " 【log_time】:%s 【imei】:%s 【content】:%s <br><br>" % (
                utils.date2str(
                    item["log_time"]), item["imei"], item["content"])
            #ret
        ret += "</html>"
        self.write(ret)