def api_reset_captchas_mobile(mobile): # check mobile mobile_resp = requests.get(API_URL + 'accounts/check-mobile/' + mobile, headers=get_headers(), data=request.data, stream=True) if (mobile_resp.status_code == 200): resp = jsonify({'message': u'手机号【' + mobile + '】不存在!'}) resp.status_code = 400 return resp # get verifyCode captcha_resp = requests.get(API_URL + 'captchas/mobile/' + mobile, headers=get_headers(), data=request.data, stream=True) if (captcha_resp.status_code == 200): resp = jsonify({'message': u'验证码获取成功!'}) resp.status_code = 200 return resp else: message = u'验证码获取失败!' if captcha_resp.json().get( 'message') is None else captcha_resp.json().get('message') resp = jsonify({'message': message}) resp.status_code = 400 return resp
def main_function(): # check we are in the correct folder and complain and exit if we are not check_cwd() # get a list of header files headers = get_headers() # get a list of source files sources = get_sources() # keep only pathname with tests_filename.cpp in them sources = keep_tests(sources) # extract names for mtl classes and functions from the test files documentation = generate_documentation(sources) output_filename = '../docs/listing.md' # keep a crc32 hash from the file before modification crc32_before = crc32(output_filename) # write the generated documentation with open(output_filename, 'w', encoding='utf-8', newline='\n') as in_file: for line in documentation: in_file.write((line + '\n')) # keep a crc32 hash from the file after modification crc32_after = crc32(output_filename) # if the file changed if crc32_before != crc32_after: print('Finished generating documentation. The ', end='') print('output is stored in {}.'.format(output_filename[3:])) # if the file didn't change else: print('No changes to the documentation file.')
def make_request(self): response = requests.post( "https://www.skyscanner.es/g/conductor/v1/fps3/search/", params=get_params(), headers=get_headers(), data=get_request_data(self.day, self.iata)) self.data, self.status = response.content, response.status_code print(self.status)
def wechat_authorize(): account = web_ui.get_account_info() response = requests.post(API_URL + 'wechat/authorize', headers=get_headers(), data=json.dumps(account)) resp = jsonify({"message": response.text}) resp.status_code = 200 return resp
def get_robot_info(): robot = {} robot_response = requests.get(API_URL + 'robots/user/' + str(session.get('user_id')), headers=get_headers()) if robot_response.status_code == 200: robot = robot_response.json() return robot
def wechat_postinfo(): print request print request.data obj = {} obj["param"] = request.data requests.post(API_URL + 'wechat/', headers=get_headers(), data=json.dumps(obj)) return Response("success")
def wechat_redirect(): authorization = {} authorization["username"] = request.args["username"] authorization["auth_code"] = request.args["auth_code"] response = requests.post(API_URL + 'wechat/redirect', headers=get_headers(), data=json.dumps(authorization)) if response.status_code == 200: return render_template('web/ditingpc1.0/access_webVx1.html', loginInfo=web_ui.get_login_info())
def wechat_accept(appid): acceptParams = {} acceptParams["xml"] = request.data acceptParams["nonce"] = request.args["nonce"] acceptParams["timeStamp"] = request.args["timestamp"] acceptParams["msgSignature"] = request.args["msg_signature"] response = requests.post(API_URL + 'wechat/accept', headers=get_headers(), data=json.dumps(acceptParams)) return Response(response.text)
def api_password_reset(): request_data = json.loads(request.data) reset_response = requests.post(API_URL + 'accounts/password/reset', headers=get_headers(), data=json.dumps(request_data)) if reset_response.status_code == 200: resp = jsonify({'message': u'密码找回成功!'}) resp.status_code = 200 return resp else: resp = jsonify({'message': reset_response.json().get('message')}) resp.status_code = 400 return resp
def api_login(): request_data = json.loads(request.data) login_response = requests.post(API_URL + 'agents/login', headers=get_headers(), data=json.dumps(request_data)) if login_response.status_code == 200: agent = login_response.json() create_session(agent) resp = jsonify({'message': u'登录成功!'}) resp.status_code = 200 return resp else: resp = jsonify({'message': u'可爱的小伙伴,您输入的帐户名或密码有误~~~'}) resp.status_code = 400 return resp
def get_category(): """ 获取分类id :return: """ result = requests.get(FIRST_URL, headers=get_headers()) return_result = list() if result.ok and result.status_code == 200: result = json.loads(result.text) for item in result['data']['categoryNotes']: category_id = item['category_id'] name = item['name'] return_result.append({'category_id': category_id, 'name': name}) return return_result
def wechat_bind(): request_data = json.loads(request.data) login_response = requests.post(API_URL + 'accounts/login', headers=get_headers(), data=json.dumps(request_data)) if login_response.status_code == 200: response = requests.post(API_URL + 'accounts/wechat/bind', headers=get_headers(), data=json.dumps(request_data)) if response.status_code == 200: account = login_response.json() create_session(account) resp = jsonify({'message': u'绑定微信成功!'}) resp.status_code = 200 return resp else: resp = jsonify({'message': u'绑定微信失败'}) resp.status_code = 400 return resp else: resp = jsonify({'message': u'可爱的小伙伴,您输入的帐户名或密码有误~~~'}) resp.status_code = 400 return resp
def get_rank_data(url): result = requests.get(url, headers=get_headers()) return_result = list() if result.ok and result.status_code == 200: result = json.loads(result.text) for item in result['data']['rankingList']: nick_name = item['wechat_nickname'] wechat_id = item['wechat_id'] return_result.append({ 'nick_name': nick_name, 'wechat_id': wechat_id }) print(nick_name, wechat_id) return return_result
def remote_wechat_login(): request_data = json.loads(request.data) response = requests.post(API_URL + 'accounts/wechat', headers=get_headers(), data=json.dumps(request_data)) if response.status_code == 200: account = response.json() create_session(account) resp = jsonify({'message': u'登录成功'}) resp.status_code = 200 return resp else: resp = jsonify({'message': u'账号不存在'}) resp.status_code = 400 return resp
def display_text(filename, scope): json_obj = common.load_json_from_file(filename) output = '' for item in json_obj.items(): device_name = item[0] print "====" + device_name + "====" print "--" + scope + '--' dataset = item[1][scope] headers = common.get_headers(dataset) table = common.get_table(dataset) output += tabulate.tabulate(table, headers, tablefmt="fancy_grid") print output return output
def display_md(filename, scope): json_obj = common.load_json_from_file(filename) output = '' for item in json_obj.items(): device_name = item[0] dataset = item[1][scope] template_file = 'templates/md/md_table.j2' header = common.get_headers(dataset) table = common.get_table(dataset) output += common.render_table_from_template(template_file, header, table, device_name, scope, '') print output return output
def display_html(filename, scope): json_obj = common.load_json_from_file(filename) output = '' for item in json_obj.items(): device_name = item[0] dataset = item[1][scope] template_file = 'templates/html/table1.html' header = common.get_headers(dataset) table = common.get_table(dataset) output += common.render_table_from_template(template_file, header, table, device_name, scope, '') main_template_file = 'templates/html/main.html' text = common.render_table_from_template(main_template_file, header, table, device_name, scope, output) print text return text
def api_accounts_register_mobile(): data = json.loads(request.data) session['user_type'] = u'DITING_USER' register_resp = requests.post(API_URL + 'accounts/register/mobile', headers=get_headers(), data=json.dumps(data)) if register_resp.status_code == 200: account = register_resp.json() create_session(account) resp = jsonify({ 'message': u'注册登录成功!', 'uniqueId': account.get("uniqueId") }) resp.status_code = 200 return resp else: message = u'注册失败!请重新注册!' if register_resp.json().get( 'message') is None else register_resp.json().get('message') resp = jsonify({'message': message}) resp.status_code = 400 return resp
def wechat_login(): code = request.args["code"] appId = "wxd7e83c7f47dab038" appsecret = "86d4caeefa7c609f4175842ce64443a3" url_get_access_token = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appId + "&secret=" + appsecret + "&code=" + code + "&grant_type=authorization_code" response = requests.get(url_get_access_token, headers={}, verify=False) if response.status_code == 200: authorInfo = response.json() openId = authorInfo.get("openid") unionId = authorInfo.get("unionid") wechatInfo = {} wechatInfo['openId'] = openId wechatInfo['unionId'] = unionId response = requests.post(API_URL + 'accounts/wechat', headers=get_headers(), data=json.dumps(wechatInfo)) if response.status_code == 200: account = response.json() create_session(account) return render_template('web/ditingpc1.0/success_index.html', loginInfo=get_login_info()) else: return render_template('web/binding_login.html', wechatInfo=wechatInfo)
const att=doc._attachments; const contentType=att[Object.keys(att)[0]].content_type; if(contentType.substring(0,6)==="image/"){ emit(doc.name,doc); } } } """ getImageFileIndex['reduce'] = "_count" args = common.parse_args() conn = common.get_connection(args.use_ssl, args.couch_server, args.couch_port) credentials = common.get_credentials(args.adminuser, args.adminpass) get_headers = common.get_headers(credentials) put_headers = common.put_headers(credentials) # Update all the wiki design docs conn.request("GET", '/_all_dbs', headers=get_headers) db_list = common.decode_response(conn.getresponse()) wiki_list = [db for db in db_list if db[0:5] == "wiki_"] # Update the wiki dbs for wiki in wiki_list: print("Examining " + wiki) # Fetch design doc ddoc_uri = '/' + wiki + '/_design/' + wiki_ddoc conn.request("GET", ddoc_uri, headers=get_headers) resp = conn.getresponse() ddoc = common.decode_response(resp)
def main_function(): ''' The main function for the script. ''' # the desired line length line_length = 100 # check we are in the correct folder and complain and exit if we are not check_cwd() # get a list of header files headers = get_headers() # get a list of source files sources = get_sources() # get all the header files beyond the desired line length longer_headers = check_line_length(headers, line_length) # get all the source files beyond the desired line length longer_sources = check_line_length(sources, line_length) # get all header files that have improperly formatted comments bad_comment_headers = check_comments_space(headers) # get all source files that have improperly formatted comments bad_comment_sources = check_comments_space(sources) # get all header files that don't have a newline as their last line no_newline_headers = check_newline_end(headers) # get all source files that don't have a newline as their last line no_newline_sources = check_newline_end(sources) if len(longer_headers) > 0 or len(longer_sources) > 0: if len(longer_headers) > 0: # print the number of header files containing lines beyond the # desired length print('\n----------------------------------------------', end='') print('-------------------------') print('There are ', end='') print('{} header files (.hpp) with'.format(len(longer_headers)), end='') print(' lines longer than {} characters :'.format(line_length)) print('------------------------------------------------', end='') print('-----------------------') for filename, lines in longer_headers: print('In {} lines '.format(filename), end='') for line in lines: print('{}, '.format(line), end='') print('\b\b. ') if len(longer_sources) > 0: # print the number of source files containing lines beyond the # desired length print('\n----------------------------------------------', end='') print('-------------------------') print('There are ', end='') print('{} source files (.cpp) with'.format(len(longer_sources)), end='') print(' lines longer than {} characters :'.format(line_length)) print('--------------------------------------------------', end='') print('---------------------') for filename, lines in longer_sources: print('In {} lines '.format(filename), end='') for line in lines: print('{}, '.format(line), end='') print('\b\b.') if len(bad_comment_headers) > 0 or len(bad_comment_sources) > 0: # divider between the printing files with lines beyond desired # length and printing files with improperly formatted comments print('\n\n') print('=================================================', end='') print('======================\n\n') # -------- if len(bad_comment_headers) > 0 or len(bad_comment_sources) > 0: if len(bad_comment_headers) > 0: # print the number of header files containing improperly formatted # comments print('\n-----------------------------------------------', end='') print('---------------------') print('There are ', end='') print(len(bad_comment_headers), end='') print(' header files (.hpp) with improperly formatted comments :') print('--------------------------------------------', end='') print('------------------------') for filename, lines in bad_comment_headers: print('In {} lines '.format(filename), end='') for line in lines: print('{}, '.format(line), end='') print('\b\b. ') if len(bad_comment_sources) > 0: # print the number of source files containing improperly formatted # comments print('\n----------------------------------------------', end='') print('----------------------') print('There are ', end='') print(len(bad_comment_sources), end='') print(' source files (.cpp) with improperly formatted comments :') print('--------------------------------------------', end='') print('------------------------') for filename, lines in bad_comment_sources: print('In {} lines '.format(filename), end='') for line in lines: print('{}, '.format(line), end='') print('\b\b. ') if len(bad_comment_headers) > 0 or len(bad_comment_sources) > 0: # divider print('\n\n') print('=================================================', end='') print('======================\n\n') # -------- if len(no_newline_headers) > 0 or len(no_newline_sources) > 0: if len(no_newline_headers) > 0: # print the number of header files that are missing a newline # as their last line print('--------------------------------------------', end='') print('-----------------------------------') print('There are {} '.format(len(no_newline_headers)), end='') print('header files (.hpp) missing a newline', end='') print(' as their last line.') print('--------------------------------------------', end='') print('-----------------------------------') for no_nl_header in no_newline_headers: print('The header file {} '.format(no_nl_header), end='') print('is missing a newline as its last line.') print() if len(no_newline_sources) > 0: # print the number of source files that are missing a newline # as their last line print('--------------------------------------------', end='') print('-----------------------------------') print('There are {} '.format(len(no_newline_sources)), end='') print('source files (.cpp) missing a newline', end='') print(' as their last line.') print('--------------------------------------------', end='') print('-----------------------------------') for no_nl_source in no_newline_sources: print('The source file {} '.format(no_nl_source), end='') print('is missing a newline as its last line.') # if everything is fine, print a message to inform the user longer_files = len(longer_headers) == 0 and len(longer_sources) == 0 bad_comments = len(bad_comment_headers) == 0 bad_comments = bad_comments and len(bad_comment_sources) == 0 no_newlines = len(no_newline_headers) == 0 no_newlines = no_newlines and len(no_newline_sources) == 0 if longer_files and bad_comments and no_newlines: print('All files checked. No errors detected.')
def api_agent_companies_searchpage(): dictionaries = [] page_no = "1" if request.args.get('pageNo') is None else request.args.get('pageNo') invitation_code = "" if request.args.get('invitationCode') is None else request.args.get('invitationCode') select_response = requests.get(API_URL + 'companies/egent/search-page?pageNo=' + page_no+'&invitationCode='+invitation_code, headers=get_headers()) if select_response.status_code == 200: dictionaries = select_response.json() return Response(json.dumps(dictionaries))