def handle_text(message): logs.save_log(message) if message.text == 'Главное меню': main_menu_keyboard(message) elif message.text == 'Five news from the Village': bot.send_message(message.chat.id, data_parse.five_news_from_the_village())
def addUser(self): args = self.user_info_string ''' add monkey1 12 132xxx [email protected] ''' user_info_list = args.split(" ") if len(user_info_list) != 4: logs.save_log("addUser failed, args length != 4", tag='error') user_expand.format_print(False, "addUser failed, args length != 4") return username = user_info_list[0] try: student.select().where(student.username == username).get() user_expand.format_print(False, "{} 已存在".format(username)) return except: RESULT = { 'username': username, 'age': user_info_list[1], 'phone': user_info_list[2], 'email': user_info_list[3], } try: student.insert(RESULT).execute() logs.save_log("add user {} secc.".format(username)) user_expand.format_print(True, "add user {} secc.".format(username)) except Exception as e: print(e)
def main(): init_fail_count = 0 max_fail_count = 3 while init_fail_count < max_fail_count: try: username = input("Please input your login username: "******"Please input your login password: "******"Please input your login password: "******"{} 登录成功".format(username)) user_expand.user_help(username=username, roles=roles) user_expand.logic(roles) else: logs.save_log("{} 登录失败".format(username), tag='error') user_expand.format_print(False, "username or password valid failed.") print() init_fail_count += 1 except Exception as e: print(e) user_expand.format_print(False, "操作异常,程序退出!!!") exit(1) user_expand.format_print(False,"Game Over.") logs.save_log("密码错误次数过多,退出登录", tag='error')
def deleteUser(self): args = self.user_info_string user_info_list = args.split(" ") if args is '' or len(user_info_list) != 1: logs.save_log("deleteUser failed, args length != 1", tag='error') user_expand.format_print(False, "deleteUser failed, args length != 1") return username = args try: tag = student.delete().where( student.username == username).execute() if tag: user_expand.format_print( True, "delete user {} secc.".format(username)) else: user_expand.format_print( False, "Username: {} not found.".format(username)) except Exception as e: print(e)
def main(): init_fail_count = 0 max_fail_count = 3 while init_fail_count < max_fail_count: username = input("Please input your login username: "******"Please input your login password: "******"{} 登录成功".format(username)) #user_expand.format_print(True, "\n\tWelcome to user magage system.\n") user_expand.user_help(username=username) user_expand.logic() else: logs.save_log("{} 登录失败".format(username), tag='error') user_expand.format_print(False, "username or password valid failed.") print() init_fail_count += 1 user_expand.format_print(False, "Game Over.") logs.save_log("密码错误次数过多,退出登录", tag='error')
def start_message(message): logs.save_log(message) keyboard = telebot.types.ReplyKeyboardMarkup(True, True) keyboard.row('Главное меню') bot.send_message(message.chat.id, 'Привет!', reply_markup=keyboard)
for e in conn.get_errs(): print e else: print 'a' while True: tms.append(c.get_time()) print iii if iii < STOP: conn.write(str(iii)) for mes in conn.read(): miii = int(mes) # print '',miii assert miii == len(rec) rec.append(c.get_time()) iii += 1 c.tick(0.001) if (len(tms) >= STOP and len(rec) >= STOP) or len(tms) >= STOP_ANYWAY: break if not conn.are_you_OK(): happy_ending = False for e in conn.get_errs(): print e break conn.close() logs.save_log(tms=tms, rec=rec, happy_ending=happy_ending)
if not conn.are_you_OK(): print "a connection error ocurred:" print(conn.get_errs()) print '' raise Exception("connection error") iii += 1 if __name__ == "__main__": try: my_ac = int(raw_input('choose controller: ')) conn = setup_conn() game = Main(my_cont=my_ac) c = clock.Clock() log = dict(tms=[], rec=[]) ## select our actor our actor main_loop(**locals()) finally: try: conn.close() except: print 'failed to close connection' try: game.close() except: print 'failed to close graphics' try: logs.save_log(**log) except: print 'failed to save data'