Changeset 2308 for palm/trunk/SCRIPTS/palm_gf
- Timestamp:
- Jul 10, 2017 12:15:43 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/palm_gf
r2117 r2308 42 42 import sys 43 43 import os 44 import time 44 45 import palm_gf_files.palm_gf_exec as execute_script 45 46 import palm_gf_files.palm_gf_conf as config_wr … … 47 48 import subprocess as sub 48 49 49 from PyQt4 import QtCore, QtGui, uic 50 51 from PyQt4 import QtCore, QtGui, uic, Qt 52 from PyQt4.QtCore import QCoreApplication 50 53 from palm_gf_files.palm_gf_tools import MyApp3 51 54 … … 67 70 68 71 class MyApp1(QtGui.QMainWindow, Ui_MainWindow): 69 def __init__(self , parent=None):72 def __init__(self): 70 73 71 74 … … 81 84 self.move(frameGm.topLeft()) 82 85 86 87 #centerPoint = str(centerPoint) 88 #xcenter = centerPoint.split('(')[1].split(',')[0] 89 #ycenter = centerPoint.split('(')[1].split(',')[1].split(')')[0] 90 #print xcenter, ycenter 91 #centerPoint = QtCore.QPoint(int(xcenter) - 418, int(ycenter)) 92 #frameGm.moveCenter(centerPoint) 93 #self.move(frameGm.topLeft()) 94 83 95 self.setupUi(self) 84 self.startbutton.clicked.connect(self. run_program) # starts grid_calculation96 self.startbutton.clicked.connect(self.input_check) # starts grid_calculation 85 97 self.psolver_box.currentIndexChanged.connect(self.vis) # triggers visibility of fft_method option 86 98 self.save_button.clicked.connect(self.save_results) # saves .db file under given name … … 89 101 self.result_headline.setVisible(False) 90 102 self.result_label.setVisible(False) 91 self.line_res_up.setVisible(False)103 #self.line_res_up.setVisible(False) 92 104 self.line_res_down.setVisible(False) 93 105 self.view_result_button.setVisible(False) 94 self.tableWidget.setVisible(False)106 #self.tableWidget.setVisible(False) 95 107 self.load_text_label.setVisible(False) 96 108 self.nor_spinbox.setVisible(False) 97 109 self.filename_line.setVisible(False) 98 110 self.save_button.setVisible(False) 111 self.testbar.setVisible(False) 112 self.d_box.setVisible(False) 113 self.tpn_box.setVisible(False) 114 self.tolerance_bar.setVisible(False) 115 self.tolerance_value.setVisible(False) 99 116 self.view_result_button.clicked.connect(self.load_gui) 100 101 #self.startbutton.clicked.connect(self.progress) 102 #self.progressBar.setEnabled(False) 103 #self.progressBar.setVisible(False) 104 105 #def progress(self): 106 # import time 107 # self.progressBar.setVisible(True) 108 # self.progressBar.setDisabled(False) 109 # self.progressBar.setValue(10) 110 # time.sleep(1) 111 # self.progressBar.setValue(50) 112 # time.sleep(1) 113 # self.progressBar.setValue(100) 114 # time.sleep(1) 115 # self.progressBar.setEnabled(False) 117 self.threadclass = Threadclass() 118 self.actionSetting.triggered.connect(self.settings) 119 self.question_box.clicked.connect(self.settings) 120 self.warning_label.setVisible(False) 121 122 123 124 125 def closeEvent(self, QCloseEvent): 126 127 config_wr.closing_cleanup() 128 QCloseEvent.accept() 129 130 131 def input_check(self): 132 133 if int(self.nx_min_box.value()) <= int(self.nx_max_box.value()) and int(self.ny_min_box.value()) <= int(self.nx_max_box.value()) and int(self.nz_min_box.value()) <= int(self.nz_max_box.value()): 134 self.warning_label.setVisible(False) 135 self.run_program() 136 137 else: 138 139 self.warning_label.setStyleSheet('color: red') 140 self.warning_label.setVisible(True) 141 142 143 144 145 146 147 148 def settings(self): 149 150 self.w = MyPopup() 151 #self.w.setGeometry(Qt.QRect(100, 100, 400, 200)) 152 frameGm = self.frameGeometry() 153 screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) 154 centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center() 155 frameGm.moveCenter(centerPoint) 156 self.w.move(frameGm.topLeft()) 157 self.w.show() 158 159 116 160 117 161 def vis(self): … … 126 170 127 171 def load_gui(self): 128 print("not yet possible")129 172 self.child_win = MyApp3() 130 173 self.child_win.show() 131 #self.load_results_2() 132 #MyApp2(self).show() 133 # import filter_script 134 # upt = filter_script.MyApp2() 135 # upt.cur_grid() 136 137 def load_results(self): 138 self.setGeometry(330, 250, 584, 622) 139 self.tableWidget.setVisible(True) 140 conn = sqlite3.connect(".palm_gf_data.db") 141 c = conn.cursor() 142 nor = int(self.nor_spinbox.value()) 143 self.tableWidget.setRowCount(nor) 144 c.execute("SELECT * FROM grid_current") 145 results = c.fetchmany(nor) 146 i = 0 147 j = 0 148 149 while i < nor: 150 line = results[i] 151 while j < 6: 152 var = line[j] 153 154 self.tableWidget.setItem(i, j, QtGui.QTableWidgetItem(str(var))) 155 156 j += 1 157 j = 0 158 i += 1 159 160 c.close() 161 conn.close() 174 175 def run_transfer(self): 176 self.threadclass = Threadclass() 177 self.connect(self.threadclass, QtCore.SIGNAL('finish'), self.behind_run) 178 #self.connect(self.threadclass, QtCore.SIGNAL('progress'), self.up2date) 179 self.connect(self.threadclass, QtCore.SIGNAL('startqmsg'), self.takeoff) 180 self.connect(self.threadclass, QtCore.SIGNAL('check'), self.checkme) 181 self.threadclass.runx() 162 182 163 183 def run_program(self): 164 self.setEnabled(False) 184 185 186 self.result_label.setText('Starting calculation...') 187 #self.QtCore.QCoreApplication.processEvents() 188 QtGui.QApplication.processEvents() 189 #self.setEnabled(False) 165 190 # self.Ui_MainWindow.setDisabled(True) 166 self.qmsg() 191 #self.qmsg_wait(0) 192 #print("bool state ", self.npex_npey_box.checkState()) # XXX 167 193 np_min = str(self.np_min_box.value()) 168 194 np_max = str(self.np_max_box.value()) … … 175 201 tpn = str(self.tpn_box.value()) 176 202 dnpexnpey = str(self.d_box.value()) 203 dnpexnpey_tolerance = str(self.tolerance_value.value()) 177 204 dnxny = str(self.dnxny_box.value()) 205 myobject = MyPopup() 206 ld_thrs = myobject.load_thres.value() 207 rslt_thrs = myobject.result_thres.value() 178 208 179 209 if str(self.psolver_box.currentIndex()) == str(1): … … 199 229 else: 200 230 spctre = False 201 print(poisfft, switch, temperton, mlt_grid, spctre) 202 config_wr.write_config(np_min, np_max, nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, tpn, dnpexnpey, dnxny, 203 str(poisfft), str(switch), str(temperton), str(mlt_grid), str(spctre)) 204 execute_script.grid_executer() 205 #execute_script.grid_maxmin() 231 232 if int(self.strict_box.checkState()) != 2: 233 tpn = 0 234 235 if int(self.npex_npey_box.checkState()) != 2: 236 dnpexnpey = 0 237 dnpexnpey_tolerance = 0 238 239 #print(poisfft, switch, temperton, mlt_grid, spctre) 240 config_wr.write_config(np_min, np_max, nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, tpn, dnpexnpey,dnpexnpey_tolerance, dnxny, 241 str(poisfft), str(switch), str(temperton), str(mlt_grid), str(spctre), rslt_thrs, ld_thrs) 242 #time.sleep(1) 243 # execute_script.grid_executer() temp deactive 244 self.testbar.setVisible(True) 245 QtCore.QCoreApplication.processEvents() 246 self.run_transfer() 247 248 249 def behind_run(self): 250 trigger_bool = False 251 #print("behind_run executed") 206 252 checkfile = open(".palm_gf_tmp", "r") 207 self.result_label.setText(str(checkfile.readline())) 253 #self.result_label.setText(str(checkfile.readline())) 254 res_text = str(checkfile.readline()) # XXX 255 self.result_label.setText(res_text) 256 result_nr = res_text.split(' ')[2] 208 257 if int(checkfile.readline()) == 1: 209 258 self.view_result_button.setVisible(True) 259 trigger_bool = True 210 260 self.result_label.setVisible(True) 211 261 self.result_headline.setVisible(True) 212 262 self.line_res_down.setVisible(True) 213 self.line_res_up.setVisible(True)263 #self.line_res_up.setVisible(True) 214 264 self.load_text_label.setVisible(False) 215 265 self.nor_spinbox.setVisible(False) 216 266 checkfile.close() 217 self.setEnabled(True)267 #self.setEnabled(True) 218 268 self.filename_line.setVisible(True) 219 269 self.save_button.setVisible(True) 220 221 def load_results_2(self): 222 223 database = str(".palm_gf_data.db") 224 print(database) 225 self.tableWidget.setVisible(True) 226 conn = sqlite3.connect(database) # ".palm_gf_data.db" 227 c = conn.cursor() 228 c.execute("SELECT * FROM " + 'grid_current') # "grid_current" database[:-3] 229 # c.execute("SELECT * FROM " + database) 230 results = c.fetchall() 231 232 self.tableWidget.setRowCount(len(results)) 233 234 i = 0 235 j = 0 236 237 while i < len(results): 238 line = results[i] 239 while j < 6: 240 var = line[j] 241 242 self.tableWidget.setItem(i, j, QtGui.QTableWidgetItem(str(var))) 243 244 if i == 0 and j == 0: 245 np_min = line[0] 246 np_max = line[0] 247 npex_min = line[1] 248 npex_max = line[1] 249 npey_min = line[2] 250 npey_max = line[2] 251 nx_min = line[3] 252 nx_max = line[3] 253 ny_min = line[4] 254 ny_max = line[4] 255 nz_min = line[5] 256 nz_max = line[5] 257 else: 258 if line[0] > np_max: 259 np_max = line[0] 260 if line[0] < np_min: 261 np_min = line[0] 262 if line[1] > npex_max: 263 npex_max = line[1] 264 if line[1] < npex_min: 265 npex_min = line[1] 266 if line[2] > npey_max: 267 npey_max = line[2] 268 if line[2] < npey_min: 269 npey_min = line[2] 270 if line[3] > nx_max: 271 nx_max = line[3] 272 if line[3] < nx_min: 273 nx_min = line[3] 274 if line[4] > ny_max: 275 ny_max = line[4] 276 if line[4] < ny_min: 277 ny_min = line[4] 278 if line[5] > nz_max: 279 nz_max = line[5] 280 if line[5] < nz_min: 281 nz_min = line[5] 282 283 j += 1 284 j = 0 285 i += 1 286 287 c.close() 288 conn.close() 289 290 self.np_max.setValue(np_max) 291 292 self.np_min.setValue(np_min) 293 self.npex_max.setValue(npex_max) 294 self.npex_min.setValue(npex_min) 295 self.npey_max.setValue(npey_max) 296 self.npey_min.setValue(npey_min) 297 self.nx_max.setValue(nx_max) 298 self.nx_min.setValue(nx_min) 299 self.ny_max.setValue(ny_max) 300 self.ny_min.setValue(ny_min) 301 self.nz_max.setValue(nz_max) 302 self.nz_min.setValue(nz_min) 303 self.np_max.setMaximum(np_max) 304 self.np_min.setMinimum(np_min) 305 self.npex_max.setMaximum(npex_max) 306 self.npex_min.setMinimum(npex_min) 307 self.npey_max.setMaximum(npey_max) 308 self.npey_min.setMinimum(npey_min) 309 self.nx_max.setMaximum(nx_max) 310 self.nx_min.setMinimum(nx_min) 311 self.ny_max.setMaximum(ny_max) 312 self.ny_min.setMinimum(ny_min) 313 self.nz_max.setMaximum(nz_max) 314 self.nz_min.setMinimum(nz_min) 315 316 self.nr_output_label.setText(str(len(results)) + ' results') 270 parameters = config_wr.read_config() 271 272 273 if trigger_bool is True and int(result_nr) < int(parameters[18]): 274 self.result_label.setText(res_text + 'Loading Ui...') 275 self.load_gui() # XXXX 276 self.result_label.setText(res_text) 277 #self.close() 278 #frameGm = self.frameGeometry() 279 #screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) 280 #centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center() 281 #frameGm = self.frameGeometry() 282 #screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) 283 #centerPoint = str(centerPoint) 284 #xcenter = centerPoint.split('(')[1].split(',')[0] 285 #ycenter = centerPoint.split('(')[1].split(',')[1].split(')')[0] 286 ##print xcenter, ycenter 287 #centerPoint = QtCore.QPoint(int(xcenter) - 292, int(ycenter)) 288 #frameGm.moveCenter(centerPoint) 289 #self.move(frameGm.topLeft()) 290 291 292 293 317 294 318 295 … … 325 302 if dialog.ShowModal() == wx.ID_OK: 326 303 path = dialog.GetPath() 327 print(path) 304 305 print(path, file) 328 306 else: 329 307 path = None … … 357 335 msgbox.exec_() 358 336 337 def tester(self): 338 #print("tester was executed from run method") 339 pass 340 341 def qmsg_wait(self, progress): 342 global msgbox 343 msgbox = QtGui.QMessageBox() 344 layout = msgbox.layout() 345 layout.itemAtPosition(layout.rowCount() - 1, 0).widget().hide() 346 global progressx 347 progressx = QtGui.QProgressBar() 348 layout.addWidget(progressx, layout.rowCount(), 0, 1, layout.columnCount()) 349 350 msgbox.setWindowTitle("Progress") 351 msgbox.Information 352 msgbox.setText("Calculating, please be patient.") 353 354 progressx.setValue(int(progress)) 355 #msgbox.setModal(False) 356 msgbox.exec_() 357 358 def up2date(self, progress): 359 360 progressx.setValue(int(progress)) 361 if progress == 100: 362 msgbox.done(1) 363 364 def takeoff(self): 365 #self.qmsg_wait(0) 366 pass 367 368 def checkme(self, check): 369 #print(check) 370 self.testbar.setValue(int(check)) 371 372 if check == 100: 373 self.testbar.setVisible(False) 374 QtGui.QApplication.processEvents() 375 376 377 378 379 380 class Threadclass(QtCore.QThread): 381 def __init__(self, parent = None): 382 super(Threadclass, self).__init__(parent) 383 384 def runx(self): 385 #print("runx exec.") 386 self.execute() 387 388 389 390 def execute(self): 391 self.emit(QtCore.SIGNAL('startqmsg'), 0) 392 393 parameters = config_wr.read_config() 394 min_procs = int(parameters[0]) 395 max_procs = int(parameters[1]) 396 tpn = int(parameters[2]) 397 dnpexnpey = float(parameters[3]) 398 dnpexnpey_tol = int(parameters[4]) 399 dnxny = float(parameters[5]) 400 nx_min = int(parameters[6]) 401 nx_max = int(parameters[7]) 402 ny_min = int(parameters[8]) 403 ny_max = int(parameters[9]) 404 nz_min = int(parameters[10]) 405 nz_max = int(parameters[11]) 406 poisfft = parameters[12] 407 switch = parameters[13] 408 tempterton = parameters[14] 409 mlt_grid = parameters[15] 410 spectr = parameters[16] 411 result_thrs = parameters[17] 412 413 414 path = "/localdata/.palm_gf_data.db" 415 pathx = parameters[19] + '/.palm_gf_data.db' 416 417 418 conn = sqlite3.connect(pathx) 419 #conn = sqlite3.connect(".palm_gf_data.db") 420 c = conn.cursor() 421 c.execute("DROP TABLE IF EXISTS grid_current") 422 c.execute("DROP TABLE IF EXISTS grid_limits") 423 c.execute( 424 "CREATE TABLE IF NOT EXISTS grid_current(nx INT, ny INT, nz INT, npex INT, npey INT, npxnpy FLOAT, np INT, ngpts INT)") 425 c.execute( 426 "CREATE TABLE IF NOT EXISTS grid_limits(nx INT, ny INT, nz INT, npex INT, npey INT, npxnpy FLOAT, np INT, ngpts INT)") 427 conn.commit() 428 main_bool = True 429 430 431 432 433 if poisfft == str(True): 434 poisfft = True 435 else: 436 poisfft = False 437 438 if switch == str(True): 439 switch = True 440 else: 441 switch = False 442 443 if tempterton == str(True): 444 tempterton = True 445 else: 446 tempterton = False 447 448 if mlt_grid == str(True): 449 mlt_grid = True 450 else: 451 mlt_grid = False 452 453 if spectr == str(True): 454 spectr = True 455 else: 456 spectr = False 457 458 #print(spectr, type(spectr)) 459 #print(poisfft, switch, tempterton, mlt_grid, spectr) 460 461 np_used = min_procs 462 counter = 0 463 464 nx = nx_min 465 ny = ny_min 466 nz = nz_min 467 468 from math import floor 469 470 def factors(n): 471 result = [] 472 for i in range(2, n + 1): # test all integers between 2 and n 473 s = 0 474 while n / i == floor(n / float(i)): # is n/i an integer? 475 n = n / float(i) 476 s += 1 477 if s > 0: 478 for k in range(s): 479 result.append(i) # i is a pf s times 480 if n == 1: 481 return result 482 483 while np_used <= max_procs: 484 a = 1 485 486 while a <= np_used: 487 prcs_var = np_used % a 488 if prcs_var != 0: 489 a += 1 490 elif prcs_var == 0: 491 npex = a 492 npey = int(np_used / npex) 493 494 if tpn != 0: # XXX 495 496 if np_used % tpn != 0: 497 a += 1 498 continue 499 500 if dnpexnpey != 0 and npex / npey != dnpexnpey: 501 a += 1 502 continue 503 504 if dnpexnpey != 0: 505 506 507 if float(npex) / float(npey) < (dnpexnpey - dnpexnpey*dnpexnpey_tol/100): 508 a += 1 509 continue 510 511 if float(npex) / float(npey) > (dnpexnpey + dnpexnpey*dnpexnpey_tol/100): 512 a += 1 513 continue 514 515 while nx <= nx_max: 516 if (nx + 1) % npex != 0: 517 nx += 1 518 continue 519 520 if mlt_grid is True and (nx + 1) % 2 != 0: 521 nx += 1 522 continue 523 524 if switch is True and (nx + 1) % npey != 0: 525 nx += 1 526 continue 527 if npex > nx: 528 nx += 1 529 continue 530 531 while ny <= ny_max: 532 533 if dnxny != 0 and float(nx) / float(ny) != float(dnxny): 534 ny += 1 535 continue 536 if (ny + 1) % npey != 0: 537 ny += 1 538 continue 539 540 #if mlt_grid is True and ny % 2 != 0: mlt and mlt_noOpt have same cond. 541 # ny += 1 542 # continue 543 544 if (ny + 1) % npex != 0 and switch is True: 545 ny += 1 546 continue 547 if npey > ny: 548 ny += 1 549 continue 550 551 while nz <= nz_max: 552 553 if mlt_grid is True and nz % 2 != 0: 554 nz += 1 555 continue 556 557 if poisfft is True and nz % npex != 0: 558 nz += 1 559 continue 560 561 if spectr is True and nz % npey != 0: 562 nz += 1 563 continue 564 565 if tempterton is True and nx > 1 and ny > 1: # and nz < 1: 566 567 nx_list = factors(nx + 1) 568 569 i = 0 570 nx_var = nx_list[i] 571 572 573 while i < len(nx_list): 574 if nx_var != 2 or nx_var != 3 or nx_var != 5: 575 i += 1 576 continue 577 578 i += 1 579 ny_list = factors(ny + 1) 580 i = 0 581 ny_var = ny_list[i] 582 while i < len(ny_list): 583 if ny_var != 2 or ny_var != 3 or ny_var != 5: 584 i += 1 585 continue 586 i += 1 587 588 counter += 1 589 if counter > int(result_thrs): 590 break 591 592 npxnpy = format(float(npex) / float(npey), '.2f') 593 c.execute( 594 """INSERT OR REPLACE INTO grid_current(nx, ny, nz, npex, npey, npxnpy, np, ngpts) VALUES (?, ?, ?, ?, ?, ?, ?, ?)""", 595 (nx, ny, nz, npex, npey, npxnpy, (npex * npey), (nx * ny * nz))) 596 597 nz += 1 598 nz = nz_min 599 ny += 1 600 ny = ny_min 601 nx += 1 602 nx = nx_min 603 a += 1 604 # a += 1 605 np_used += 1 606 progr_act = 100*(float(np_used-1)/float(max_procs)) 607 self.emit(QtCore.SIGNAL('check'), progr_act) 608 #print(np_used, max_procs, progr_act) 609 self.emit(QtCore.SIGNAL('progress'), progr_act) 610 611 conn.commit() 612 613 conn.commit() 614 #c.close() 615 #conn.close() 616 # 617 ## ******************************** 618 # 619 #conn = sqlite3.connect(parameters[19] + '/.palm_gf_data.db') 620 #print parameters[19] + '/.palm_gf_data.db' 621 #c = conn.cursor() 622 try: 623 c.execute("SELECT nx FROM grid_current ORDER BY nx DESC LIMIT 1") 624 mx_nx = c.fetchone()[0] 625 # print(mx_nx) 626 c.execute("SELECT nx FROM grid_current ORDER BY nx LIMIT 1") 627 mn_nx = c.fetchone()[0] 628 # print(mn_nx) 629 c.execute("SELECT ny FROM grid_current ORDER BY ny DESC LIMIT 1") 630 mx_ny = c.fetchone()[0] 631 # print(mx_ny) 632 c.execute("SELECT ny FROM grid_current ORDER BY ny LIMIT 1") 633 mn_ny = c.fetchone()[0] 634 # print(mn_ny) 635 c.execute("SELECT nz FROM grid_current ORDER BY nz DESC LIMIT 1") 636 mx_nz = c.fetchone()[0] 637 # print(mx_nz) 638 c.execute("SELECT nz FROM grid_current ORDER BY nz LIMIT 1") 639 mn_nz = c.fetchone()[0] 640 # print(mn_nz) 641 c.execute("SELECT npex FROM grid_current ORDER BY npex DESC LIMIT 1") 642 mx_npex = c.fetchone()[0] 643 # print(mx_npex) 644 c.execute("SELECT npex FROM grid_current ORDER BY npex LIMIT 1") 645 mn_npex = c.fetchone()[0] 646 # print(mn_npex) 647 c.execute("SELECT npey FROM grid_current ORDER BY npey DESC LIMIT 1") 648 mx_npey = c.fetchone()[0] 649 # print(mx_npey) 650 c.execute("SELECT npey FROM grid_current ORDER BY npey LIMIT 1") 651 mn_npey = c.fetchone()[0] 652 # print(mn_npey) 653 c.execute("SELECT npxnpy FROM grid_current ORDER BY npxnpy DESC LIMIT 1") 654 mx_npxnpy = c.fetchone()[0] 655 # print(mx_npxnpy) 656 c.execute("SELECT npxnpy FROM grid_current ORDER BY npxnpy LIMIT 1") 657 mn_npxnpy = c.fetchone()[0] 658 # print(mn_npxnpy) 659 c.execute("SELECT np FROM grid_current ORDER BY np DESC LIMIT 1") 660 mx_np = c.fetchone()[0] 661 # print(mx_np) 662 c.execute("SELECT np FROM grid_current ORDER BY np LIMIT 1") 663 mn_np = c.fetchone()[0] 664 # print(mn_np) 665 c.execute("SELECT ngpts FROM grid_current ORDER BY ngpts DESC LIMIT 1") 666 mx_ngpts = c.fetchone()[0] 667 # print(mx_ngpts) 668 c.execute("SELECT ngpts FROM grid_current ORDER BY ngpts LIMIT 1") 669 mn_ngpts = c.fetchone()[0] 670 # print(mn_ngpts) 671 672 conn.commit() 673 c.execute( 674 """INSERT OR REPLACE INTO grid_limits(nx, ny, nz, npex, npey, npxnpy, np, ngpts) VALUES (?, ?, ?, ?, ?, ?, ?, ?)""", 675 (mn_nx, mn_ny, mn_nz, mn_npex, mn_npey, mn_npxnpy, mn_np, mn_ngpts)) 676 677 c.execute( 678 """INSERT OR REPLACE INTO grid_limits(nx, ny, nz, npex, npey, npxnpy, np, ngpts) VALUES (?, ?, ?, ?, ?, ?, ?, ?)""", 679 (mx_nx, mx_ny, mx_nz, mx_npex, mx_npey, mx_npxnpy, mx_np, mx_ngpts)) 680 conn.commit() 681 682 c.close() 683 conn.close() 684 except TypeError: 685 686 checkfile = open(".palm_gf_tmp", "w") 687 if counter != 0: 688 checkfile.write("Gridfinder found " + str(counter) + " results.\n1") 689 else: 690 checkfile.write("Check input, no Results found.\n0") 691 checkfile.close() 692 693 checkfile = open(".palm_gf_tmp", "w") 694 if counter != 0: 695 checkfile.write("Gridfinder found " + str(counter) + " results.\n1") 696 else: 697 checkfile.write("Check input, no Results found.\n0") 698 checkfile.close() 699 self.emit(QtCore.SIGNAL('finish'), 1) 700 #print("finished with main execute") 701 702 703 704 705 706 qtpopupFile = palm_bin + '/palm_gf_files/palm_gf_settings.ui' 707 Ui_Pop, QtBaseClass = uic.loadUiType(qtpopupFile) 708 709 710 class MyPopup(QtGui.QWidget, Ui_Pop): 711 712 def __init__(self): 713 Qt.QWidget.__init__(self) 714 Ui_Pop.__init__(self) 715 716 self.setupUi(self) 717 self.show 718 self.savepath.clicked.connect(self.path_to_save) 719 self.begin_check() 720 self.buttonBox.accepted.connect(self.end_check) 721 self.buttonBox.rejected.connect(self.close) 722 723 724 def begin_check(self): 725 file_check = palm_dir + '/trunk/SCRIPTS/.palm_gf_config' 726 if os.path.isfile(file_check) is True: 727 parameters = config_wr.read_config_settings() 728 self.linepath.setText(parameters[0]) 729 self.result_thres.setValue(int(parameters[1])) 730 self.load_thres.setValue(int(parameters[2])) 731 732 def end_check(self): 733 config_wr.write_config_settings(self.linepath.text(), self.result_thres.value(), self.load_thres.value()) 734 735 self.close() 736 737 738 739 740 741 def path_to_save(self, wildcard= None): 742 import wx 743 app = wx.App(None) 744 style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST 745 dialog = wx.DirDialog(None, 'Open') 746 if dialog.ShowModal() == wx.ID_OK: 747 path = str(dialog.GetPath()) 748 749 print(path) 750 self.linepath.setText(path) 751 752 753 754 else: 755 path = None 756 dialog.Destroy() 757 return 758 759 760 761 762 763 764 359 765 360 766 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.