def __init__(self): """ 构造方法 :return: 无 """ self.__connection = pika.BlockingConnection(pika.ConnectionParameters(host=conf.RBMQ_HOST)) # 创建连接 self.__log = mylib.mylog(conf.AGENT_LOG) self.__channel = self.__connection.channel() # 创建channel self.__channel.exchange_declare(exchange=conf.EXCHANGE, type="fanout") res = self.__channel.queue_declare(durable=True) # 队列持久化 self.__queue_name = res.method.queue
def __init__(self): ''' 构造方法 :return: 无 ''' self.__connection = pika.BlockingConnection( pika.ConnectionParameters(host=conf.RBMQ_HOST)) # 创建连接 self.__log = mylib.mylog(conf.AGENT_LOG) self.__channel = self.__connection.channel() # 创建channel self.__channel.exchange_declare(exchange=conf.EXCHANGE, type='fanout') res = self.__channel.queue_declare(durable=True) # 队列持久化 self.__queue_name = res.method.queue
def __init__(self): ''' 构造方法 :return: ''' self.__log = mylib.mylog(conf.CLIENT_LOG) self.__connection = pika.BlockingConnection(pika.ConnectionParameters( host= conf.RBMQ_HOST)) # 创建连接 self.__channel = self.__connection.channel() # 创建channel self.__channel.exchange_declare(exchange = conf.EXCHANGE, type = 'fanout') # 定义exchange self.__channel.queue_declare(queue = conf.QUEUE, exclusive = True) result = self.__channel.queue_declare(exclusive = True) self.__callback_queue = result.method.queue # 定义接收返回的队列 #print(self.__callback_queue) self.__channel.basic_consume(self.__on_response, no_ack = True, queue = self.__callback_queue) # 调用消费方法,接收消息
def __init__(self): ''' 构造方法 :return: ''' self.__log = mylib.mylog(conf.CLIENT_LOG) self.__connection = pika.BlockingConnection( pika.ConnectionParameters(host=conf.RBMQ_HOST)) # 创建连接 self.__channel = self.__connection.channel() # 创建channel self.__channel.exchange_declare(exchange=conf.EXCHANGE, type='fanout') # 定义exchange self.__channel.queue_declare(queue=conf.QUEUE, exclusive=True) result = self.__channel.queue_declare(exclusive=True) self.__callback_queue = result.method.queue # 定义接收返回的队列 #print(self.__callback_queue) self.__channel.basic_consume( self.__on_response, no_ack=True, queue=self.__callback_queue) # 调用消费方法,接收消息
def handle(self): ''' handle方法 :return: 无 ''' import os self.__loger = mylib.mylog(conf.LOGS, isstream = True) # 定义日志对象 self.__current_user = user('guest', '', conf.DEFAULT_QUOTA) # 定义默认用户 self.__users = users() # 获取users对象 self.__home_path = os.path.abspath(os.path.join(conf.HOME_PATH,self.__current_user.get_username())).replace('\\', '/') # 获取家目录 self.__current_path = self.__home_path # 定义当前目录 self.__code_list = conf.CODE_LIST # 定义错误里诶表 self.__loger.info('Client %s:%s is connect the server' %self.client_address) while True: try: data = mylib.b2s(self.request.recv(1024)) # 获取客户端命令 except socket.error as e: self.__loger.info('Has lost client %s:%s' %self.client_address) break if not data: self.__loger.info('Has lost client %s:%s' %self.client_address) break #如果收不到客户端数据了(代表客户端断开了),就断开 self.instruction_allowcation(data) #客户端发过来的数据统一交给功能分发器处理
Version: 1.0 Description: Help: ''' from model.account import account from model.atm import atm import conf import libs.mylib as mylib if __name__ == '__main__': ac = account() atm = atm() # import re # amount_re = re.compile('^\d+[.]{0,1}\d+$') logger = mylib.mylog(conf.ATM_LOG) def print_menu(menu_list): ''' 输出菜单函数,用于显示菜单和获取用户输入 :param menu_list: 菜单列表 :return: 返回用户输入的选项 ''' for item in enumerate(menu_list, 1): print('%s、 %s' %item) # 通过遍历打印菜单项 chose = input('请选择:').strip() # 获取用户输入 return chose #返回用户输入 def print_welcome(): ''' 输出系统信息和用户信息
Description: Help: ''' # import logging # import logging.config from model.account import account from model.atm import atm import conf import libs.mylib as mylib if __name__ == '__main__': ac = account() atm = atm() # logging.config.fileConfig("atm_logger.conf") logger = mylib.mylog(conf.ATM_LOG) # handler = logging.FileHandler(filename='atm.log',encoding = "UTF-8") # logger.addHandler(handler) # logging.basicConfig(level=logging.DEBUG, format = u'%(asctime)s [%(levelname)s]: %(message)s', datefmt='%Y-%m-%d %H:%M:%S', filename='atm.log', filemode='a', encoding = "UTF-8") def print_welcome(): # menu = ['查看详细信息', '查看账单', '提现', '同行转账', '查看消费流水', '修改密码', '退出'] #account = atm.get_crurrent() #print(account) welcome_info = ''' ********************************** * %s * * %s * * %s * **********************************''' %(mylib.myljust('欢迎来到65银行后台系统', 30), mylib.myljust('Version: 1.0', 30), mylib.myljust('admin 您好', 30)) print(welcome_info)
Description: 65商城主程序 Help: ''' from model.customer import customer from model.shopping import shopping from model.goods import goods from model.atm import atm from libs import mylib import conf if __name__ == '__main__': shopping = shopping() goo = goods() logger = mylib.mylog(conf.SHOPPING_LOG) cu = customer() atm = atm() def print_menu(menu_list): ''' 输出菜单函数,用于显示菜单和获取用户输入 :param menu_list: 菜单列表 :return: 返回用户输入的选项 ''' for item in enumerate(menu_list, 1): print('%s、 %s' %item) # 通过遍历打印菜单项 chose = input('请选择:').strip() # 获取用户输入 return chose #返回用户输入 def print_welcome(): '''
Description: 65商城主程序 Help: ''' from model.customer import customer from model.shopping import shopping from model.goods import goods from model.atm import atm from libs import mylib import conf if __name__ == '__main__': shopping = shopping() goo = goods() logger = mylib.mylog(conf.SHOPPING_LOG) cu = customer() atm = atm() def print_menu(menu_list): ''' 输出菜单函数,用于显示菜单和获取用户输入 :param menu_list: 菜单列表 :return: 返回用户输入的选项 ''' for item in enumerate(menu_list, 1): print('%s、 %s' % item) # 通过遍历打印菜单项 chose = input('请选择:').strip() # 获取用户输入 return chose #返回用户输入 def print_welcome():