def metrics(): #sop project sop_urls = ["http://*****:*****@10.80.82.203:30622/"] for index, url in enumerate(sop_urls): code = tools.get_content(url) web_code.labels("sop", "prod", "eurake" + str(index), url).set(code) logger.info(prometheus_client.generate_latest(web_code)) #ai project ai_urls = { "ai-gpu-prod": "http://47.103.96.111:9081/health_check", "ai-video-prod": "http://47.103.96.111:9083/health_check", "ai-ocr-prod": "http://47.103.96.111:9086/health_check", "ai-cdmp-prod": "http://47.103.96.111:9089/health_check", "ai-forecast-prod": "http://47.103.96.111:9087/health_check", "ai-search-prod": "http://47.103.96.111:9085/health_check", "ai-picture-prod": "http://47.103.96.111:9092/health_check", "ai-dam-prod": "http://47.103.96.111:9096/health_check", "ai-saas-prod": "http://47.103.96.111:9084/health_check", "ai-logo-recognition-prod": "http://47.103.96.111:9090/health_check" } for project, url in ai_urls.items(): code = tools.get_content(url) web_code.labels("ai", "prod", project, url).set(code) #vms project return Response(prometheus_client.generate_latest(web_code), mimetype="text/plain")
def save_blog(): if 'user' in session and not escape(session['user']) == 'stranger': if time.time() - int(escape(session['time'])) < remember_login_time: content = request.form['content'] title = request.form['title'] user = escape(session['user']) c = get_content(content) now = get_time() path = save_md(content, user) Database.connect() Database.add_blog(title=title, auth=user, create_date=now, content=c, path=path) Database.close() return render_template('md_editor_edit.html', user=escape(session['user'])) else: session['user'] = '******' session['password'] = '******' return render_template('md_editor_edit.html', user=escape(session['user'])) else: return render_template('md_editor_edit.html', user='******')
def reddit_save_blog(): Database.connect() blogid = request.form['blogid'] content = request.form['content'] auth = Database.check_blog_haver(blogid) if "time" in session and time.time() - int(escape( session['time'])) < remember_login_time: user = escape(session['user']) else: session['user'] = '******' session['password'] = '******' user = '******' authority = Database.check_user(user, password='******', name_only=True) path = Database.get_blog(blogid) if auth == user or authority == 1: with open(path, 'wb') as fi: fi.write(content.encode('utf-8')) date = get_time() c = get_content(content) Database.change_blog(blogid, c, date) Database.close() return redirect('/md-editor/show/' + blogid)
import os from time import sleep import docx from pandas import DataFrame from config import STEM_CONTENT_COLUMN_NAME, ANSWER_A_COLUMN_NAME, ANSWER_B_COLUMN_NAME, \ ANSWER_C_COLUMN_NAME, ANSWER_D_COLUMN_NAME, ANSWER_COLUMN_NAME, SERIAL_NUMBER_COLUMN_NAME, XLSX_FILES_DIR from tools import get_content, get_docx_file for name, docx_file_path in get_docx_file(): f = docx.Document(docx_file_path) print('-----%s-----' % name) serial, stem, answer_a, answer_b, answer_c, answer_d, answer = get_content( f.paragraphs) stru_dict = { SERIAL_NUMBER_COLUMN_NAME: serial, STEM_CONTENT_COLUMN_NAME: stem, ANSWER_A_COLUMN_NAME: answer_a, ANSWER_B_COLUMN_NAME: answer_b, ANSWER_C_COLUMN_NAME: answer_c, ANSWER_D_COLUMN_NAME: answer_d, ANSWER_COLUMN_NAME: answer } df = DataFrame(stru_dict) xlsx_name = os.path.join(XLSX_FILES_DIR, '%s.xlsx' % name) print('-------成功将 %s 转成 xlsx' % name)