def get(self): Temp4Get = dict() MST = MyShiftTime() state = MST.IsOrderAvbl() Temp4Get['POST'] = False Temp4Get['Avbl2Order'] = state['Avbl'] Temp4Get['DinnerList'] = getTodayDinnerList() #============================================================= _UserTime = strftime('%Y/%m/%d %a %H:%M:%S') _UserIp = self.request.remote_ip if _UserIp in Member_List.keys(): _UserName = Member_List[_UserIp] else: _UserName = '******' log = '{}, {}, {}\n'.format(_UserTime, _UserIp, _UserName) print('get: ' + log.replace('\n', '')) #============================================================= Temp4Get['User'] = _UserName logfile = state['FileName'] with open(logfile + '.txt', 'a') as f: pass with open('alllog.txt', 'a') as f: pass Temp4Get['AllResult'] = GetAllResult(logfile + '.txt') Temp4Get['AllSummary'] = GetSummary(Temp4Get['AllResult']) self.render("index.html", Temp4Get=Temp4Get)
def get(self): ITA = IsTimeAvailable() with open(ITA['today'] + '.txt', 'a') as file: pass with open(ITA['tomorrow'] + '.txt', 'a') as file: pass if ITA['weekday_for_Order']: dinner_list = GetGetDinner_List()[ITA['weekday_for_Order']] else: dinner_list = 'none' logfile = ITA[ITA['filechoice']] AllResult = GetAllResult(logfile + '.txt') Summary = GetSummary(AllResult) OrderIp = self.request.remote_ip if OrderIp in Member_List.keys(): OrderUser = Member_List[OrderIp] else: OrderUser = '' self.render("index.html", dinner=dinner_list, Post=False, AllResult=AllResult, Summary=Summary, OrderUser=OrderUser)
def get(self): Temp4Get = dict() MST = MyShiftTime() state = MST.IsOrderAvbl() Temp4Get['POST'] = False Temp4Get['Avbl2Order'] = state['Avbl'] Temp4Get['DinnerList'] = getTodayDinnerList() #============================================================= _UserTime = strftime('%Y/%m/%d %a %H:%M:%S') _UserIp = self.request.remote_ip if _UserIp in Member_List.keys(): _UserName = Member_List[_UserIp] else: _UserName = '******' log = '{}, {}, {}\n'.format(_UserTime,_UserIp,_UserName) print('get: '+log.replace('\n','')) #============================================================= Temp4Get['User'] = _UserName logfile = state['FileName'] with open(logfile+'.txt','a') as f: pass with open('alllog.txt','a') as f: pass Temp4Get['AllResult'] = GetAllResult(logfile+'.txt') Temp4Get['AllSummary'] = GetSummary(Temp4Get['AllResult']) self.render("index.html",Temp4Get=Temp4Get)
def get(self): ITA = IsTimeAvailable() with open(ITA['today']+'.txt','a') as file: pass with open(ITA['tomorrow']+'.txt','a') as file: pass if ITA['weekday_for_Order']: dinner_list = GetGetDinner_List()[ITA['weekday_for_Order']] else: dinner_list = 'none' logfile = ITA[ITA['filechoice']] AllResult = GetAllResult(logfile+'.txt') Summary = GetSummary(AllResult) OrderIp = self.request.remote_ip if OrderIp in Member_List.keys(): OrderUser = Member_List[OrderIp] else: OrderUser = '' self.render("index.html", dinner=dinner_list,Post=False, AllResult=AllResult,Summary=Summary,OrderUser=OrderUser)
def GetAllResult(logfile): result_all = dict() with open(logfile) as f: for line in f: tmp = line.strip().split(', ') if tmp[2] in list(Member_List.keys()): key = Member_List[tmp[2]] val = tmp[1] result_all[key] = val result_all = sorted(result_all.items(), key=itemgetter(0)) for idx,i in enumerate(result_all): if '取消今日點餐' in i: result_all.pop(idx) return result_all
def post(self): Temp4Get = dict() MST = MyShiftTime() state = MST.IsOrderAvbl() Temp4Get['POST'] = True Temp4Get['Avbl2Order'] = state['Avbl'] Temp4Get['DinnerList'] = getTodayDinnerList() #============================================================= _UserTime = strftime('%Y/%m/%d %a %H:%M:%S') Choice = self.get_argument('choice') tmps = Temp4Get['DinnerList']['餐點'] dinnersDict = {key: tmp[key] for tmp in tmps for key in tmp} _UserMeal = '取消今日點餐' if Choice == '0' else dinnersDict[Choice] _UserIp = self.request.remote_ip if _UserIp in Member_List.keys(): _UserName = Member_List[_UserIp] else: _UserName = self.get_argument('Name') log = '{}, {}, {}, {}, {}\n'.format(_UserTime, _UserMeal, _UserIp, _UserName, Choice) print('post: ' + log.replace('\n', '')) #============================================================= Temp4Get['Meal'] = _UserMeal Temp4Get['User'] = _UserName logfile = state['FileName'] with open(logfile + '.txt', 'a') as f: f.write(log) with open('alllog.txt', 'a') as f: f.write(log) Temp4Get['AllResult'] = GetAllResult(logfile + '.txt') Temp4Get['AllSummary'] = GetSummary(Temp4Get['AllResult']) self.render("index.html", Temp4Get=Temp4Get)
def post(self): Temp4Get = dict() MST = MyShiftTime() state = MST.IsOrderAvbl() Temp4Get['POST'] = True Temp4Get['Avbl2Order'] = state['Avbl'] Temp4Get['DinnerList'] = getTodayDinnerList() #============================================================= _UserTime = strftime('%Y/%m/%d %a %H:%M:%S') Choice = self.get_argument('choice') tmps = Temp4Get['DinnerList']['餐點'] dinnersDict = {key:tmp[key] for tmp in tmps for key in tmp} _UserMeal = '取消今日點餐' if Choice=='0' else dinnersDict[Choice] _UserIp = self.request.remote_ip if _UserIp in Member_List.keys(): _UserName = Member_List[_UserIp] else: _UserName = self.get_argument('Name') log = '{}, {}, {}, {}, {}\n'.format(_UserTime,_UserMeal,_UserIp,_UserName,Choice) print('post: '+log.replace('\n','')) #============================================================= Temp4Get['Meal'] = _UserMeal Temp4Get['User'] = _UserName logfile = state['FileName'] with open(logfile+'.txt','a') as f: f.write(log) with open('alllog.txt','a') as f: f.write(log) Temp4Get['AllResult'] = GetAllResult(logfile+'.txt') Temp4Get['AllSummary'] = GetSummary(Temp4Get['AllResult']) self.render("index.html",Temp4Get=Temp4Get)