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


Python MyTime.getTheTimeNowPlus方法代码示例

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


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

示例1: storeAllMenus

# 需要导入模块: from mytime import MyTime [as 别名]
# 或者: from mytime.MyTime import getTheTimeNowPlus [as 别名]
    def storeAllMenus(tot_days):
        db.delete(db.GqlQuery("SELECT * FROM MenuDatabase"))
        successCode = "Updated: \n"
        for dh in UrlRepo.dhs:
            #2 = Today and tmrw
            for i in range(tot_days):
                d = MyTime.getTheTimeNowPlus(i)
                menu = MyMenuParser.getMenuFor(dh, d)
                successCode += MenuStorage.store(dh, menu, d)
                successCode += UrlRepo.getUrl(dh, d) + "\n"

        return successCode[:-2] #[:-2] removes the last ", "
开发者ID:Pancia,项目名称:slug-menu-server,代码行数:14,代码来源:storemenu.py

示例2: getMenu

# 需要导入模块: from mytime import MyTime [as 别名]
# 或者: from mytime.MyTime import getTheTimeNowPlus [as 别名]
    def getMenu(self):
        dh = self.request.get("dh")
        self.response.headers["Content-Type"] = "application/json"

        if self.request.get('time') == "true":
            self.response.out.write(datetime.now())
            self.response.out.write("\n")
            self.response.out.write(MyTime.getTheTimeNow())
            self.response.out.write("\n")

        #"Hack" to allow first-time storage of menus, 
        #where necessary url-command is: slugmenu.appspot.com/getmenu.py?exe=storeAllMenus[&num_to_store=#]
        if self.request.get('exe') == "storeAllMenus":
            num_dh = 8;
            if self.request.get('num_to_store') != "":
                num_dh = self.request.get('num_to_store')
            self.response.out.write( MenuStorage.storeAllMenus(num_dh) )
            return

        if dh == "":
            self.response.out.write( 
                json.dumps(
                    {"request":{"success":0}, 
                    "response":{"message":"Error! Null Dining Hall!"}
                    }
                )
            )
            return

        if dh not in UrlRepo.dhs:
            self.response.out.write( 
                json.dumps(
                    {"request":{"success":0}, 
                    "response":{"message":"Invalid Dining Hall: "+dh}
                    }
                )
            )
            return

        #For testing!
        
        if self.request.get('debug') == "url":
            self.response.out.write("#URL")
            self.response.out.write("\n")
            self.response.out.write(UrlRepo.getUrl(dh, MyTime.getTheTimeNow()))
            self.response.out.write("\n")

        if self.request.get('debug') == "simple":
            self.response.out.write("#MENU")
            self.response.out.write("\n")
            self.response.out.write(UrlRepo.getUrl(dh, MyTime.getTheTimeNow()))
            self.response.out.write("\n")
            self.response.out.write(
                json.dumps(
                    MyMenuParser.getMenuFor(dh, MyTime.getTheTimeNow())
                    , indent = 4, sort_keys = True
                ))
            self.response.out.write("\n")

        if self.request.get('debug') == "verbose":
            self.response.out.write("#HTML")
            self.response.out.write("\n")
            html = MyMenuParser.getHtmlFrom( UrlRepo.getUrl(dh, MyTime.getTheTimeNow()) )
            self.response.out.write(html)
            self.response.out.write("\n")

        dtdate = 0
        if self.request.get('dtdate') != '':
                dtdate = int(self.request.get('dtdate'))
                if dtdate > 7:
                    self.response.out.write(
                        json.dumps(
                            {"request":{"success":0}, 
                            "response":{"message":"Cannot get more than 1 week ahead!"}
                            }
                        )
                    )
                    return
        
        q = db.GqlQuery(
            "SELECT * FROM MenuDatabase " +
            "WHERE dh=:1 AND time=:2",
                dh, MyTime.getTheTimeNowPlus(dtdate))

        json_str = ''
        for i in q:
            json_str += i.menu

        try:
            self.response.out.write( 
                json.dumps(
                    json.loads(json_str), indent=4, sort_keys=True
                )
            )
        except ValueError as ve:
            self.response.out.write( 
                json.dumps(
                    {"request":{"success":0}, 
                    "response":{"message":ve.args[0]}
                    }
#.........这里部分代码省略.........
开发者ID:Pancia,项目名称:slug-menu-server,代码行数:103,代码来源:getmenu.py

示例3: main

# 需要导入模块: from mytime import MyTime [as 别名]
# 或者: from mytime.MyTime import getTheTimeNowPlus [as 别名]
def main():
    for dh in UrlRepo.dhs:
        d = MyTime.getTheTimeNowPlus(8)
        menu = MyMenuParser.getMenuFor(dh, d)
        MenuStorage.store(dh, menu, d)
开发者ID:Pancia,项目名称:slug-menu-server,代码行数:7,代码来源:storemenu.py


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