コード例 #1
0
def order_token():
    conf = config.Config()
    conf.load('./unit/test.xml')

    log = LOG()
    mongo = wx_mongo.WxMongo()
    log.setlogger('./test.log')
    mongo.start()

    refresher = order_notify.TokenRefresher()
    refresher.start_refresh(LOG().getlogger(), mongo, conf)
    time.sleep(60)
    refresher.stop_refresh()
コード例 #2
0
def main():
    settings = {
        'cookie_secret': '66oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=',
        'login_url': r'/login',
        'debug': True,
    }

    #load config xml and init logger
    conf = Config()
    conf.load('./wm.xml')
    LOG().setlogger('./wm.log')
    print conf.to_string()

    html_mgn().start(conf.bnum)
    wx_mongo.WxMongo().start()

    omgn = order_mgn.OrderMgn()
    omgn.init()
    onotify = order_notify.OrderNotify()
    onotify.start(wx_mongo.WxMongo(), conf)
    discount_mgn.DiscountMgn().start('./dc.xml')
    print 'server ip[%s],port[%d]' % (conf.ip, conf.port)
    # Start server
    app = tornado.web.Application([
        (r'/wm', WMHandler),
        (r'/openid', OrderHandler),
        (r'/shopping', ShoppingHandler),
        (r'/test', TestHandler),
    ], **settings)

    app.listen(conf.port)
    tornado.ioloop.IOLoop.instance().start()
コード例 #3
0
ファイル: tool.py プロジェクト: zyqlzr/simple_python
    def __init__(self, log_path, conf_path):
        LOG().setlogger(log_path)
        self.conf = Config()
        self.conf.load(conf_path)
        self.app_id = self.conf.appid
        self.app_secret = self.conf.appsecret
        self.mongo = wx_mongo.WxMongo()
        self.mongo.start()

        print 'app_id=%s,key=%s' % (self.app_id, self.app_secret)
        self.tool = api_tool.ApiTool(self.conf.appid, self.conf.appsecret,
                                     3000)
コード例 #4
0
ファイル: main.py プロジェクト: zyqlzr/simple_python
def main():
    settings = {
        'cookie_secret': '66oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=',
        'login_url': r'/login',
        'debug': True,
    }

    app = tornado.web.Application([
        (r'/main', MenuHandler),
    ], **settings)

    #print config.CGI_BIN_ACCESS_PATH_PREFIX + r'/interface/main'

    # Init logger
    LOG().setlogger('./wx.log')
    url_mgr.UrlMgr().init('./url.xml', LOG().getlogger())
    WxServer().start('./wx.xml')
    print 'server ip[%s],port[%d]' % (Config().ip, Config().port)
    # Start server
    app.listen(Config().port)
    tornado.ioloop.IOLoop.instance().start()
コード例 #5
0
ファイル: wx_server.py プロジェクト: zyqlzr/simple_python
 def start(self, path=None):
     if path is None:
         pinfo = 'input path is null of WxServer'
         raise err.IException(err.ErrCode.ParamErr, pinfo)
     self.conf.load(path)
     wx_mongo.WxMongo().start()
     self.log = LOG().getlogger()
     self.mprocessor = msg_processor.MsgProcessor(wx_mongo.WxMongo(),
                                                  self.log)
     self.eprocessor = event_processor.EventProcessor(
         wx_mongo.WxMongo(), self.log)
     self.wx_crypto = WXBizMsgCrypt(self.conf.token, self.conf.enc_key,
                                    self.conf.appid)
コード例 #6
0
def order_and_shopping():
    conf = config.Config()
    conf.load('./unit/test.xml')

    log = LOG()
    mongo = wx_mongo.WxMongo()
    log.setlogger('./test.log')
    mongo.start()

    oid = 'zhengyang'
    odtime = mytime.today2str()
    oprice = '14'
    ocounts = [1, 2, 3, 4, 5, 6, 7, 8]
    for i in ocounts:
        omenu = {}
        omenu['m'] = 'menu' + str(i)
        omenu['n'] = i
        omenu['t'] = 'title' + str(i)
        mongo.order.add_order(id=oid,
                              dtime=odtime,
                              count=i,
                              menu=omenu,
                              price=oprice)
        mongo.shopping.add_shopping(id=oid, dtime=odtime, count=i)

    nums = mongo.shopping.get_shopping(oid)
    print nums
    id_arrays = nums['history']
    for id in id_arrays:
        id_order = mongo.order.get_order(id)
        print id_order

    arr_len = len(id_arrays)
    print id_arrays[arr_len - 4]
    print id_arrays[arr_len - 3]
    print id_arrays[arr_len - 2]

    mongo.shopping.drop()
    mongo.order.drop()
