def displayMenu(stu, db): role = StudentRole(stu, db) menu = '' menu += '[1]上课签到'.ljust(menu_width) menu += '[2]提交作业'.ljust(menu_width) menu += '[3]查看个人成绩'.ljust(menu_width) + os.linesep menu += '[4]查看成绩排名'.ljust(menu_width) # menu += '[88]修改密码'.ljust(menu_width) menu += '[99]退出'.ljust(menu_width) while True: common.menuDisplay(menu) choice = input('请录入菜单代码:') if choice == '99': break elif choice == '1': checkIn(role) elif choice == '2': push_job(role) elif choice == '3': queryScore(role) elif choice == '4': queryScoreList(role) elif choice == '5': cur_pwd = input('请录入旧密码:') new_pwd = input('请录入新密码:') User.Change_Password(stu.login_user, cur_pwd, new_pwd) else: pass
def displayMenu(teacher, db): role = TeacherRole(teacher, db) menu = '' menu += '[1]新增班级'.ljust(menu_width) menu += '[2]添加学员'.ljust(menu_width) menu += '[3]上课安排'.ljust(menu_width) + os.linesep menu += '[4]记录成绩'.ljust(menu_width) menu += '[5]查看班级成员'.ljust(menu_width) # menu += '[88]修改密码'.ljust(menu_width)+os.linesep menu += '[99]退出'.ljust(menu_width) while True: # print('负责的课程'.center(center_width,'-')) # for cls in role.tec.classes_list: # print(cls) common.menuDisplay(menu) choice = input('请录入菜单代码:') if choice == '99': break elif choice == '1': classesManage(role) elif choice == '2': addStu(role) elif choice == '3': sessionArrange(role) elif choice == '4': ChangeScore(role) elif choice == '5': queryStudent(role) elif choice == '88': cur_pwd = input('请录入旧密码:') new_pwd = input('请录入新密码:') User.Change_Password(teacher.login_user, cur_pwd, new_pwd, 2) else: pass # # unit test # tec = model.Teacher('1', 'oldboy', 'oldboy', '','8001') # role = TeacherRole(tec) # displayMenu(tec) # sessionArrange(role)
def on_response(self, ch, method, props, body): if self.corr_id == props.correlation_id: self.response = body def call(self, hosts, cmd): self.response = None self.corr_id = str(uuid.uuid4()) self.channel.basic_publish(exchange='', routing_key='rpc_queue', properties=pika.BasicProperties( reply_to=self.callback_queue, correlation_id=self.corr_id, ), body=cmd) print(' [task_id]:', self.corr_id) while self.response is None: self.conn.process_data_events() return self.response.decode() if __name__ == '__main__': cmd_rpc = RemoteCmd_RpcClient() remote_hosts = ['10.0.0.90'] cmd = 'df -h' for h in remote_hosts: print(" [x] Requesting (%s) running: %s " % (h, cmd)) response = cmd_rpc.call(h, cmd) common.menuDisplay(("[ Got %r ]" % h).center(50, '#')) print(response)
if __name__ == '__main__': while True: # input_cmd = 'run "ifconfig eth0" --hosts 10.0.0.90 10.0.0.88' input_cmd = input('>>:([q:退出]) ') remote_hosts = None cmd = None if input_cmd == 'q': break elif input_cmd.startswith('run'): input_cmd = input_cmd.strip().replace("'", '"') cmd = re.search('"(.*)"', input_cmd).group(1) data = input_cmd.split(" --hosts ") if len(data) > 1: remote_hosts = data[1].split() # print(remote_hosts) cmd_rpc = RemoteCmd_RpcClient() for h in remote_hosts: print(" [x] Requesting (%s) running: %s " % (h, cmd)) cmd_rpc.call(h, cmd) response = cmd_rpc.get_result() common.menuDisplay(("[ Response from %r ]" % h).center(50, '#')) print(response) else: common.errorPrompt('run "ifconfig eth0" --hosts 10.0.0.90 10.0.0.88')
if __name__ == '__main__': prompt = "=" * info_width + os.linesep prompt += '欢迎来到前程似锦网上教学系统' + os.linesep prompt += "=" * info_width print("\033[36m%s \033[0m" % prompt) menu = '' menu += '[1]登录'.ljust(menu_width) menu += '[2]注册'.ljust(menu_width) menu += '[99]退出'.ljust(menu_width) engine = create_engine(common.ReadConfig('db', 'dns')) db = dataAccess.dbProxy(engine) try: user = business.User(db) while True: common.menuDisplay(menu) choice = input('please input your choice:') # choice ='1' if choice == '99': break elif choice == '1': login(user, db) elif choice == '2': register(user) else: pass except Exception as e: print(e) finally: db.close()