def handle(self, path, name): try: Import = importlib.import_module(path) classname = getattr(Import, name) classname().run() except Exception as e: app('log').warning(e)
def run(self): if self.code is None: param = { 'account': app('env')['USER_ACCOUNT'], 'password': Aes.encrypt( app('env')['USER_PASSWORD'], app('env')['UAES_KEY']), } data = app('request').post(app('env').DOMAIN + self.uri, params=param, header={}).json() self.log(data) Login.code = HandyJson(data).get('retData._token', None) return self.code
def run(self): param = { 'account': '186529793361', 'password': '******', } data = app('request').post(app('env').DOMAIN + self.uri, params=param, header={}).json() code = data.get('retCode', None) if code is not None and data.get('retData', {}).get('code', 0) != 404: app('log').info(self.uri + ': success, return:' + data.__str__()) else: app('log').error(self.uri + ': error, return:' + data.__str__())
def run(self): param = { 'type': 'draw', } header = {'token': LoginCheck().run()} data = app('request').post(app('env').DOMAIN + self.uri, params=param, header=header).json() data = HandyJson(data) code = data.get('retCode', 0) if code == 0: app('log').info(self.uri + ': success, return:' + data.__str__()) else: app('log').error(self.uri + ': error, return:' + data.__str__())
def run(self): if self.token is None: param = { '_token': Login().run(), 'phone_code': '1314', 'email_code': '1314', 'google_code': '1314', } data = app('request').post(app('env').DOMAIN + self.uri, params=param, header={}).json() hjdata = HandyJson(data) self.token = hjdata.get('retData.token', None) if self.token is None: app('log').error(self.uri + ': error, return:' + hjdata.__str__()) else: app('log').info(self.uri + ': success, return:' + hjdata.__str__()) return self.token
# # 取消referer # app('oss').referer().push('test/api.json', rep.text, {'Content-Encoding': 'utf-8'}) # # 上传本地文件 # app('oss').push_file('test/api.json', '/Users/jemes/workspace/simutil/Storage/Logs/20200528.log', {'Content-Encoding': 'utf-8'}) # rule规则设置 # app('oss').rule(allowed_origins=['*'], allowed_methods=['GET'], allowed_headers=['*'], max_age_seconds=100)\ # .push_file('test/api.json', '/Users/jemes/workspace/simutil/Storage/Logs/20200528.log') # Path # print(app('path').resolve()) # print(app('path').joinpath('Config')) # exit(0) # RabbitMQ channel = app('rabbitmq').channel() print(channel.queue_declare) print(type(channel)) exit(0) result = channel.queue_declare('', exclusive=True) # 声明exchange,由exchange指定消息在哪个队列传递,如不存在,则创建。durable = True 代表exchange持久化存储,False 非持久化存储 channel.exchange_declare(exchange='python-test', durable=True, exchange_type='fanout') # 绑定exchange和队列 exchange 使我们能够确切地指定消息应该到哪个队列去 channel.queue_bind(exchange='python-test', queue=result.method.queue) # 定义一个回调函数来处理消息队列中的消息,这里是打印出来 def callback(ch, method, properties, body): ch.basic_ack(delivery_tag=method.delivery_tag) print("consumer_2", body.decode()) channel.basic_consume(result.method.queue, callback, # 设置成 False,在调用callback函数时,未收到确认标识,消息会重回队列。True,无论调用callback成功与否,消息都被消费掉
def handle(e: Exception): if isinstance(e, ServiceException): app('log').info(e.__str__()) else: app('log').info(e.__str__())
def __new__(cls, *args, **kwargs): if not cls._instance: cls._instance = BasePath(app('BASE_PATH')) return cls._instance
def log(self, data): if data.get('retCode', -1) == 0: app('log').info(self.uri + ': success, return:' + data.__str__()) else: app('log').error(self.uri + ': error, return:' + data.__str__())