コード例 #7
0
ファイル: order_mgn.py プロジェクト: zyqlzr/simple_python
 def init(self):
     self.log = LOG().getlogger()
     self.mongo = wx_mongo.WxMongo()
     self.counter = order_notify.OrderCounter()
     self.dm = discount_mgn.DiscountMgn()
コード例 #8
0
ファイル: mongo_test.py プロジェクト: zyqlzr/simple_python
def admin_logic_test():
    conf = config.Config()
    conf.load('./unit/test.xml')

    umgr = url_mgr.UrlMgr()
    umgr.init('./url.xml', None)
    umgr.load()

    print 'mongo ip=%s,port=%d' % (conf.mongo_ip, conf.mongo_port)
    mongo = WxMongo()
    mongo.start()
    LOG().setlogger('./log')
    log = LOG().getlogger()

    admin_logic = AdminLogic(mongo, log)
    eventp = EventProcessor(mongo, log)

    admin_coll = mongo.admin
    user_coll = mongo.user
    stat_coll = mongo.stat
    menu_coll = mongo.menu

    for aitem in admin_coll.coll.find():
        print aitem
    #admin_coll.coll.drop()
    fid = 'test_zhengyang'
    tid = 'zyqlzr'
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'sub')

    msg = ''
    print eventp.process_subscribe(msg, 'ifanyoyo', 'test_1')
    print eventp.process_subscribe(msg, 'ifanyoyo', 'test_2')
    print eventp.process_subscribe(msg, 'ifanyoyo', 'test_2')
    print eventp.process_subscribe(msg, 'ifanyoyo', 'test_3')
    print eventp.process_subscribe(msg, 'ifanyoyo', 'test_4')
    print eventp.process_unsubscribe(msg, 'ifanyoyo', 'test_3')
    print eventp.process_unsubscribe(msg, 'ifanyoyo', 'test_4')
    print eventp.process_unsubscribe(msg, 'ifanyoyo', 'test_5')

    today = mytime.today2str()
    menu_coll.add_menu(name='menu_1', day=today, price=10, title=FOOD_1, 
            url='http://127.0.0.1/menu1', info='balabala1', clock=0)
    menu_coll.add_menu(name='menu_2', day=today, price=10, title=FOOD_2, 
            url='http://127.0.0.1/menu2', info='balabala2', clock=0)
    menu_coll.add_menu(name='menu_3', day=today, price=10, title=FOOD_3, 
            url='http://127.0.0.1/menu3', info='balabala3', clock=0)


    admin_coll.add_admin(user='******', pri=10, name='jianglili')
    #admin_coll.add_admin(user='******', pri=8, name='jiangzifa')
    #admin_coll.add_admin(user='******', pri=5, name='zhangsan')
    #admin_coll.add_admin(user='******', pri=5, name='lisi')
    #admin_coll.add_admin(user='******', pri=0, name='wangwu')
    #admin_coll.add_admin(user='******', pri=0, name='zhaoliu')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'add admin x351575427 jiangzifa')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'add employee employee_1 zhangsan')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'add employee employee_2 lisi')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'add employee employee_3 zhengqi')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'add employee employee_4 zhengqi')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'add client client_1 wangwu')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'add client client_2 zhaoliu')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'add client client_3 zhaoliu')

    for uitem in user_coll.coll.find():
        print uitem
    for sitem in stat_coll.coll.find():
        print sitem
    for aitem in admin_coll.coll.find():
        print aitem

    print admin_logic.process_text(fid, admin.PRI_ROOT, 'sub')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'sub +')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'sub -')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'unsub')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'unsub +')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'unsub -')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'unsub')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'menu')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'menu +')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'menu -')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'list all')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'list admin')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'list employee')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'list client')

    print admin_logic.process_text(fid, admin.PRI_ROOT, 'del wx employee_2')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'del name zhaoliu')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'del employee_4 zhengqi')

    print admin_logic.process_text(fid, admin.PRI_ROOT, 'list employee')
    print admin_logic.process_text(fid, admin.PRI_ROOT, 'list client')

    admin_coll.coll.drop()
    user_coll.coll.drop()
    stat_coll.coll.drop()
    menu_coll.coll.drop()