当前位置: 首页>>代码示例>>Python>>正文


Python Database.read_sms_date方法代码示例

本文整理汇总了Python中common.database.Database.read_sms_date方法的典型用法代码示例。如果您正苦于以下问题:Python Database.read_sms_date方法的具体用法?Python Database.read_sms_date怎么用?Python Database.read_sms_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.database.Database的用法示例。


在下文中一共展示了Database.read_sms_date方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: api

# 需要导入模块: from common.database import Database [as 别名]
# 或者: from common.database.Database import read_sms_date [as 别名]

#.........这里部分代码省略.........
            else:
                cherrypy.response.status = 400

        if arg == "receiverouting":
            try:
                wisglobals.rdb.merge_routing(data)
            except error.DatabaseError as e:
                smsgwglobals.wislogger.debug(e.message)

        if arg == "requestrouting":
            if data["get"] != "peers":
                cherrypy.response.status = 400
                return

            smsgwglobals.wislogger.debug("Sending routing table to you")
            try:
                erg = wisglobals.rdb.read_routing()
                jerg = json.dumps(erg)
                data = GlobalHelper.encodeAES(jerg)
                return data

            except error.DatabaseError as e:
                smsgwglobals.wislogger.debug(e.message)

        if arg == "managemodem":
            try:
                if data["action"] == "register":
                    smsgwglobals.wislogger.debug("managemodem register")
                    smsgwglobals.wislogger.debug(wisglobals.wisid)

                    # add wisid to data object
                    data["wisid"] = wisglobals.wisid

                    # store date in routing table
                    wisglobals.rdb.write_routing(data)

                    # call receiverouting to distribute routing
                    Helper.receiverouting()

                elif data["action"] == "unregister":
                    smsgwglobals.wislogger.debug("managemodem unregister")
                    wisglobals.rdb.change_obsolete(data["routingid"], 14)
                    Helper.receiverouting()
                else:
                    return False
            except error.DatabaseError as e:
                smsgwglobals.wislogger.debug(e.message)

        if arg == "deligatesms":
            if "sms" in data:
                smsgwglobals.wislogger.debug(data["sms"])
                try:
                    sms = Smstransfer(**data["sms"])
                    sms.smsdict["status"] = 1
                    sms.writetodb()
                    self.triggerwatchdog()
                except error.DatabaseError:
                    cherrypy.response.status = 400
            else:
                cherrypy.response.status = 400

        if arg == "router":
            if data["action"] == "status":
                smsgwglobals.wislogger.debug("API: " + data["action"])
                if wisglobals.routerThread is None:
                    cherrypy.response.status = 200
                    data = GlobalHelper.encodeAES('{"ROUTER":"noobject"}')
                    return data

                if wisglobals.routerThread.isAlive():
                    cherrypy.response.status = 200
                    data = GlobalHelper.encodeAES('{"ROUTER":"alive"}')
                    return data
                else:
                    cherrypy.response.status = 200
                    data = GlobalHelper.encodeAES('{"ROUTER":"dead"}')
                    return data

        if arg == "getsms":
            if data["get"] != "sms":
                cherrypy.response.status = 400
                return

            if "date" in data:
                date = data["date"]
                smsgwglobals.wislogger.debug("API: " + date)
            else:
                date = None

            smsgwglobals.wislogger.debug("Sending SMS Table")
            smsgwglobals.wislogger.debug("Sending SMS Table date: " + str(date))
            try:
                db = Database()
                erg = db.read_sms_date(date=date)
                jerg = json.dumps(erg)
                data = GlobalHelper.encodeAES(jerg)
                return data

            except error.DatabaseError as e:
                smsgwglobals.wislogger.debug(e.message)
开发者ID:haouach,项目名称:smsgateway,代码行数:104,代码来源:wis.py


注:本文中的common.database.Database.read_sms_date方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。