本文整理汇总了Python中mytime.MyTime.getTheTimeNow方法的典型用法代码示例。如果您正苦于以下问题:Python MyTime.getTheTimeNow方法的具体用法?Python MyTime.getTheTimeNow怎么用?Python MyTime.getTheTimeNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mytime.MyTime
的用法示例。
在下文中一共展示了MyTime.getTheTimeNow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getMenu
# 需要导入模块: from mytime import MyTime [as 别名]
# 或者: from mytime.MyTime import getTheTimeNow [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]}
}
#.........这里部分代码省略.........