コード例 #1
0
ファイル: main.py プロジェクト: douyou/meican
def order(meican):
    try:
        order_week = ConfigUtil.instance().order_week
        cur_week = str(DateUtil.curr_week())
        if cur_week not in order_week:
            critical(
                "meican | order week not in config!!!!!!!!!!!!, cur_week:<%s>"
                % cur_week)
            return
        info("meican |begin order")
        meican.order()
    except Exception as e:
        info(traceback.format_exc())
コード例 #2
0
    def login(self):
        code = self.load_mc_cookies()
        info("meican | init | has cookies:<%s>"%code)
        if code == False:
            code = self.login_account(self.username, self.password)
            if code != ErrCode.ok:
                error("meican | login error:<%s>"%Desc[code])
            else:
                self.save_mc_cookies()
                self.login_ok = True
        else:
            self.login_ok = True

        if self.login_ok:
            # mc_time_info = self.mc_time()
            # info("meican |server time | time:<%s>"%(milli_strftime(mc_time_info.serverTime, "%Y-%m-%d %H:%M:%S")))
            show_info = self.account_show_info()
            info("meican | login info | username:<%s>"%(show_info.username))
            self.close_time_list = self.tab_close_time()
            # info("meican | order limit times | <%s>"%(str(self.close_time_list)))
        return self.login_ok
コード例 #3
0
    def order_pack(self):
	code, tabs = self.available_tab() # all 餐区
        if code != ErrCode.ok:
            return code
	for tab in tabs:
            user_tab_corp = tab['userTab']['corp']
            address_uid = user_tab_corp['addressList'][0]['uniqueId']
            price_limit_cent = user_tab_corp['priceLimitInCent']

	    dish_ids = []
	    desc_obj = None
            code, re_lsts = self.recommends_dish_list(tab)
            if code == ErrCode.ok:
                dish_ids, desc_obj = self.group_dish(price_limit_cent, re_lsts)
            if empty_list(dish_ids):
                dish_ids, desc_obj = self.group_dish(price_limit_cent, self.restaurant_dish_list(tab))
            if empty_list(dish_ids):
                return ErrCode.money_dish_error
            resp = self.order_request(tab, dish_ids, address_uid)
	    print resp
            if resp["status"] == "SUCCESSFUL":
                info("meican | order success | <%s>"%desc_obj.get_desc())
        return ErrCode.ok
コード例 #4
0
ファイル: main.py プロジェクト: douyou/meican
def do_job():
    try:
        info("I'm working on : <%s>" % datetime.datetime.now())
    except Exception as e:
        info(traceback.format_exc())
コード例 #5
0
ファイル: main.py プロジェクト: douyou/meican
        info("meican |begin order")
        meican.order()
    except Exception as e:
        info(traceback.format_exc())


def do_job():
    try:
        info("I'm working on : <%s>" % datetime.datetime.now())
    except Exception as e:
        info(traceback.format_exc())


if __name__ == '__main__':
    install_log()
    info("start meican robot")

    meican = None
    login_ok = False
    if has_cookies():
        meican = MeiCan('', '')
        login_ok = meican.login()
    else:
        while not login_ok:
            username = raw_input('[ Enter meican email ]:')
            password = raw_input('[ Enter meican password ]:')
            meican = MeiCan(username, password)
            login_ok = meican.login()
        clear_output()

    schedule.every(1).day.at("06:20").do(order, meican)
コード例 #6
0
 def order(self):
     code = self.order_pack()
     if code != ErrCode.ok:
         info("meican | order failure, errdesc:<%s>"%Desc[code])
     return code