def visual(self, env_name): gl._init() plotter = utils.VisdomLinePlotter(env_name=env_name) gl.set_value(env_name, plotter) return gl.get_value(env_name)
def click_start(self): # 获取SN serial_number = self.serial_number_line.text() # 初始化Log gl._init() now_time = time.strftime('%Y%m%d-%H%M%S') now_day = time.strftime('%Y%m%d') path = "E:\station_log\\" + serial_number + "\\" + now_time + "\\" summary_path = "E:\station_log\\summary_log\\" WhetherPathExist(path) LOG_path = path + "test.log" log = Logger(LOG_path) gl.set_value('SN', serial_number) gl.set_value('path', path) gl.set_value('log_func', log) gl.set_value('now_day', now_day) gl.set_value('summary_path', summary_path) # 将生成Log实例化对象设为全局变量 # SN输入框无法编辑 self.serial_number_line.setReadOnly(True) # 表格设置为空 self.Test_Item.setRowCount(0) self.Test_Item.clearContents() # 开始按键变灰 self.Start_Button.setEnabled(False) # 改变测试标签状态 self.label_status.setText("Runing") self.label_status.setPalette(pe_yel) # 测试线程开始 self.thread.start()
def turntodata(myFPtree): data = [] for child in myFPtree.children.values(): data_node = {} data_node["name"] = child.name + " (" + str(child.count) + ")" data_node["children"] = [] data_node["count"] = child.count child.todata(data_node["children"]) data.append(data_node) file = open('fp-tree.json', 'w', encoding='utf-8') json.dump(data, file, ensure_ascii=False) gl._init(data, "frequent_itemset")
def pridect(self): gl._init() ttt = self.open_path.text() gl.set_value('val_path', ttt) tt = self.textEdit.toPlainText() gl.set_value('val_text', tt) print(ttt) cf.runn() _translate = QtCore.QCoreApplication.translate path = r'D:\python\Bert_chinese_1\output\test_results_1.txt' if path is not None: with open(file=path, mode='r+', encoding='utf-8') as file: self.textBrowser.setPlainText(file.read())
def save_textvariable(): global username global password username = e1.get() password = e2.get() gl._init() gl.set_value('username',username) gl.set_value('password',password) try: jira = JIRA( basic_auth = (username, password), options = {'server': 'http://142.104.193.65:8080'} ) GUI_flag=True log_inWindow.destroy() except: mb.showerror("Error", "Login Unsuccessfull")
def on_pushButton_clicked(self): """ Slot documentation goes here. """ last = unicode(self.lineEdit_last.text()) new1 = unicode(self.lineEdit_new1.text()) new2 = unicode(self.lineEdit_new2.text()) if new1 != new2: QtGui.QMessageBox.information(self, 'Message', "两次密码输入不一致!", QtGui.QMessageBox.Yes) test_sql_client = globalvar._init(self.sql_client.user, last) if test_sql_client.check_user(): self.sql_client.update_admin_password(new2) globalvar._init(self.sql_client.user, new2) QtGui.QMessageBox.information(self, 'Message', "修改成功!", QtGui.QMessageBox.Yes) else: QtGui.QMessageBox.information(self, 'Message', "旧密码输入错误!", QtGui.QMessageBox.Yes)
def solr_document_searcher(query_string, local): if local: SOLR_URL_PREFIX = SOLR_URL_PREFIX_LOCAL else: SOLR_URL_PREFIX = SOLR_URL_PREFIX_SERVER payload = { 'q': query_string, 'start': '0', 'rows': '100', "facet.field": "snomed_codes", "facet": "on" } r = requests.get(SOLR_URL_PREFIX, params=payload) # print(r.url) search_result = r.json() ''' assert 'response' in search_result, \ 'search_result_parser: no "response" key in search_result object' ''' if 'response' not in search_result: print(search_result) with open('./log.json', 'w') as f: json.dump(search_result, f) else: # preprocess certain non-ascii strings with open('./log.json', 'w') as f: json.dump(search_result, f) response = search_result['response'] for i in range(len(response['docs'])): abstract = response['docs'][i]['abstract'][0] response['docs'][i]['abstract'][0] = unicodedata.normalize( "NFD", abstract) title = response['docs'][i]['title'][0] response['docs'][i]['title'][0] = unicodedata.normalize( "NFD", title) gl._init(response, 'search_result') return search_result
def calculate_tf_idf(search_result, code2n): dsn_uid = "vaclabuser" dsn_pwd = "vaclab206" jdbc_driver_name = "org.postgresql.Driver" connection_string = "jdbc:postgresql://sils-gotz.ad.unc.edu:8032/omop" conn = jaydebeapi.connect(jdbc_driver_name, connection_string, { 'user': dsn_uid, 'password': dsn_pwd }, jars='..\\jar\\postgresql-42.2.12.jar') curs = conn.cursor() code_frequency = search_result['facet_counts']['facet_fields'][ 'snomed_codes'] a = 0 code2tf_idf = {} all_documents = 29137784 while (a <= len(code_frequency) / 2): code = code_frequency[a] tf = math.log(code_frequency[a + 1]) sql_str = "select * from concept where concept.concept_code='" + str( code) + "'" curs.execute(sql_str) result = curs.fetchall() concept = "" if len(result) != 0: concept = result[0][1] idf = math.log(all_documents / int(code2n[code])) tf_idf = tf * idf code2tf_idf[code] = {"value": tf_idf, "concept": concept} a = a + 2 code2tf_idf = { k: v for k, v in sorted(code2tf_idf.items(), key=lambda item: item[1]['value'], reverse=True) } gl._init(code2tf_idf, "tf_idf")
def file_based_convert_examples_to_features(examples, label_list, max_seq_length, tokenizer, output_file): """Convert a set of `InputExample`s to a TFRecord file.""" gl._init() L = '' gl.set_value('pre_deal', L) writer = tf.python_io.TFRecordWriter(output_file) for (ex_index, example) in enumerate(examples): if ex_index % 10000 == 0: tf.logging.info("Writing example %d of %d" % (ex_index, len(examples))) feature = convert_single_example(ex_index, example, label_list, max_seq_length, tokenizer) def create_int_feature(values): f = tf.train.Feature(int64_list=tf.train.Int64List( value=list(values))) return f features = collections.OrderedDict() features["input_ids"] = create_int_feature(feature.input_ids) features["input_mask"] = create_int_feature(feature.input_mask) features["segment_ids"] = create_int_feature(feature.segment_ids) features["label_ids"] = create_int_feature([feature.label_id]) features["is_real_example"] = create_int_feature( [int(feature.is_real_example)]) tf_example = tf.train.Example(features=tf.train.Features( feature=features)) writer.write(tf_example.SerializeToString()) L = gl.get_value('pre_deal') output_predict_file = os.path.join(FLAGS.output_dir, "test_results_3.txt") with tf.gfile.GFile(output_predict_file, "w") as writer: writer.write(L) writer.close()
def __init__(self, Files): gl._init() self.NewVm = GetVm(Files) gl.set_value('NowDate', self.NewVm.starttime) #gl.set_value('Debug',True) gl.set_value('OP', writeCsv()) gl.set_value('LastDate', None) self.NCPool = NCPool(gl.get_value('NowDate')) self.VQ = VmQueue() self.AllCPUCost = 0 self.AllBuyCost = 0 self.AllLoseCost = 0 self.NowMachineNum = 0 self.AllEarnMoney = 0 self.AllBuyServerCost = 0 self.wantUseList = [] conf = Config("./config.json") # 初始化保有量 gl.set_value( "NCKeepNum", { "NT-1-2": conf.readNC("NT-1-2")["initNum"], "NT-1-4": conf.readNC("NT-1-4")["initNum"], "NT-1-8": conf.readNC("NT-1-8")["initNum"] })
def on_pushButton_login_clicked(self): """ Slot documentation goes here. """ username = unicode(self.lineEdit_user.text()) password = unicode(self.lineEdit_password.text()) # 创建SQL客户端。保证全局可用。 global sql_client sql_client = globalvar._init(username, password) if sql_client.check_user(): print "登陆成功" from main import MainWindow self.main_window = MainWindow() self.main_window.show() else: print "用户名或密码错误!"
"Receive_Enable:" + str(globalvar.get_value("Receive_Enable"))) self.lineEdit_Receive_Message.setText( globalvar.get_value("Receive_Message")) def printf_sys_log_Func(self, sys_log_str): self.textBrowser_sys_log.append( time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime()) + globalvar.get_value("TCP_select") + ":" + sys_log_str) #文本框逐条添加数据 self.textBrowser_sys_log.moveCursor( self.textBrowser_sys_log.textCursor().End) #文本框显示到底部 #print(globalvar.set_value("TCP_select")+":"+sys_log_str) if __name__ == '__main__': #全局变量初始化... globalvar._init() globalvar.set_value("TCP_select", "As TCP Client") globalvar.set_value("Server_IP", "192.168.1.200") globalvar.set_value("Server_PORT", "60000") globalvar.set_value("send_Message", "Hello vivo_X21A") globalvar.set_value("Receive_Enable", False) TCP_Socket_tool_Thread = threading.Thread(target=TCP_Socket_tool) TCP_Socket_Receive_Thread = threading.Thread(target=TCP_Socket_Receive) TCP_Socket_tool_Thread.setDaemon(True) TCP_Socket_Receive_Thread.setDaemon(True) TCP_Socket_tool_Thread.start() TCP_Socket_Receive_Thread.start() myApp = QApplication(sys.argv) myWindow = MyDialog()
import sys import os import sqlite3 # 用于数据库 from PyQt5 import QtCore, QtWidgets from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * from PyQt5.QtSql import * from PIL import Image import globalvar as gl from _infoPage_ui import Ui_Info from _modifyPassword import modifyPasswordPage gl._init() # 初始化全局变量管理模块 OpenFilePath = " " def convertToBinaryData(filename): # Convert digital data to binary format with open(filename, 'rb') as file: blobData = file.read() return blobData def updateBLOB(icon, username): try: sqliteConnection = sqlite3.connect('database.db') cursor = sqliteConnection.cursor() sqlite_update_blob_query = """ UPDATE user SET portrait = ? WHERE name = ? """
from matplotlib import pyplot as plt from scipy.interpolate import make_interp_spline from PyQt5.QtWidgets import * from PyQt5 import * from influxdb import InfluxDBClient import globalvar as gl #导入自建的全局变量,用存储所有工位号及其实时数据,内部时字典格式 import gwh as gw #导入工位号全局变量 import shuju as sj #导入数据全局变量 from x import Ui_MainWindow #导入主窗口 import datab import booll, floatt #导入开关阀和调节阀子窗口 import tx, qx gl._init() #全局变量初始化 cgitb.enable() #异常捕捉 lock = QMutex() #实例化锁,针对数据读取和数据刷新两个线程 lock1 = QMutex() #实例化锁,针对自建的全局变量 q = queue.Queue() #实例化队列,针对控制消息获取 #建立全局变量 xp = [] #用于存储AI控件 xpindex = [] xpd = [] #用于存储DI控件 xpdindex = [] xptype = [] xh = [] #用于存储采集的现场信号 jp = [] #存储控件对应的数值索引 address = "" #用于存储TCP服务器地址及端口
from router.testurl import Testurl from router.handle import Handle from router.thirdPartHandle import ThirdPartHandle import logging import pymongo import logging.config urls = ( '/wx', 'Handle', '/wechat/thirdpart/events/listen/(.*?)', 'ThirdPartHandle', '/test', 'Testurl' ) if __name__ == '__main__': gl._init() # logger config logging.config.fileConfig("config/logger.conf") logger = logging.getLogger("example01") gl.set_value('logger', logger) # env config ENV = 'dev' if len(argv) > 2 and argv[2] in ('dev','test','prod'): ENV = argv[2] CONFIG = json.load(open('config/config.json'))[ENV] logger.debug("run environment: %s" % (ENV)) logger.debug("run config: %s" % (CONFIG)) gl.set_value('env', ENV)
def main(): info_focus_dict = {"event":[ { "name":"nicotine", "importance":"10" }, { "name":"tobacco", "importance":"7" }, { "name":"pain", "importance":"5" }, { "name":"opioid", "importance":"3" } ]} #info_focus_dict = {'concepts': [('migraine', 1.0),('pain',0)]} gl._init(load_stopwords(),"_stopwords") ''' ''' # step 1: build search string query_string,key_terms = solr_query_builder(info_focus_dict) # step 2: search solr index print("begin searching") results = solr_document_searcher(query_string, False) print("end") ''' print("find frequent itemset") find_frequent_itemset(results) print("end") print("calculate_tf_idf") calculate_tf_idf(results,code2n) print("end") ''' # step 3: parse search results print("begin parsing") concepts= search_result_parser(results, False,100) print("end") all_concepts = dict(sorted(concepts.items(), key = lambda x: len(x[1].pmids), reverse = True)) frequent_concepts={} codes=[] for cui,concept in all_concepts.items(): snomed_codes=list(concept.snomed_codes)[0] for code in snomed_codes: if code not in codes: codes.append(code) if len(codes)==30: break; gl._init(snomed_codes,"snomed_codes") dag_builder()
self.btn3.clicked.connect(self.click_btn3) self.btn4.clicked.connect(self.click_btn4) self.btn5.clicked.connect(self.click_btn5) def click_btn1(self): self.window1.beam_combobox_init() self.window1.show() def click_btn2(self): self.window2.show() def click_btn3(self): self.window3.show() def click_btn4(self): self.window4.show() def click_btn5(self): # filepath = str(os.getcwd() + 'main/Instruction_Manual.pdf') # now go to Github webbrowser.open(r'https://github.com/KanruXie/Virtual_Linac') if __name__ == '__main__': glv._init() beam_dict._init() app = QApplication(sys.argv) w = MainWindow() w.show() app.exec_()
import pygame import sys from rider import * import threading import output import globalvar as gl gl._init() # initialize pygame.init() # initialize gl.set_value('bianhao', 0) # 初始化骑手编号 # 转换坐标函数 def change(coordinate): pos = [] pos.append((coordinate[0] // 100) * 100 + 50) pos.append((coordinate[1] // 100) * 100 + 100) pos.append((coordinate[2] // 100) * 100 + 50) pos.append((coordinate[3] // 100) * 100 + 100) return pos def main(): # 初始化 clock = pygame.time.Clock() coordinate = [] # 坐标 gl.set_value('money', 1000) # 设置钱 gl.set_value('riders', []) gl.set_value('running', True) t = threading.Thread(target=output.cartoon_output)