def getfilelist(school_code): """ 获取待下载文件列表信息 :param school_code: :return: """ try: url_filelist = '/'.join([config.Config.SERVER_URL, 'getFileList']) json_str = json.dumps({'code': school_code}) sign_str = ''.join([json_str, config.Config.HASH_KEY]) signature = hashlib.md5(sign_str).hexdigest() params = {"json": json_str, "signature": signature} r = requests.post(url_filelist, data=params) gen_log.info('getfilelist url: %s, params: %s, response: %s', url_filelist, json.dumps(params, ensure_ascii=True), r.text) response = r.json() if response['respcode'] == '00': filelist = response['filelist'] return filelist else: gen_log.error(u'调用获取文件列表接口失败:%s', response['respdesc']) return None except Exception: gen_log.exception(u'调用获取文件列表接口异常:') return None
def get_method_name(method): name_pattern = re.compile("@.*?\(") result = re.search(name_pattern, method) if not result: gen_log.error("cannot find method name in method: " + method) else: name = result.group()[1:-1] return name
def get_commands(method): body_pattern = re.compile("{\n.*", re.S) result = re.search(body_pattern, method) commands_list = [] if not result: gen_log.error("cannot find commands in method: " + method) else: commands = result.group()[2:] commands_list = commands.split("\n") # Skip blank line commands_list = [line for line in commands_list if line] return commands_list