def __init__(self): QtGui.QMainWindow.__init__(self) Ui_MainWindow.__init__(self) self.setupUi(self) self.setWindowTitle("自动选课器") icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap("./source/logo.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.setWindowIcon(icon) self.get_captcha.clicked.connect(self.connect_to_captcha) self.response = requests.session() self.connect_to_captcha_thread = None
def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.fname = None self.page = None self.ui.toolButton.clicked.connect(self.fname_pages_dialog) self.ui.pushButton.clicked.connect(self.convert) self.DB = shelve.open('DB.txt') self.DB['Template1'] = ['\d\d-\d\d-\d\d','\n(Tue|Wed|Fri|Thu|Mon|Sat|Sun)','[^\n:]\d\d:\d\d','Voice','\d{7,}',r'\bL\b',r'\b(1|2|3)\b\n',r'\bO-P\b',r'\b00:\d\d:\d\d\b',r'\bH:M:S\b',r'\b\d+,\d+\b'] self.DB.close() self.enum_temp() self.ui.comboBox.currentIndexChanged.connect(self.enum_temp) self.ui.pushButton_2.clicked.connect(self.save_temp)
class TestUI(QMainWindow, Ui_MainWindow): frame_signal = pyqtSignal(QImage) def __init__(self): super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.__video_thread = VideoThread("rtsp://172.16.1.87", self.frame_signal) self.__video_thread.start() #loadUi("test.ui", self) # btn = QPushButton(self) # lbl = QLabel(self) # self.setMouseTracking(True) # # # #self.label.mouseReleaseEvent.connect(self.mouseClick_label) # self.frame_signal.connect(self.video_play) # self.pushButton.clicked.connect(self.mouseClick_label) self.ui.label.clicked.connect(self.mouseClick_label) self.move(100, 100) self.show() def mouseClick_label(self, event): print(event.pos()) print(360 / self.ui.label.height()) x = event.pos().x() * 480 / self.ui.label.width() y = event.pos().y() * 360 / self.ui.label.height() print(y) self.__video_thread.list_point.append((int(x), int(y))) def video_play(self, sender): pixmap = QPixmap().fromImage(sender) pixmap2 = pixmap.scaled(self.ui.label.width(), self.ui.label.height()) self.ui.label.setPixmap(pixmap2) self.ui.label_2.setPixmap(pixmap)
def __init__(self): QtGui.QMainWindow.__init__(self) Ui_MainWindow.__init__(self) self.setupUi(self) self.setWindowTitle("自动选课器") icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap("./source/logo.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.setWindowIcon(icon) self.login.clicked.connect(self.run) self.get_course_info.triggered.connect(self.get_course_info_func) self.response = requests.session() self.download_captcha_is_done = 0 self.cookie = "" self.auto_email = EmailUser() self.connect_to_captcha_thread = None self.download_captcha_thread = None self.get_course_info_thread = None self.connect_to_login_thread = None self.post_course_thread = None self.get_captcha_()
def __init__(self): super(mywindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) # TODO deberia crear self.ui.canvas aqui self.dotSize = 5 self.borderSize = 3 self.penWhite = QPen(Qt.white, self.borderSize) self.penRed = QPen(Qt.red, self.borderSize) self.penGreen = QPen(Qt.green, self.borderSize) self.penOrange = QPen(QColor(243, 156, 18), self.borderSize) self.brushWhite = QBrush(Qt.white) self.r = Random() rec = self.ui.canvas.sceneRect() self.image = QImage(int(rec.width()), int(rec.height()), QImage.Format_RGB32) # self.image.fill(0) self.painter = QPainter(self.image) self.painter.setRenderHint(QPainter.Antialiasing)
def __init__(self): super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.__video_thread = VideoThread("rtsp://172.16.1.87", self.frame_signal) self.__video_thread.start() #loadUi("test.ui", self) # btn = QPushButton(self) # lbl = QLabel(self) # self.setMouseTracking(True) # # # #self.label.mouseReleaseEvent.connect(self.mouseClick_label) # self.frame_signal.connect(self.video_play) # self.pushButton.clicked.connect(self.mouseClick_label) self.ui.label.clicked.connect(self.mouseClick_label) self.move(100, 100) self.show()
def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.DB = shelve.open('DB.txt') self.DB['HRM_Trunk'] = [r'C:\ProgramData\Experium_DB_TRUNK_HRM', r'C:\Program Files\EXPERIUM_DB_TRUNK_HRM','0','0'] self.DB['HRM_Release'] = [r'C:\ProgramData\Experium_DB_RELEASE_HRM', r'C:\Program Files\EXPERIUM_DB_RELEASE_HRM','0','1'] self.DB['AGN_Trunk'] = [r'C:\ProgramData\Experium_DB_TRUNK_KA', r'C:\Program Files\EXPERIUM_DB_TRUNK','1','0'] self.DB['AGN_Release'] = [r'C:\ProgramData\Experium_DB_RELEASE_KA', r'C:\Program Files\EXPERIUM_DB_RELEASE_RA','1','1'] self.trunk_expcl_path = r'X:\ExperiumTrunk' self.release_expcl_path = r'X:\ExperiumRelease' self.cl_exp_path = r'C:\Program Files\Experium' self.ui.lineEdit_7.setText(self.cl_exp_path) self.ui.lineEdit_3.setText(self.DB['HRM_Trunk'][0]) self.ui.lineEdit_6.setText(self.DB['HRM_Trunk'][1]) self.type_flag = (self.DB['HRM_Trunk'][2]) self.trunk_flag = (self.DB['HRM_Trunk'][3]) self.ui.comboBox.currentIndexChanged.connect(self.db_change) self.cl_localdata_path = r'C:\Users\win7_test\AppData\Roaming\Experium\Client' self.data_trunk_path = r'X:\ExperiumTrunk\DB' self.data_release_path = r'X:\ExperiumRelease\DB' self.X_serv_release_path = r'X:\winserverexe\newexe' self.X_serv_trunk_path = r'X:\winserverexe\newexe\trunkexe' self.clientupd = [r'\Experium.exe',r'\expenu.dll',r'\exprus.dll',r'\GCalDav.dll',r'\MailEngine.dll',r'\SMSEngine.dll',r'\Telephony.dll'] self.srvupd = [r'\exp_srv.exe',r'\sdatacnv.exe',r'\sdatasrv.exe',r'\sexpsrv.exe',r'\smetasrch.exe',r'\smetasrv.exe',r'\srmeta.exe',r'\wcnvnode.exe',r'\wdatacnv.exe',r'\wdatasrv.exe',r'\wmetasrch.exe',r'\wmetasrv.exe',r'\wrmeta.exe'] self.localdatas = [r'C:\Users\win7_test\AppData\Roaming\Experium\Client'] self.J = Jenkins('http://buildsrv.experium.ru/', username="******", password="******") self.ui.comboBox_2.addItems(self.J.keys()) self.ui.calendarWidget.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.calendarWidget.setWindowTitle('Calendar for Redmine') self.ui.widget.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.widget.setWindowTitle('Database Info') self.ui.widget.setWindowModality(QtCore.Qt.WindowModal) self.ui.widget_2.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.widget_2.setWindowTitle('API Options') self.ui.widget_2.setWindowModality(QtCore.Qt.WindowModal) self.ui.pushButton.clicked.connect(self.enumver) self.ui.pushButton_7.clicked.connect(self.clrlocal_cl) self.ui.pushButton_11.clicked.connect(self.jenkins_build) self.ui.pushButton_9.clicked.connect(self.ui.textBrowser.clear) self.ui.pushButton_3.clicked.connect(lambda: self.start_thread(self.start)) self.ui.pushButton_4.clicked.connect(lambda: self.start_thread(self.stop)) self.ui.pushButton_6.clicked.connect(lambda: self.start_thread(self.update_cl)) self.ui.pushButton_5.clicked.connect(lambda: self.start_thread(self.start_cl)) self.ui.pushButton_2.clicked.connect(lambda: self.start_thread(self.update)) self.ui.pushButton_10.clicked.connect(self.jenkins) self.ui.pushButton_8.clicked.connect(self.redmine) self.ui.pushButton_12.clicked.connect(lambda: self.start_thread(self.update_db)) self.ui.pushButton_13.clicked.connect(lambda: self.start_thread(self.stop_cl)) self.ui.pushButton_14.clicked.connect(self.jenkins_queue) self.ui.pushButton_18.clicked.connect(lambda: self.start_thread(self.ess)) self.ui.pushButton_19.clicked.connect(self.ui.widget_2.show) self.ui.pushButton_17.clicked.connect(self.calendar) self.ui.pushButton_15.clicked.connect(self.prep_deploy_databases) self.ui.pushButton_22.clicked.connect(self.deploy_database) self.ui.pushButton_16.clicked.connect(self.uninstall_databases) self.ui.pushButton_24.clicked.connect(self.clear_opt) self.ui.comboBox_4.customContextMenuRequested.connect(self.openMenu) try: self.ui.comboBox_4.addItems(self.DB['SConfig']) if self.ui.comboBox_4.currentText() == '': self.ui.comboBox_4.addItem('127.0.0.1') except: self.ui.comboBox_4.addItem('127.0.0.1') self.logger = Logger(self.ui.textBrowser) sys.stdout = self.logger for k in self.DB.keys(): if not k in ['HRM_Trunk','HRM_Release','AGN_Trunk','AGN_Release']: self.ui.comboBox.addItem(k) self.DB.close() self.t_time = None self.ui.calendarWidget.selectionChanged.connect(lambda: self.start_thread(self.redmine_anyday)) self.movie = QMovie("exp.gif", QByteArray(), self) self.movie.setCacheMode(QMovie.CacheAll) self.movie.setSpeed(100) self.ui.label_8.setMovie(self.movie)
class MainWindow(QMainWindow): """MainWindow inherits QMainWindow""" def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.DB = shelve.open('DB.txt') self.DB['HRM_Trunk'] = [r'C:\ProgramData\Experium_DB_TRUNK_HRM', r'C:\Program Files\EXPERIUM_DB_TRUNK_HRM','0','0'] self.DB['HRM_Release'] = [r'C:\ProgramData\Experium_DB_RELEASE_HRM', r'C:\Program Files\EXPERIUM_DB_RELEASE_HRM','0','1'] self.DB['AGN_Trunk'] = [r'C:\ProgramData\Experium_DB_TRUNK_KA', r'C:\Program Files\EXPERIUM_DB_TRUNK','1','0'] self.DB['AGN_Release'] = [r'C:\ProgramData\Experium_DB_RELEASE_KA', r'C:\Program Files\EXPERIUM_DB_RELEASE_RA','1','1'] self.trunk_expcl_path = r'X:\ExperiumTrunk' self.release_expcl_path = r'X:\ExperiumRelease' self.cl_exp_path = r'C:\Program Files\Experium' self.ui.lineEdit_7.setText(self.cl_exp_path) self.ui.lineEdit_3.setText(self.DB['HRM_Trunk'][0]) self.ui.lineEdit_6.setText(self.DB['HRM_Trunk'][1]) self.type_flag = (self.DB['HRM_Trunk'][2]) self.trunk_flag = (self.DB['HRM_Trunk'][3]) self.ui.comboBox.currentIndexChanged.connect(self.db_change) self.cl_localdata_path = r'C:\Users\win7_test\AppData\Roaming\Experium\Client' self.data_trunk_path = r'X:\ExperiumTrunk\DB' self.data_release_path = r'X:\ExperiumRelease\DB' self.X_serv_release_path = r'X:\winserverexe\newexe' self.X_serv_trunk_path = r'X:\winserverexe\newexe\trunkexe' self.clientupd = [r'\Experium.exe',r'\expenu.dll',r'\exprus.dll',r'\GCalDav.dll',r'\MailEngine.dll',r'\SMSEngine.dll',r'\Telephony.dll'] self.srvupd = [r'\exp_srv.exe',r'\sdatacnv.exe',r'\sdatasrv.exe',r'\sexpsrv.exe',r'\smetasrch.exe',r'\smetasrv.exe',r'\srmeta.exe',r'\wcnvnode.exe',r'\wdatacnv.exe',r'\wdatasrv.exe',r'\wmetasrch.exe',r'\wmetasrv.exe',r'\wrmeta.exe'] self.localdatas = [r'C:\Users\win7_test\AppData\Roaming\Experium\Client'] self.J = Jenkins('http://buildsrv.experium.ru/', username="******", password="******") self.ui.comboBox_2.addItems(self.J.keys()) self.ui.calendarWidget.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.calendarWidget.setWindowTitle('Calendar for Redmine') self.ui.widget.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.widget.setWindowTitle('Database Info') self.ui.widget.setWindowModality(QtCore.Qt.WindowModal) self.ui.widget_2.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.widget_2.setWindowTitle('API Options') self.ui.widget_2.setWindowModality(QtCore.Qt.WindowModal) self.ui.pushButton.clicked.connect(self.enumver) self.ui.pushButton_7.clicked.connect(self.clrlocal_cl) self.ui.pushButton_11.clicked.connect(self.jenkins_build) self.ui.pushButton_9.clicked.connect(self.ui.textBrowser.clear) self.ui.pushButton_3.clicked.connect(lambda: self.start_thread(self.start)) self.ui.pushButton_4.clicked.connect(lambda: self.start_thread(self.stop)) self.ui.pushButton_6.clicked.connect(lambda: self.start_thread(self.update_cl)) self.ui.pushButton_5.clicked.connect(lambda: self.start_thread(self.start_cl)) self.ui.pushButton_2.clicked.connect(lambda: self.start_thread(self.update)) self.ui.pushButton_10.clicked.connect(self.jenkins) self.ui.pushButton_8.clicked.connect(self.redmine) self.ui.pushButton_12.clicked.connect(lambda: self.start_thread(self.update_db)) self.ui.pushButton_13.clicked.connect(lambda: self.start_thread(self.stop_cl)) self.ui.pushButton_14.clicked.connect(self.jenkins_queue) self.ui.pushButton_18.clicked.connect(lambda: self.start_thread(self.ess)) self.ui.pushButton_19.clicked.connect(self.ui.widget_2.show) self.ui.pushButton_17.clicked.connect(self.calendar) self.ui.pushButton_15.clicked.connect(self.prep_deploy_databases) self.ui.pushButton_22.clicked.connect(self.deploy_database) self.ui.pushButton_16.clicked.connect(self.uninstall_databases) self.ui.pushButton_24.clicked.connect(self.clear_opt) self.ui.comboBox_4.customContextMenuRequested.connect(self.openMenu) try: self.ui.comboBox_4.addItems(self.DB['SConfig']) if self.ui.comboBox_4.currentText() == '': self.ui.comboBox_4.addItem('127.0.0.1') except: self.ui.comboBox_4.addItem('127.0.0.1') self.logger = Logger(self.ui.textBrowser) sys.stdout = self.logger for k in self.DB.keys(): if not k in ['HRM_Trunk','HRM_Release','AGN_Trunk','AGN_Release']: self.ui.comboBox.addItem(k) self.DB.close() self.t_time = None self.ui.calendarWidget.selectionChanged.connect(lambda: self.start_thread(self.redmine_anyday)) self.movie = QMovie("exp.gif", QByteArray(), self) self.movie.setCacheMode(QMovie.CacheAll) self.movie.setSpeed(100) self.ui.label_8.setMovie(self.movie) #self.movie.start() def mstart(self): """sart animnation""" self.movie.start() def mstop(self): """stop the animation""" self.movie.stop() def openMenu(self, position): menu = QMenu() deleteAction = menu.addAction("Delete") clearAction = menu.addAction("ClearAll") savetoDBAction = menu.addAction("SaveToDB") action = menu.exec_(self.ui.comboBox_4.mapToGlobal(position)) if action == deleteAction: self.ui.comboBox_4.removeItem(self.ui.comboBox_4.currentIndex()) elif action == clearAction: self.ui.comboBox_4.clear() elif action == savetoDBAction: DB = shelve.open('DB.txt') DB['SConfig'] = [self.ui.comboBox_4.itemText(i) for i in range(self.ui.comboBox_4.count())] DB.close() def output_to_box(self, text): print(text.toUtf8()) def prep_deploy_databases(self): self.ui.widget.show() self.ui.pushButton_22.setEnabled(False) self.DB_name, ok = QtGui.QInputDialog.getText(self, 'DBName', 'Enter DB name:') self.ui.lineEdit_9.setText(str(self.DB_name)) self.DB_serv_path = QtGui.QFileDialog.getExistingDirectory(self, 'Select DB Server Path','/') self.ui.lineEdit_4.setText(str(self.DB_serv_path)) self.DB_data_path = QtGui.QFileDialog.getExistingDirectory(self, 'Select DB Data Path','/') self.ui.lineEdit_5.setText(str(self.DB_data_path)) if str(self.DB_name) !='' and str(self.DB_data_path) !='' and str(self.DB_serv_path) !='': self.ui.pushButton_22.setEnabled(True) def deploy_database(self): if self.ui.radioButton.isChecked(): type_flag = '0' elif self.ui.radioButton_2.isChecked(): type_flag = '1' else: return(0) if self.ui.radioButton_4.isChecked(): trunk_flag = '0' elif self.ui.radioButton_3.isChecked(): trunk_flag = '1' else: return(0) self.DB = shelve.open('DB.txt') self.DB[str(self.DB_name)] = [str(self.DB_data_path),str(self.DB_serv_path),type_flag,trunk_flag] self.DB.close() self.ui.widget.hide() self.ui.comboBox.addItem(str(self.DB_name)) wdatasrv = open('wdatasrv.par','r') wdatasrv1 = open('wdatasrv1.par','w') wmetasrv1 = open('wmetasrv1.par','w') wmetasrv = open('wmetasrv.par','r') srvini = open('exp_srv.ini','r') srvini1 = open('exp_srv1.ini','w') text = wdatasrv.read() wdatasrv1.write(text.replace('DB_data_path',str(self.DB_data_path))) text = wmetasrv.read() wmetasrv1.write(text.replace('DB_data_path',str(self.DB_data_path))) text = srvini.read() srvini1.write(text.replace('DB_serv_path',str(self.DB_serv_path))) srvini.close() srvini1.close() wdatasrv.close() wdatasrv1.close() wmetasrv.close() wmetasrv1.close() self.wid_write('copy /Y "wdatasrv1.par" "%s\wdatasrv.par"') % str(self.DB_serv_path) self.wid_write('copy /Y "wmetasrv1.par" "%s\wmetasrv.par"') % str(self.DB_serv_path) self.wid_write('copy /Y "exp_srv1.ini" "%s\exp_srv.ini"') % str(self.DB_serv_path) def uninstall_databases(self): self.DB = shelve.open('DB.txt') if not self.ui.comboBox.currentText() in ['HRM_Trunk','HRM_Release','AGN_Trunk','AGN_Release']: self.DB.pop(str(self.ui.comboBox.currentText())) self.ui.comboBox.removeItem(self.ui.comboBox.currentIndex()) def wid_write(self, cmd): PIPE = subprocess.PIPE p = subprocess.Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=subprocess.STDOUT) print p.stdout.read() def start_thread(self, meth): threading.Thread(target=meth).start() def clrlocal_cl(self): for f in self.localdatas: self.wid_write('RMDIR /s /Q '+f) def jenkins(self): self.thread2 = Thread2(self) self.thread2.message2[str].connect(self.output_to_box) self.thread2.start() def redmine(self): self.thread1 = Thread1(self) self.thread1.message1[str].connect(self.output_to_box) self.thread1.start() def ess(self): import requests url = 'http://msmeta6.experium.ru/SupportSrv/SupportSrv.svc/Support/control' payload = {'command':'grep'} ess = '' win32clipboard.OpenClipboard() ess = win32clipboard.GetClipboardData() win32clipboard.CloseClipboard() print('***'+ess+'***') r = requests.post(url, auth=('support', 'c5128437'), params=payload, json={'id': ''+str(ess)+''}) print(r.text.encode('latin1')) print(r.status_code) def jenkins_build(self): j = self.J.get_job(self.ui.comboBox_2.currentText()) if not j.is_queued_or_running(): self.J.build_job(self.ui.comboBox_2.currentText()) def jenkins_queue(self): self.thread4 = Thread4(self) self.thread4.message4[str].connect(self.output_to_box) self.thread4.signal_start[str].connect(self.mstart) self.thread4.signal_stop[str].connect(self.mstop) self.thread4.start() def calendar(self): self.ui.calendarWidget.show() def redmine_anyday(self): self.thread3 = Thread3(self) self.thread3.message3[str].connect(self.output_to_box) self.thread3.start() def update_cl(self): if self.ui.checkBox_4.isChecked(): if self.ui.checkBox_2.isChecked(): self.wid_write("taskkill /im experium.exe") time.sleep(3) for f in self.clientupd: self.wid_write('copy /Y "'+self.trunk_expcl_path+f+'" "'+self.cl_exp_path+f+'"') else: self.wid_write("taskkill /im experium.exe") time.sleep(3) for f in self.clientupd: self.wid_write('copy /Y "'+self.release_expcl_path+f+'" "'+self.cl_exp_path+f+'"') for f in self.localdatas: self.wid_write('RMDIR /s /Q '+f) if self.ui.checkBox_3.isChecked(): self.wid_write("taskkill /t /im exp_srv.exe") time.sleep(15) self.wid_write("taskkill /t /im wdatacnv.exe") if self.ui.checkBox_2.isChecked(): for f in self.srvupd: self.wid_write('copy /Y "'+self.X_serv_trunk_path+f+'" "'+self.cl_exp_path+f+'"') else: for f in self.srvupd: self.wid_write('copy /Y "'+self.X_serv_release_path+f+'" "'+self.cl_exp_path+f+'"') print('DONE!!!') def start_cl(self): config = open(self.cl_exp_path + '\config.ini', 'r') regex = re.compile(r"^.*Server.*$") text2 = [] for line in config.readlines(): text2.append(regex.sub('Server=' + str(re.findall('[^ ()]+', str(self.ui.comboBox_4.currentText()))[0]), line)) config.close() config = open(self.cl_exp_path + '\config.ini', 'w') config.writelines(text2) config.close() for i in range(int(self.ui.comboBox_3.currentIndex())+1): os.startfile(self.cl_exp_path+'\experium.exe') if self.ui.checkBox_3.isChecked(): os.startfile(self.cl_exp_path+'\exp_srv.exe') time.sleep(10) self.wid_write("taskkill /im wdatacnv.exe") time.sleep(3) os.startfile(self.cl_exp_path+'\wdatacnv.exe') def stop_cl(self): self.wid_write("taskkill /im experium.exe") if self.ui.checkBox_3.isChecked(): self.wid_write("taskkill /t /im exp_srv.exe") time.sleep(15) self.wid_write("taskkill /t /im wdatacnv.exe") print('DONE!!!') def start(self): self.server = str(self.ui.lineEdit_6.displayText()) self.wid_write('RMDIR /s /Q '+self.cl_localdata_path) self.stop() self.ui.pushButton_3.setEnabled(False) self.ui.comboBox.setEnabled(False) self.wid_write('sc create SDataSrv binPath= "'+self.server+'\sdatasrv.exe" type= own start= demand error= normal"') self.wid_write('sc create SMetaSrch binPath= "'+self.server+'\smetasrch.exe" type= own start= demand error= normal"') self.wid_write('sc create SMetaSrv binPath= "'+self.server+'\smetasrv.exe" type= own start= demand error= normal"') self.wid_write('sc create SDataCnv binPath= "'+self.server+'\sdatacnv.exe" type= own start= demand error= normal"') self.wid_write('sc create ExperiumLauncherService binPath= "'+self.server+'\sexpsrv.exe" type= own start= auto error= normal"') self.wid_write('sc start "ExperiumLauncherService"') print('DONE!!!') def stop(self): self.server = str(self.ui.lineEdit_6.displayText()) self.wid_write('sc stop "ExperiumLauncherService"') self.wid_write('sc delete "SDataSrv"') self.wid_write('sc delete "SDataCnv"') self.wid_write('sc delete "SMetaSrch"') self.wid_write('sc delete "SMetaSrv"') self.wid_write('sc delete "ExperiumLauncherService"') self.ui.pushButton_3.setEnabled(True) self.ui.comboBox.setEnabled(True) print('DONE!!!') def update(self): self.server = str(self.ui.lineEdit_6.displayText()) self.stop() print(str(self.trunk_flag)) print(str(self.type_flag)) if str(self.trunk_flag) == '0': for f in self.srvupd: self.wid_write('copy /Y "'+self.X_serv_trunk_path+f+'" "'+self.server+f+'"') if str(self.trunk_flag) == '1': for f in self.srvupd: self.wid_write('copy /Y "'+self.X_serv_release_path+f+'" "'+self.server+f+'"') if self.ui.checkBox.isChecked(): for f in self.srvupd: self.wid_write('copy /Y "'+self.X_serv_trunk_path+f+'" "'+self.server+f+'"') print('DONE!!!') def update_db(self): data_path = str(self.ui.lineEdit_3.displayText()) self.server = str(self.ui.lineEdit_6.displayText()) self.stop() if str(self.trunk_flag) == '0': X_path = self.data_trunk_path if str(self.type_flag) == '0': base1 = 'db0hr.zip' if str(self.type_flag) == '1': base1 = 'db0ra.zip' if str(self.trunk_flag) == '1': X_path = self.data_release_path if str(self.type_flag) == '0': base1 = 'db0hr.zip' if str(self.type_flag) == '1': base1 = 'db0ra.zip' base = r'\\'+base1 self.wid_write('RMDIR /s /Q '+data_path+'\BACKUPDATA') self.wid_write('RMDIR /s /Q '+data_path+'\DATASERVERDATA') self.wid_write('RMDIR /s /Q '+data_path+'\METASERVERDATA') self.wid_write('copy /Y "'+X_path+base+'" "'+data_path+base+'"') z = ZipFile(data_path+base,'r') z.extractall(data_path) z.close() self.wid_write('DEL /Q '+data_path+base) print('DONE!!!') def db_change(self): self.DB = shelve.open('DB.txt') DB_name = str(self.ui.comboBox.currentText()) self.ui.lineEdit_3.setText(self.DB[DB_name][0]) self.ui.lineEdit_6.setText(self.DB[DB_name][1]) self.type_flag = str(self.DB[DB_name][2]) self.trunk_flag = str(self.DB[DB_name][3]) self.DB.close() def enumver(self): versions = [re.findall(r'\d{4,}',f) for f in os.listdir(self.trunk_expcl_path)] self.ui.lineEdit.setText("TRUNK "+str(max(versions))) versions = [re.findall(r'\d{4,}',f) for f in os.listdir(self.release_expcl_path)] self.ui.lineEdit_2.setText("RELEASE "+str(max(versions))) def clear_opt(self): self.ui.lineEdit_10.clear() self.ui.lineEdit_11.clear() self.ui.lineEdit_12.clear() self.ui.lineEdit_13.clear() self.ui.lineEdit_14.clear() self.test = QtGui.QFileDialog.getOpenFileName(self, 'Выберите файл для отправки') print (self.test) def save_opt(self): """TODO""" def __del__(self): self.ui = None
class MainWindow(QMainWindow): """MainWindow inherits QMainWindow""" def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.fname = None self.page = None self.ui.toolButton.clicked.connect(self.fname_pages_dialog) self.ui.pushButton.clicked.connect(self.convert) self.DB = shelve.open('DB.txt') self.DB['Template1'] = ['\d\d-\d\d-\d\d','\n(Tue|Wed|Fri|Thu|Mon|Sat|Sun)','[^\n:]\d\d:\d\d','Voice','\d{7,}',r'\bL\b',r'\b(1|2|3)\b\n',r'\bO-P\b',r'\b00:\d\d:\d\d\b',r'\bH:M:S\b',r'\b\d+,\d+\b'] self.DB.close() self.enum_temp() self.ui.comboBox.currentIndexChanged.connect(self.enum_temp) self.ui.pushButton_2.clicked.connect(self.save_temp) def enum_temp(self): template = str(self.ui.comboBox.currentText()) self.DB = shelve.open('DB.txt') self.ui.lineEdit_2.setText(str(self.DB[template][0])) self.ui.lineEdit_3.setText(str(self.DB[template][1])) self.ui.lineEdit_4.setText(str(self.DB[template][2])) self.ui.lineEdit_5.setText(str(self.DB[template][3])) self.ui.lineEdit_6.setText(str(self.DB[template][4])) self.ui.lineEdit_7.setText(str(self.DB[template][5])) self.ui.lineEdit_8.setText(str(self.DB[template][6])) self.ui.lineEdit_9.setText(str(self.DB[template][7])) self.ui.lineEdit_10.setText(str(self.DB[template][8])) self.ui.lineEdit_11.setText(str(self.DB[template][9])) self.ui.lineEdit_12.setText(str(self.DB[template][10])) self.DB.close() def save_temp(self): self.DB = shelve.open('DB.txt') template = str(self.ui.comboBox.currentText()) if template != 'Template1': self.DB[template] = [str(self.ui.lineEdit_2.text()), str(self.ui.lineEdit_3.text()), str(self.ui.lineEdit_4.text()), str(self.ui.lineEdit_5.text()), str(self.ui.lineEdit_6.text()), str(self.ui.lineEdit_7.text()), str(self.ui.lineEdit_8.text()), str(self.ui.lineEdit_9.text()), str(self.ui.lineEdit_10.text()), str(self.ui.lineEdit_11.text()), str(self.ui.lineEdit_12.text())] self.DB.close() def fname_pages_dialog(self): self.fname = QFileDialog.getOpenFileName(self,'Open PDF','/') self.pages = [] try: self.truepage = QInputDialog.getText(self,'Page select','Enter page number') for tp in list(self.truepage[0].split(',')): self.pages.append(int(tp)) except: pass self.ui.lineEdit.setText(str(self.fname)) def convert(self): self.ui.progressBar.setValue(0) if not self.pages: pagenums = set() else: pagenums = set(self.pages) output = StringIO() manager = PDFResourceManager() converter = TextConverter(manager, output, laparams=LAParams()) interpreter = PDFPageInterpreter(manager, converter) infile = file(self.fname, 'rb') for page in PDFPage.get_pages(infile, pagenums): interpreter.process_page(page) infile.close() converter.close() data = output.getvalue() output.close #print(data) style1 = xlwt.easyxf('font: bold off; align: wrap off, vert centre, horiz center; borders: top thin, bottom thin, left thin, right thin;') style1.num_format_str = 'DD-MM-YY' style2 = xlwt.easyxf('font: bold off; align: wrap off, vert centre, horiz center; borders: top thin, bottom thin, left thin, right thin;') style2.num_format_str = 'HH:MM' style4 = xlwt.easyxf('font: bold off; align: wrap off, vert centre, horiz center; borders: top thin, bottom thin, left thin, right thin;') style4.num_format_str = 'HH:MM:SS' style0 = xlwt.easyxf('font: bold off; align: wrap off, vert centre, horiz left; borders: top thin, bottom thin, left thin, right thin;') style3 = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center; borders: top double, bottom double, left double, right double;') style5 = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center; borders: top double, bottom double, left double, right double;') style5.num_format_str = '[h]:mm:ss;@' wb = xlwt.Workbook() ws = wb.add_sheet('A Test Sheet') ws.write(3,0,'Day',style3) ws.write(3,1,'Date',style3) ws.write(3,2,'Time',style3) ws.write(3,3,'E/Stn',style3) ws.write(3,4,'Service Name',style3) ws.write(3,5,'Destination',style3) ws.write(3,6,'Code',style3) ws.write(3,7,'Band',style3) ws.write(3,8,'Peak/Off-Peak',style3) ws.write(3,9,'Amount',style3) ws.write(3,10,'Unit',style3) ws.write(3,11,'Cost',style3) ws.write(3,12,'Tarif',style3) ws.write(3,13,'Cost_2',style3) i = 4 self.ui.progressBar.setValue(10) #regDate = '\d\d-\d\d-\d\d' regDate = str(self.ui.lineEdit_2.text()) matchesDate = re.findall(regDate, data) #print(matchesDate) #print(len(matchesDate)) for Date in matchesDate: #outfp.write(Date+'\n') ws.write(i,1,Date,style1) i +=1 i = 4 #regDay = '\n(Tue|Wed|Fri|Thu|Mon|Sat|Sun)' regDay = str(self.ui.lineEdit_3.text()) matchesDay = re.findall(regDay, data) for Day in matchesDay: #outfp.write(Day+'\n') ws.write(i,0,Day,style0) i +=1 i = 4 k = 0 self.ui.progressBar.setValue(20) #regTime = '[^\n:]\d\d:\d\d' regTime = str(self.ui.lineEdit_4.text()) matchesTime = re.findall(regTime, data) #print(matchesTime) #print(len(matchesTime)) while k < len(matchesDate): #outfp.write(Time+'\n') ws.write(i,2,matchesTime[k],style2) k+=1 i+=1 i = 4 k = 0 #regService = 'Voice' regService = str(self.ui.lineEdit_5.text()) matchesService = re.findall(regService, data) #print(matchesService) #print(len(matchesService)) while k < len(matchesDate): #outfp.write(Day+'\n') ws.write(i,4,matchesService[k],style0) i+=1 k+=1 i = 4 k = 0 self.ui.progressBar.setValue(30) trueDest = [] truedest2 = [] regDest = str(self.ui.lineEdit_6.text()) #regDest = '\d{7,}' matchesDest = re.findall(regDest, data) ws.write(0,0,'Mobile No',style3) ws.write(0,1,matchesDest[0],style3) #print(matchesDest) #print(len(matchesDest)) for Dest in matchesDest: if Dest != matchesDest[0]: #outfp.write(Day+'\n') trueDest.append(Dest) while k < len(matchesDate): ws.write(i,5,trueDest[k],style0) truedest2.append(trueDest[k][0:4]) i+=1 k+=1 #print(len(truedest2)) #print(truedest2) i = 4 k = 0 self.ui.progressBar.setValue(40) regCode = str(self.ui.lineEdit_7.text()) #regCode = r'\bL\b' matchesCode = re.findall(regCode, data) #print(matchesCode) #print(len(matchesCode)) while k < len(matchesDate): #outfp.write(Day+'\n') ws.write(i,6,matchesCode[k],style0) i+=1 k+=1 i = 4 k = 0 self.ui.progressBar.setValue(50) regBand = str(self.ui.lineEdit_8.text()) #regBand = r'\b(1|2|3)\b\n' matchesBand = re.findall(regBand, data) #print(matchesBand) #print(len(matchesBand)) while k < len(matchesDate): #outfp.write(Day+'\n') ws.write(i,7,matchesBand[k],style0) i+=1 k+=1 i = 4 k = 0 self.ui.progressBar.setValue(60) regPeak = str(self.ui.lineEdit_9.text()) #regPeak = r'\bO-P\b' matchesPeak = re.findall(regPeak, data) #print(matchesPeak) #print(len(matchesPeak)) while k < len(matchesDate): #outfp.write(Day+'\n') ws.write(i,8,matchesPeak[k],style0) i+=1 k+=1 i = 4 k = 0 self.ui.progressBar.setValue(70) regAmount = str(self.ui.lineEdit_10.text()) #regAmount = r'\b00:\d\d:\d\d\b' matchesAmount = re.findall(regAmount, data) #print(matchesAmount) #print(len(matchesAmount)) while k < len(matchesDate): #outfp.write(Day+'\n') hms = matchesAmount[k].split(':') ws.write(i,9,datetime.time(int(hms[0]),int(hms[1]),int(hms[2])),style4) i+=1 k+=1 i = 4 regUnit = str(self.ui.lineEdit_11.text()) #regUnit = r'\bH:M:S\b' matchesUnit = re.findall(regUnit, data) #print(matchesUnit) #print(len(matchesUnit)) for Unit in matchesUnit: #outfp.write(Day+'\n') ws.write(i,10,Unit,style0) i+=1 i = 4 k = 0 self.ui.progressBar.setValue(80) regCost = str(self.ui.lineEdit_12.text()) #regCost = r'\b\d+,\d+\b' matchesCost = re.findall(regCost, data) #print(matchesCost) #print(len(matchesCost)) while k < len(matchesDate): #outfp.write(Day+'\n') ws.write(i,11,float(matchesCost[k].replace(',','.')),style0) i+=1 k+=1 i = 4 k = 0 self.ui.progressBar.setValue(90) tarif = {} try: tariff = file('tarif.txt', 'r') tarif = pickle.load(tariff) tariff.close() #print(tarif) except: pass while k < len(matchesDate): if tarif.has_key(truedest2[k]): #outfp.write(Day+'\n') ws.write(i,12,tarif[truedest2[k]],style0) else: tarifinput = QInputDialog.getText(self,'Tarif','Please enter tarif for '+truedest2[k]+':') tarif[truedest2[k]] = float(tarifinput[0]) ws.write(i,12,tarif[truedest2[k]],style0) ws.write(i,13,xlwt.Formula('(HOUR(J'+str(i+1)+')*60+MINUTE(J'+str(i+1)+')+SECOND(J'+str(i+1)+')/60)*M'+str(i+1)+''),style0) i+=1 k+=1 tariff = file('tarif.txt', 'w') pickle.dump(tarif, tariff) tariff.close() ws.write(len(matchesDate)+6,0,'Total:',style3) ws.write(len(matchesDate)+6,9,xlwt.Formula('SUM(J5:J'+str(len(matchesDate)+4)+')'),style5) ws.write(len(matchesDate)+6,11,xlwt.Formula('SUM(L5:L'+str(len(matchesDate)+4)+')'),style3) ws.write(len(matchesDate)+6,13,xlwt.Formula('SUM(N5:N'+str(len(matchesDate)+4)+')'),style3) #outfp.close wb.save(self.fname+'.xls') self.ui.progressBar.setValue(100) if self.ui.checkBox.isChecked(): os.startfile(str(self.fname)+'.xls',) return data def __del__(self): self.ui = None
class mywindow(QtWidgets.QMainWindow): def __init__(self): super(mywindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) # TODO deberia crear self.ui.canvas aqui self.dotSize = 5 self.borderSize = 3 self.penWhite = QPen(Qt.white, self.borderSize) self.penRed = QPen(Qt.red, self.borderSize) self.penGreen = QPen(Qt.green, self.borderSize) self.penOrange = QPen(QColor(243, 156, 18), self.borderSize) self.brushWhite = QBrush(Qt.white) self.r = Random() rec = self.ui.canvas.sceneRect() self.image = QImage(int(rec.width()), int(rec.height()), QImage.Format_RGB32) # self.image.fill(0) self.painter = QPainter(self.image) self.painter.setRenderHint(QPainter.Antialiasing) def generatePoints(self, num): abc = 'abcdefghijklmnopqrstuvwxyz' r1 = [-300, 300] r2 = [-100, 100] points = { n: Point(self.r.randint(*r1), self.r.randint(*r2)) for n in abc[:num] } return points def generateRectangles(self, num): abc = 'ABCDEFGHIJKLMNOPQRSTUWXYZ' r1 = [-200, 200] r2 = [100, 300] pos = lambda: Point(self.r.randint(*r1), self.r.randint(*r1)) width = lambda: self.r.randint(*r2) height = lambda: self.r.randint(*r2) rects = {n: Rectangle(pos(), width(), height()) for n in abc[:num]} return rects def paintPoints(self, points): for l, p in points.items(): dot = self.ui.canvas.addEllipse(-self.dotSize / 2, -self.dotSize / 2, self.dotSize, self.dotSize, self.penWhite, self.brushWhite) label = self.ui.canvas.addText(l) x = p.x y = -p.y dot.setPos(x, y) label.setPos(x, y - 20) label.setDefaultTextColor(Qt.white) print('{0} pos {1}'.format(l, p)) def paintRectangles(self, rects): for l, r in rects.items(): self.ui.canvas.addLine(r.x0, -r.y0, r.x1, -r.y0, self.penWhite) self.ui.canvas.addLine(r.x0, -r.y0, r.x0, -r.y1, self.penWhite) self.ui.canvas.addLine(r.x1, -r.y0, r.x1, -r.y1, self.penWhite) self.ui.canvas.addLine(r.x0, -r.y1, r.x1, -r.y1, self.penWhite) label = self.ui.canvas.addText(l) label.setPos(r.x0, -r.y0 - 20) label.setDefaultTextColor(Qt.white) def test_minCircle(self, num=3): points = self.generatePoints(num) # points = {} # points['a'] = Point(300, 0) # points['b'] = Point(100, 0) # points['c'] = Point(200, 100) c = Circle.min_circle(*[p for p in points.values()]) circle = self.ui.canvas.addEllipse(-c.radius, -c.radius, c.radius * 2, c.radius * 2, self.penGreen) circle.setPos(c.center.x, -c.center.y) self.paintPoints(points) print('circle pos: {0}, radius: {1}'.format(c.center, c.radius)) #TODO Esta configuración concreta de puntos falla def test_minCircle2(self): points = {} points["1"] = Point(903, 5868) points["2"] = Point(928, 5858) points["3"] = Point(863, 5774) points["4"] = Point(863, 5774) points["5"] = Point(944, 5864) points["6"] = Point(963, 5844) points["7"] = Point(924, 5559) points["8"] = Point(924, 5559) points["9"] = Point(1561, 5591) c = Circle.min_circle(*[p for p in points.values()]) for l, p in points.items(): if not c.includePoint(p): print("{0}, queda a {1} de estar dentro".format( l, c.center.distance(p) - c.radius)) for p in points.values(): p.x -= 1000 p.y -= 5700 c.center.x -= 1000 c.center.y -= 5700 circle = self.ui.canvas.addEllipse(-c.radius, -c.radius, c.radius * 2, c.radius * 2, self.penGreen) circle.setPos(c.center.x, -c.center.y) self.paintPoints(points) print('circle 2 pos: {0}, radius: {1}'.format(c.center, c.radius)) def test_intersections(self, num=4): points = self.generatePoints(num) # points['a'] = Point(404, 139) # points['b'] = Point(706, 654) # points['c'] = Point(379, 214) # points['d'] = Point(321, 173) p = list(points.values()) for p0, p1 in zip(p[::2], p[1::2]): self.ui.canvas.addLine(p0.x, -p0.y, p1.x, -p1.y, self.penRed) bisectors = [] for p0, p1 in zip(p[::2], p[1::2]): b = Point.bisector(p0, p1) bisectors.append(b) self.ui.canvas.addLine(b.p0.x, -b.p0.y, b.p1.x, -b.p1.y, self.penGreen) for l1, l2 in zip(bisectors[::2], bisectors[1::2]): dot = {'X': Line.intersection(l1, l2)} self.paintPoints(dot) self.paintPoints(points) def test_rectangles_distance(self, num): rects = self.generateRectangles(1) self.paintRectangles(rects) points = self.generatePoints(num) self.paintPoints(points) for r in rects.values(): for p in points.values(): radius = r.distance(p) c = Circle(p, radius) circle = self.ui.canvas.addEllipse(-c.radius, -c.radius, c.radius * 2, c.radius * 2, self.penOrange) circle.setPos(c.center.x, -c.center.y) def snapshot(self, filename="untitled"): self.ui.canvas.render(self.painter) self.image.save(filename + ".png") def test_text(self): t = QGraphicsTextItemWithBackground("Hola") t.setPos(0, 0) self.ui.canvas.addItem(t)
def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.DB = shelve.open('DB.txt') self.DB['HRM_Trunk'] = [ r'C:\ProgramData\Experium_DB_TRUNK_HRM', r'C:\Program Files\EXPERIUM_DB_TRUNK_HRM', '0', '0' ] self.DB['HRM_Release'] = [ r'C:\ProgramData\Experium_DB_RELEASE_HRM', r'C:\Program Files\EXPERIUM_DB_RELEASE_HRM', '0', '1' ] self.DB['AGN_Trunk'] = [ r'C:\ProgramData\Experium_DB_TRUNK_KA', r'C:\Program Files\EXPERIUM_DB_TRUNK', '1', '0' ] self.DB['AGN_Release'] = [ r'C:\ProgramData\Experium_DB_RELEASE_KA', r'C:\Program Files\EXPERIUM_DB_RELEASE_RA', '1', '1' ] self.trunk_expcl_path = r'X:\ExperiumTrunk' self.release_expcl_path = r'X:\ExperiumRelease' self.cl_exp_path = r'C:\Program Files\Experium' self.ui.lineEdit_7.setText(self.cl_exp_path) self.ui.lineEdit_3.setText(self.DB['HRM_Trunk'][0]) self.ui.lineEdit_6.setText(self.DB['HRM_Trunk'][1]) self.type_flag = (self.DB['HRM_Trunk'][2]) self.trunk_flag = (self.DB['HRM_Trunk'][3]) self.ui.comboBox.currentIndexChanged.connect(self.db_change) self.cl_localdata_path = r'C:\Users\win7_test\AppData\Roaming\Experium\Client' self.data_trunk_path = r'X:\ExperiumTrunk\DB' self.data_release_path = r'X:\ExperiumRelease\DB' self.X_serv_release_path = r'X:\winserverexe\newexe' self.X_serv_trunk_path = r'X:\winserverexe\newexe\trunkexe' self.clientupd = [ r'\Experium.exe', r'\expenu.dll', r'\exprus.dll', r'\GCalDav.dll', r'\MailEngine.dll', r'\SMSEngine.dll', r'\Telephony.dll' ] self.srvupd = [ r'\exp_srv.exe', r'\sdatacnv.exe', r'\sdatasrv.exe', r'\sexpsrv.exe', r'\smetasrch.exe', r'\smetasrv.exe', r'\srmeta.exe', r'\wcnvnode.exe', r'\wdatacnv.exe', r'\wdatasrv.exe', r'\wmetasrch.exe', r'\wmetasrv.exe', r'\wrmeta.exe' ] self.localdatas = [ r'C:\Users\win7_test\AppData\Roaming\Experium\Client' ] self.J = Jenkins('http://buildsrv.experium.ru/', username="", password="", requester=CrumbRequester( baseurl='http://buildsrv.experium.ru/', username="", password="")) self.ui.comboBox_2.addItems(self.J.keys()) # Отрисовка модальных окон self.ui.calendarWidget.setWindowFlags( QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.calendarWidget.setWindowTitle('Calendar for Redmine') self.ui.widget.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.widget.setWindowTitle('Database Info') self.ui.widget.setWindowModality(QtCore.Qt.WindowModal) self.ui.widget_2.setWindowFlags( QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.widget_2.setWindowTitle('API Options') self.ui.widget_2.setWindowModality(QtCore.Qt.WindowModal) self.ui.pushButton.clicked.connect(self.enumver) self.ui.pushButton_7.clicked.connect(self.clrlocal_cl) self.ui.pushButton_11.clicked.connect(self.jenkins_build) self.ui.pushButton_9.clicked.connect(self.ui.textBrowser.clear) self.ui.pushButton_3.clicked.connect( lambda: self.start_thread(self.start)) self.ui.pushButton_4.clicked.connect( lambda: self.start_thread(self.stop)) self.ui.pushButton_6.clicked.connect( lambda: self.start_thread(self.update_cl)) self.ui.pushButton_5.clicked.connect( lambda: self.start_thread(self.start_cl)) self.ui.pushButton_2.clicked.connect( lambda: self.start_thread(self.update)) self.ui.pushButton_10.clicked.connect(self.jenkins) self.ui.pushButton_8.clicked.connect(self.redmine) self.ui.pushButton_12.clicked.connect( lambda: self.start_thread(self.update_db)) self.ui.pushButton_13.clicked.connect( lambda: self.start_thread(self.stop_cl)) self.ui.pushButton_14.clicked.connect(self.jenkins_queue) self.ui.pushButton_18.clicked.connect( lambda: self.start_thread(self.ess)) self.ui.pushButton_19.clicked.connect(self.ui.widget_2.show) self.ui.pushButton_17.clicked.connect(self.calendar) self.ui.pushButton_15.clicked.connect(self.prep_deploy_databases) self.ui.pushButton_22.clicked.connect(self.deploy_database) self.ui.pushButton_16.clicked.connect(self.uninstall_databases) self.ui.pushButton_24.clicked.connect(self.clear_opt) #self.ui.tableWidget.cellDoubleClicked.connect(self.mada) self.ui.comboBox_4.customContextMenuRequested.connect(self.open_menu) self.ui.comboBox_5.customContextMenuRequested.connect( self.open_menu_ess) try: self.ui.comboBox_4.addItems(self.DB['SConfig']) if self.ui.comboBox_4.currentText() == '': self.ui.comboBox_4.addItem('127.0.0.1') except: self.ui.comboBox_4.addItem('127.0.0.1') try: self.ui.comboBox_5.addItems(self.DB['ESS']) if self.ui.comboBox_5.currentText() == '': self.ui.comboBox_5.addItem('msmeta6.experium.ru') except: self.ui.comboBox_5.addItem('msmeta6.experium.ru') self.logger = Logger(self.ui.textBrowser) sys.stdout = self.logger for k in self.DB.keys(): if not k in [ 'HRM_Trunk', 'HRM_Release', 'AGN_Trunk', 'AGN_Release' ]: self.ui.comboBox.addItem(k) self.DB.close() self.t_time = None self.ui.calendarWidget.selectionChanged.connect(self.redmine) #self.ui.tabWidget.setStyleSheet("background-image: url(./Experium.jpg)") self.ui.textBrowser.setStyleSheet( "background-color: yellow; color: black") self.movie = QMovie("exp.gif", QByteArray(), self) self.movie.setCacheMode(QMovie.CacheAll) self.movie.setSpeed(100) self.ui.label_8.setMovie(self.movie)
class MainWindow(QMainWindow): """MainWindow inherits QMainWindow""" def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.DB = shelve.open('DB.txt') self.DB['HRM_Trunk'] = [ r'C:\ProgramData\Experium_DB_TRUNK_HRM', r'C:\Program Files\EXPERIUM_DB_TRUNK_HRM', '0', '0' ] self.DB['HRM_Release'] = [ r'C:\ProgramData\Experium_DB_RELEASE_HRM', r'C:\Program Files\EXPERIUM_DB_RELEASE_HRM', '0', '1' ] self.DB['AGN_Trunk'] = [ r'C:\ProgramData\Experium_DB_TRUNK_KA', r'C:\Program Files\EXPERIUM_DB_TRUNK', '1', '0' ] self.DB['AGN_Release'] = [ r'C:\ProgramData\Experium_DB_RELEASE_KA', r'C:\Program Files\EXPERIUM_DB_RELEASE_RA', '1', '1' ] self.trunk_expcl_path = r'X:\ExperiumTrunk' self.release_expcl_path = r'X:\ExperiumRelease' self.cl_exp_path = r'C:\Program Files\Experium' self.ui.lineEdit_7.setText(self.cl_exp_path) self.ui.lineEdit_3.setText(self.DB['HRM_Trunk'][0]) self.ui.lineEdit_6.setText(self.DB['HRM_Trunk'][1]) self.type_flag = (self.DB['HRM_Trunk'][2]) self.trunk_flag = (self.DB['HRM_Trunk'][3]) self.ui.comboBox.currentIndexChanged.connect(self.db_change) self.cl_localdata_path = r'C:\Users\win7_test\AppData\Roaming\Experium\Client' self.data_trunk_path = r'X:\ExperiumTrunk\DB' self.data_release_path = r'X:\ExperiumRelease\DB' self.X_serv_release_path = r'X:\winserverexe\newexe' self.X_serv_trunk_path = r'X:\winserverexe\newexe\trunkexe' self.clientupd = [ r'\Experium.exe', r'\expenu.dll', r'\exprus.dll', r'\GCalDav.dll', r'\MailEngine.dll', r'\SMSEngine.dll', r'\Telephony.dll' ] self.srvupd = [ r'\exp_srv.exe', r'\sdatacnv.exe', r'\sdatasrv.exe', r'\sexpsrv.exe', r'\smetasrch.exe', r'\smetasrv.exe', r'\srmeta.exe', r'\wcnvnode.exe', r'\wdatacnv.exe', r'\wdatasrv.exe', r'\wmetasrch.exe', r'\wmetasrv.exe', r'\wrmeta.exe' ] self.localdatas = [ r'C:\Users\win7_test\AppData\Roaming\Experium\Client' ] self.J = Jenkins('http://buildsrv.experium.ru/', username="", password="", requester=CrumbRequester( baseurl='http://buildsrv.experium.ru/', username="", password="")) self.ui.comboBox_2.addItems(self.J.keys()) # Отрисовка модальных окон self.ui.calendarWidget.setWindowFlags( QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.calendarWidget.setWindowTitle('Calendar for Redmine') self.ui.widget.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.widget.setWindowTitle('Database Info') self.ui.widget.setWindowModality(QtCore.Qt.WindowModal) self.ui.widget_2.setWindowFlags( QtCore.Qt.Dialog | QtCore.Qt.MSWindowsFixedSizeDialogHint) self.ui.widget_2.setWindowTitle('API Options') self.ui.widget_2.setWindowModality(QtCore.Qt.WindowModal) self.ui.pushButton.clicked.connect(self.enumver) self.ui.pushButton_7.clicked.connect(self.clrlocal_cl) self.ui.pushButton_11.clicked.connect(self.jenkins_build) self.ui.pushButton_9.clicked.connect(self.ui.textBrowser.clear) self.ui.pushButton_3.clicked.connect( lambda: self.start_thread(self.start)) self.ui.pushButton_4.clicked.connect( lambda: self.start_thread(self.stop)) self.ui.pushButton_6.clicked.connect( lambda: self.start_thread(self.update_cl)) self.ui.pushButton_5.clicked.connect( lambda: self.start_thread(self.start_cl)) self.ui.pushButton_2.clicked.connect( lambda: self.start_thread(self.update)) self.ui.pushButton_10.clicked.connect(self.jenkins) self.ui.pushButton_8.clicked.connect(self.redmine) self.ui.pushButton_12.clicked.connect( lambda: self.start_thread(self.update_db)) self.ui.pushButton_13.clicked.connect( lambda: self.start_thread(self.stop_cl)) self.ui.pushButton_14.clicked.connect(self.jenkins_queue) self.ui.pushButton_18.clicked.connect( lambda: self.start_thread(self.ess)) self.ui.pushButton_19.clicked.connect(self.ui.widget_2.show) self.ui.pushButton_17.clicked.connect(self.calendar) self.ui.pushButton_15.clicked.connect(self.prep_deploy_databases) self.ui.pushButton_22.clicked.connect(self.deploy_database) self.ui.pushButton_16.clicked.connect(self.uninstall_databases) self.ui.pushButton_24.clicked.connect(self.clear_opt) #self.ui.tableWidget.cellDoubleClicked.connect(self.mada) self.ui.comboBox_4.customContextMenuRequested.connect(self.open_menu) self.ui.comboBox_5.customContextMenuRequested.connect( self.open_menu_ess) try: self.ui.comboBox_4.addItems(self.DB['SConfig']) if self.ui.comboBox_4.currentText() == '': self.ui.comboBox_4.addItem('127.0.0.1') except: self.ui.comboBox_4.addItem('127.0.0.1') try: self.ui.comboBox_5.addItems(self.DB['ESS']) if self.ui.comboBox_5.currentText() == '': self.ui.comboBox_5.addItem('msmeta6.experium.ru') except: self.ui.comboBox_5.addItem('msmeta6.experium.ru') self.logger = Logger(self.ui.textBrowser) sys.stdout = self.logger for k in self.DB.keys(): if not k in [ 'HRM_Trunk', 'HRM_Release', 'AGN_Trunk', 'AGN_Release' ]: self.ui.comboBox.addItem(k) self.DB.close() self.t_time = None self.ui.calendarWidget.selectionChanged.connect(self.redmine) #self.ui.tabWidget.setStyleSheet("background-image: url(./Experium.jpg)") self.ui.textBrowser.setStyleSheet( "background-color: yellow; color: black") self.movie = QMovie("exp.gif", QByteArray(), self) self.movie.setCacheMode(QMovie.CacheAll) self.movie.setSpeed(100) self.ui.label_8.setMovie(self.movie) def mada(self, row, col): item = QTableWidgetItem(self.ui.tableWidget.currentItem()) brush = QtGui.QBrush(QtGui.QColor(125, 125, 125)) brush.setStyle(QtCore.Qt.SolidPattern) item.setBackground(brush) self.ui.tableWidget.setItem( 1, 1, QTableWidgetItem(self.ui.tableWidget.currentItem())) self.ui.tableWidget.setItem(row, col, item) def mstart(self): """sart animnation""" self.movie.start() def mstop(self): """stop the animation""" self.movie.stop() def open_menu(self, position): menu = QMenu() delete_action = menu.addAction("Delete") clear_action = menu.addAction("ClearAll") saveto_d_b_action = menu.addAction("SaveToDB") action = menu.exec_(self.ui.comboBox_4.mapToGlobal(position)) if action == delete_action: self.ui.comboBox_4.removeItem(self.ui.comboBox_4.currentIndex()) elif action == clear_action: self.ui.comboBox_4.clear() elif action == saveto_d_b_action: DB = shelve.open('DB.txt') DB['SConfig'] = [ self.ui.comboBox_4.itemText(i) for i in range(self.ui.comboBox_4.count()) ] DB.close() def open_menu_ess(self, position): menu = QMenu() delete_action = menu.addAction("Delete") clear_action = menu.addAction("ClearAll") saveto_d_b_action = menu.addAction("SaveToDB") action = menu.exec_(self.ui.comboBox_5.mapToGlobal(position)) if action == delete_action: self.ui.comboBox_5.removeItem(self.ui.comboBox_5.currentIndex()) elif action == clear_action: self.ui.comboBox_5.clear() elif action == saveto_d_b_action: DB = shelve.open('DB.txt') DB['ESS'] = [ self.ui.comboBox_5.itemText(i) for i in range(self.ui.comboBox_5.count()) ] DB.close() @staticmethod def output_to_box(text): print(text.toUtf8()) def prep_deploy_databases(self): self.ui.widget.show() self.ui.pushButton_22.setEnabled(False) self.DB_name, ok = QtGui.QInputDialog.getText(self, 'DBName', 'Enter DB name:') self.ui.lineEdit_9.setText(str(self.DB_name)) self.DB_serv_path = QtGui.QFileDialog.getExistingDirectory( self, 'Select DB Server Path', '/') self.ui.lineEdit_4.setText(str(self.DB_serv_path)) self.DB_data_path = QtGui.QFileDialog.getExistingDirectory( self, 'Select DB Data Path', '/') self.ui.lineEdit_5.setText(str(self.DB_data_path)) if str(self.DB_name) != '' and str(self.DB_data_path) != '' and str( self.DB_serv_path) != '': self.ui.pushButton_22.setEnabled(True) def deploy_database(self): if self.ui.radioButton.isChecked(): type_flag = '0' elif self.ui.radioButton_2.isChecked(): type_flag = '1' else: return (0) if self.ui.radioButton_4.isChecked(): trunk_flag = '0' elif self.ui.radioButton_3.isChecked(): trunk_flag = '1' else: return (0) self.DB = shelve.open('DB.txt') self.DB[str(self.DB_name)] = [ str(self.DB_data_path), str(self.DB_serv_path), type_flag, trunk_flag ] self.DB.close() self.ui.widget.hide() self.ui.comboBox.addItem(str(self.DB_name)) wdatasrv = open('wdatasrv.par', 'r') wdatasrv1 = open('wdatasrv1.par', 'w') wmetasrv1 = open('wmetasrv1.par', 'w') wmetasrv = open('wmetasrv.par', 'r') srvini = open('exp_srv.ini', 'r') srvini1 = open('exp_srv1.ini', 'w') text = wdatasrv.read() wdatasrv1.write(text.replace('DB_data_path', str(self.DB_data_path))) text = wmetasrv.read() wmetasrv1.write(text.replace('DB_data_path', str(self.DB_data_path))) text = srvini.read() srvini1.write(text.replace('DB_serv_path', str(self.DB_serv_path))) srvini.close() srvini1.close() wdatasrv.close() wdatasrv1.close() wmetasrv.close() wmetasrv1.close() self.wid_write('copy /Y "wdatasrv1.par" "%s\wdatasrv.par"') % str( self.DB_serv_path) self.wid_write('copy /Y "wmetasrv1.par" "%s\wmetasrv.par"') % str( self.DB_serv_path) self.wid_write('copy /Y "exp_srv1.ini" "%s\exp_srv.ini"') % str( self.DB_serv_path) def uninstall_databases(self): self.DB = shelve.open('DB.txt') if not self.ui.comboBox.currentText() in [ 'HRM_Trunk', 'HRM_Release', 'AGN_Trunk', 'AGN_Release' ]: self.DB.pop(str(self.ui.comboBox.currentText())) self.ui.comboBox.removeItem(self.ui.comboBox.currentIndex()) @staticmethod def wid_write(cmd): PIPE = subprocess.PIPE p = subprocess.Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=subprocess.STDOUT) print p.stdout.read() @staticmethod def start_thread(meth): threading.Thread(target=meth).start() def clrlocal_cl(self): for f in self.localdatas: self.wid_write('RMDIR /s /Q ' + f) def jenkins(self): self.thread2 = Thread2(self) self.thread2.message2[str].connect(self.output_to_box) self.thread2.start() def redmine(self): self.thread1 = Thread1(self) self.thread1.message1[str].connect(self.output_to_box) self.thread1.start() def ess(self): import requests self.ui.lineEdit_8.setStyleSheet("background-color: white") if self.ui.lineEdit_15.text() != "": ess_key = str(self.ui.lineEdit_15.text()) url = '%s/SupportSrv/SupportSrv.svc/Support/control/api/grep' % self.ui.comboBox_5.currentText( ) headers = { 'accept': "application/json, text/plain, */*", 'origin': "https://msmeta6.experium.ru", 'x-devtools-emulate-network-conditions-client-id': "41f1c26a-9fd4-48be-b7e5-82cfd3d85220", 'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36", 'content-type': "application/json;charset=UTF-8", 'accept-encoding': "gzip, deflate, br", 'accept-language': "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7", 'authorization': "Basic c3VwcG9ydDpjNTEyODQzNw==", 'cache-control': "no-cache" } try: r = requests.post(url, headers=headers, json={'id': ess_key}, verify=False) if r.status_code == 200: data = r.text.encode('latin1').decode('utf-8') win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboardData( win32clipboard.CF_UNICODETEXT, data) win32clipboard.CloseClipboard() self.ui.lineEdit_8.setStyleSheet("background-color: green") else: self.ui.lineEdit_8.setStyleSheet("background-color: red") except: self.ui.lineEdit_8.setStyleSheet("background-color: red") def jenkins_build(self): j = self.J.get_job(self.ui.comboBox_2.currentText()) if not j.is_queued_or_running(): self.J.build_job(self.ui.comboBox_2.currentText()) def jenkins_queue(self): self.thread4 = Thread4(self) self.thread4.message4[str].connect(self.output_to_box) self.thread4.signal_start[str].connect(self.mstart) self.thread4.signal_stop[str].connect(self.mstop) self.thread4.start() def calendar(self): win = self.ui.calendarWidget win.show() x = self.x() + self.frameSize().width() y = self.y() win.move(x, y) def update_cl(self): if self.ui.checkBox_4.isChecked(): if self.ui.checkBox_2.isChecked(): self.wid_write("taskkill /im experium.exe") time.sleep(3) for f in self.clientupd: self.wid_write('copy /Y "' + self.trunk_expcl_path + f + '" "' + self.cl_exp_path + f + '"') else: self.wid_write("taskkill /im experium.exe") time.sleep(3) for f in self.clientupd: self.wid_write('copy /Y "' + self.release_expcl_path + f + '" "' + self.cl_exp_path + f + '"') for f in self.localdatas: self.wid_write('RMDIR /s /Q ' + f) if self.ui.checkBox_3.isChecked(): self.wid_write("taskkill /t /im exp_srv.exe") time.sleep(15) self.wid_write("taskkill /t /im wdatacnv.exe") if self.ui.checkBox_2.isChecked(): for f in self.srvupd: self.wid_write('copy /Y "' + self.X_serv_trunk_path + f + '" "' + self.cl_exp_path + f + '"') else: for f in self.srvupd: self.wid_write('copy /Y "' + self.X_serv_release_path + f + '" "' + self.cl_exp_path + f + '"') print('DONE!!!') def start_cl(self): config = open(self.cl_exp_path + '\config.ini', 'r') regex = re.compile(r"^.*Server.*$") text2 = [] for line in config.readlines(): text2.append( regex.sub( 'Server=' + str( re.findall('[^ ()]+', str(self.ui.comboBox_4.currentText()))[0]), line)) config.close() config = open(self.cl_exp_path + '\config.ini', 'w') config.writelines(text2) config.close() for i in range(int(self.ui.comboBox_3.currentIndex()) + 1): os.startfile(self.cl_exp_path + '\experium.exe') if self.ui.checkBox_3.isChecked(): os.startfile(self.cl_exp_path + '\exp_srv.exe') time.sleep(10) self.wid_write("taskkill /im wdatacnv.exe") time.sleep(3) os.startfile(self.cl_exp_path + '\wdatacnv.exe') def stop_cl(self): self.wid_write("taskkill /im experium.exe") if self.ui.checkBox_3.isChecked(): self.wid_write("taskkill /t /im exp_srv.exe") time.sleep(15) self.wid_write("taskkill /t /im wdatacnv.exe") print('DONE!!!') def start(self): self.server = str(self.ui.lineEdit_6.displayText()) self.wid_write('RMDIR /s /Q ' + self.cl_localdata_path) self.stop() self.ui.pushButton_3.setEnabled(False) self.ui.comboBox.setEnabled(False) self.wid_write('sc create SDataSrv binPath= "' + self.server + '\sdatasrv.exe" type= own start= demand error= normal"') self.wid_write( 'sc create SMetaSrch binPath= "' + self.server + '\smetasrch.exe" type= own start= demand error= normal"') self.wid_write('sc create SMetaSrv binPath= "' + self.server + '\smetasrv.exe" type= own start= demand error= normal"') self.wid_write('sc create SDataCnv binPath= "' + self.server + '\sdatacnv.exe" type= own start= demand error= normal"') self.wid_write('sc create ExperiumLauncherService binPath= "' + self.server + '\sexpsrv.exe" type= own start= auto error= normal"') self.wid_write('sc start "ExperiumLauncherService"') print('DONE!!!') def stop(self): self.server = str(self.ui.lineEdit_6.displayText()) self.wid_write('sc stop "ExperiumLauncherService"') self.wid_write('sc delete "SDataSrv"') self.wid_write('sc delete "SDataCnv"') self.wid_write('sc delete "SMetaSrch"') self.wid_write('sc delete "SMetaSrv"') self.wid_write('sc delete "ExperiumLauncherService"') self.ui.pushButton_3.setEnabled(True) self.ui.comboBox.setEnabled(True) print('DONE!!!') def update(self): self.server = str(self.ui.lineEdit_6.displayText()) self.stop() print(str(self.trunk_flag)) print(str(self.type_flag)) if str(self.trunk_flag) == '0': for f in self.srvupd: self.wid_write('copy /Y "' + self.X_serv_trunk_path + f + '" "' + self.server + f + '"') if str(self.trunk_flag) == '1': for f in self.srvupd: self.wid_write('copy /Y "' + self.X_serv_release_path + f + '" "' + self.server + f + '"') if self.ui.checkBox.isChecked(): for f in self.srvupd: self.wid_write('copy /Y "' + self.X_serv_trunk_path + f + '" "' + self.server + f + '"') print('DONE!!!') def update_db(self): data_path = str(self.ui.lineEdit_3.displayText()) self.server = str(self.ui.lineEdit_6.displayText()) self.stop() if str(self.trunk_flag) == '0': X_path = self.data_trunk_path if str(self.type_flag) == '0': base1 = 'db0hr.zip' if str(self.type_flag) == '1': base1 = 'db0ra.zip' if str(self.trunk_flag) == '1': X_path = self.data_release_path if str(self.type_flag) == '0': base1 = 'db0hr.zip' if str(self.type_flag) == '1': base1 = 'db0ra.zip' base = r'\\' + base1 self.wid_write('RMDIR /s /Q ' + data_path + '\BACKUPDATA') self.wid_write('RMDIR /s /Q ' + data_path + '\DATASERVERDATA') self.wid_write('RMDIR /s /Q ' + data_path + '\METASERVERDATA') self.wid_write('copy /Y "' + X_path + base + '" "' + data_path + base + '"') z = ZipFile(data_path + base, 'r') z.extractall(data_path) z.close() self.wid_write('DEL /Q ' + data_path + base) print('DONE!!!') def db_change(self): self.DB = shelve.open('DB.txt') DB_name = str(self.ui.comboBox.currentText()) self.ui.lineEdit_3.setText(self.DB[DB_name][0]) self.ui.lineEdit_6.setText(self.DB[DB_name][1]) self.type_flag = str(self.DB[DB_name][2]) self.trunk_flag = str(self.DB[DB_name][3]) self.DB.close() def enumver(self): versions = [ re.findall(r'\d{4,}', f) for f in os.listdir(self.trunk_expcl_path) ] self.ui.lineEdit.setText("TRUNK " + str(max(versions))) versions = [ re.findall(r'\d{4,}', f) for f in os.listdir(self.release_expcl_path) ] self.ui.lineEdit_2.setText("RELEASE " + str(max(versions))) def clear_opt(self): self.ui.lineEdit_10.clear() self.ui.lineEdit_11.clear() self.ui.lineEdit_12.clear() self.ui.lineEdit_13.clear() self.ui.lineEdit_14.clear() self.test = QtGui.QFileDialog.getOpenFileName( self, 'Выберите файл для отправки') print(self.test) @staticmethod def save_opt(): """TODO""" def __del__(self): self.ui = None