1 | #!/usr/bin/env python3 |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | #--------------------------------------------------------------------------------# |
---|
4 | # This file is part of the PALM model system. |
---|
5 | # |
---|
6 | # PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | # of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | # either version 3 of the License, or (at your option) any later version. |
---|
9 | # |
---|
10 | # PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | # |
---|
14 | # You should have received a copy of the GNU General Public License along with |
---|
15 | # PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | # |
---|
17 | # Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
18 | #--------------------------------------------------------------------------------# |
---|
19 | # |
---|
20 | # Current revisions: |
---|
21 | # ----------------- |
---|
22 | # |
---|
23 | # |
---|
24 | # Former revisions: |
---|
25 | # ----------------- |
---|
26 | # $Id: palmrungui 4789 2020-11-18 09:05:50Z gronemeier $ |
---|
27 | # Bugfix: set check boxes for cyclic fill and svf I/O when loading job from history. |
---|
28 | # Added support for option -W (wait for job; dependency mode) |
---|
29 | # |
---|
30 | # |
---|
31 | # 4670 2020-09-09 17:27:45Z maronga |
---|
32 | # Ported to PyQt5, removed support for user parameters. Added support for Option |
---|
33 | # "-V" (do not re-build pre-built source code). Changed activation strings |
---|
34 | # according to default .palm.iofiles (svfin/svfout/rec) |
---|
35 | # |
---|
36 | # 4482 2020-04-01 13:17:50Z maronga |
---|
37 | # Added possibility to delete all files in a directory and option to create |
---|
38 | # blank new jobs |
---|
39 | # |
---|
40 | # 4481 2020-03-31 18:55:54Z maronga |
---|
41 | # Bugfixes: - reading history lines discard button caused error message |
---|
42 | # - deleting of USER_CODE files did not work |
---|
43 | # |
---|
44 | # 4470 2020-03-24 06:52:19Z maronga |
---|
45 | # Added file size output, more I/O functionalities, new/removed buttons |
---|
46 | # |
---|
47 | # 4428 2020-02-27 11:43:53Z maronga |
---|
48 | # Bugfix for update button |
---|
49 | # |
---|
50 | # 4427 2020-02-27 11:29:51Z maronga |
---|
51 | # Small fixes and adjustments |
---|
52 | # |
---|
53 | # 4420 2020-02-24 14:13:56Z maronga |
---|
54 | # Bugfix: minor fixes related to start buttons |
---|
55 | # |
---|
56 | # 4411 2020-02-18 14:28:02Z maronga |
---|
57 | # Added new features: individual tag for submitted runs, automatic finding of |
---|
58 | # configuration, start of palmbuild from GUI |
---|
59 | # |
---|
60 | # 4405 2020-02-12 19:11:11Z maronga |
---|
61 | # Major revisions: New layout. Merged with palm job manager (palm_jm). |
---|
62 | # Minor revisions: Misc. bugs fixed. |
---|
63 | # |
---|
64 | # 4394 2020-02-04 21:40:38Z maronga |
---|
65 | # Bugfix: harmonized naming convention of configuration files |
---|
66 | # |
---|
67 | # 4393 2020-02-04 21:24:48Z maronga |
---|
68 | # Removed PALM_BIN dependency and os calls |
---|
69 | # |
---|
70 | # 3487 2018-11-05 07:18:02Z maronga |
---|
71 | # Renamed options -d and -h to -r and -c. |
---|
72 | # |
---|
73 | # 2825 2018-02-20 21:48:27Z maronga |
---|
74 | # Adjusted to work with newest version of palmrun |
---|
75 | # |
---|
76 | # 2718 2018-01-02 08:49:38Z maronga |
---|
77 | # Corrected "Former revisions" section |
---|
78 | # |
---|
79 | # 2696 2017-12-14 17:12:51Z kanani |
---|
80 | # Change in file header (GPL part) |
---|
81 | # |
---|
82 | # 2484 2017-09-20 14:22:42Z maronga |
---|
83 | # Added PALM logo |
---|
84 | # |
---|
85 | # 2480 2017-09-19 06:24:14Z maronga |
---|
86 | # option -A (project account number) added |
---|
87 | # |
---|
88 | # 2477 2017-09-18 08:42:29Z maronga |
---|
89 | # Renamed restart run appendix from "f" to "r". Bugfix for displaying restart runs.> |
---|
90 | # Revised list of recently submitted jobs |
---|
91 | # |
---|
92 | # 2413 2017-09-06 12:48:29Z maronga |
---|
93 | # Renamed to palmrungui and adapted for use with palmrun instead of mrun. |
---|
94 | # |
---|
95 | # 2316 2017-07-20 07:53:42Z maronga |
---|
96 | # Initial revision in python |
---|
97 | # |
---|
98 | # |
---|
99 | # |
---|
100 | # Description: |
---|
101 | # ------------ |
---|
102 | # Graphical user interface for the palmrun script. |
---|
103 | # @author Felix Gaschler |
---|
104 | # @author Björn Maronga (maronga@muk.uni-hannover.de) |
---|
105 | # |
---|
106 | # Instructions: |
---|
107 | # ------------- |
---|
108 | # |
---|
109 | #------------------------------------------------------------------------------! |
---|
110 | import sys |
---|
111 | import subprocess |
---|
112 | from PyQt5 import QtCore, QtGui, uic, QtWidgets |
---|
113 | from PyQt5.QtWidgets import QMainWindow, QApplication |
---|
114 | from PyQt5.QtCore import QProcess, pyqtSlot, QTimer |
---|
115 | from time import strftime |
---|
116 | import os |
---|
117 | import shutil |
---|
118 | |
---|
119 | global update_frequency |
---|
120 | update_frequency = 5*60000 |
---|
121 | |
---|
122 | # Determine PALM directories |
---|
123 | try: |
---|
124 | devnull = open(os.devnull, 'w') |
---|
125 | palm_dir = os.getcwd() |
---|
126 | palm_bin = palm_dir + '/trunk/SCRIPTS' |
---|
127 | palm_source = palm_dir + '/trunk/SOURCE' |
---|
128 | job_dir = palm_dir + '/JOBS' |
---|
129 | user_dir = palm_dir + '/USER_CODE' |
---|
130 | with open(palm_bin + '/palmrungui', 'r', encoding='utf8') as fh: |
---|
131 | # file found |
---|
132 | out = None |
---|
133 | except: |
---|
134 | print ("Error. palmrungui probably called in wrong directory.") |
---|
135 | raise SystemExit |
---|
136 | |
---|
137 | |
---|
138 | # returns the human readable file size of filename |
---|
139 | def file_size(filename, suffix='B'): |
---|
140 | size_raw = os.stat(filename).st_size |
---|
141 | for unit in [' ',' K',' M',' G',' T']: |
---|
142 | if abs(size_raw) < 1024.0: |
---|
143 | return "%i%s%s" % (size_raw, unit, suffix) |
---|
144 | size_raw /= 1024.0 |
---|
145 | return "%.1f%s%s" % (num, 'Y', suffix) |
---|
146 | |
---|
147 | def ilen(iterable): |
---|
148 | return reduce(lambda sum, element: sum + 1, iterable, 0) |
---|
149 | |
---|
150 | palmrunline = "" |
---|
151 | set_list = [] |
---|
152 | |
---|
153 | Ui_MainWindow = uic.loadUiType("%s/palmrungui_files/mainwindow.ui" % (palm_bin))[0] |
---|
154 | Ui_helpDialog = uic.loadUiType("%s/palmrungui_files/help.ui" % (palm_bin))[0] |
---|
155 | Ui_aboutDialog = uic.loadUiType("%s/palmrungui_files/about.ui" % (palm_bin))[0] |
---|
156 | |
---|
157 | class HelpDialog(QtWidgets.QDialog,Ui_helpDialog): |
---|
158 | def __init__(self, parent=None): |
---|
159 | super(HelpDialog,self).__init__() |
---|
160 | self.setupUi(self) |
---|
161 | |
---|
162 | class AboutDialog(QtWidgets.QDialog,Ui_aboutDialog): |
---|
163 | def __init__(self, parent=None): |
---|
164 | super(AboutDialog,self).__init__() |
---|
165 | self.setupUi(self) |
---|
166 | |
---|
167 | class Mainwindow(QtWidgets.QMainWindow, Ui_MainWindow): |
---|
168 | def __init__(self, parent=None): |
---|
169 | super(Mainwindow, self).__init__() |
---|
170 | self.setupUi(self) |
---|
171 | |
---|
172 | self.palm_logo.setPixmap(QtGui.QPixmap(palm_bin + "/palmrungui_files/logo.png")) |
---|
173 | with open(palm_bin + "/palmrungui", encoding='utf8') as search: |
---|
174 | for line in search: |
---|
175 | line = line.rstrip() |
---|
176 | if "$Id" in line: |
---|
177 | version = "Version: r" + line.split(" ")[3] + " (" + line.split(" ")[4] + ")" |
---|
178 | self.groupBox.findChild(QtWidgets.QLabel,"label_version").setText(version) |
---|
179 | break |
---|
180 | self.recent_jobs(50) |
---|
181 | self.load_jobs() |
---|
182 | |
---|
183 | |
---|
184 | |
---|
185 | # look up configuration files and add to combo box |
---|
186 | |
---|
187 | self.group_execution.findChild(QtWidgets.QComboBox,"combo_configuration").addItem("") |
---|
188 | |
---|
189 | for files in os.listdir(palm_dir): |
---|
190 | if files.startswith(".palm.config"): |
---|
191 | tmpstring = list(filter(None,files.split(".palm.config.")))[0] |
---|
192 | self.group_execution.findChild(QtWidgets.QComboBox,"combo_configuration").addItem(tmpstring) |
---|
193 | |
---|
194 | commandline = self.groupBox.findChild(QtWidgets.QLineEdit,"commandline") |
---|
195 | commandline.setText("") |
---|
196 | |
---|
197 | self.tabWidget.setCurrentIndex(0) |
---|
198 | |
---|
199 | |
---|
200 | filename = "%s/.palmrungui.default" % (palm_dir) |
---|
201 | if os.path.exists(filename): |
---|
202 | file = open(filename, "r") |
---|
203 | if ( file is not None ): |
---|
204 | # File opened successfully |
---|
205 | palmrunline = file.readline() |
---|
206 | #if neue zeile zeichen |
---|
207 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
208 | file.close() |
---|
209 | |
---|
210 | # In case a palmrunline was found, load it to mainwindow |
---|
211 | if ( palmrunline != ""): |
---|
212 | palmrunline = palmrunline[17:] |
---|
213 | commandline.setText(palmrunline) |
---|
214 | self.setup_gui(palmrunline) |
---|
215 | |
---|
216 | QtWidgets.QApplication.processEvents() |
---|
217 | |
---|
218 | # Start refresh timer. On timeout perform update |
---|
219 | |
---|
220 | self.timer = QtCore.QTimer(self) |
---|
221 | self.timer.timeout.connect(self.update_all) |
---|
222 | self.timer.setSingleShot(False) |
---|
223 | self.timer.start(update_frequency) |
---|
224 | |
---|
225 | # The timetimer counts the time since last update |
---|
226 | self.timetimer= QtCore.QElapsedTimer() |
---|
227 | self.timetimer.start() |
---|
228 | |
---|
229 | # The labeltimer induces the update of the remaining time in the UI |
---|
230 | |
---|
231 | self.labeltimer = QtCore.QTimer(self) |
---|
232 | self.labeltimer.timeout.connect(self.UpdatePush) |
---|
233 | self.labeltimer.setSingleShot(False) |
---|
234 | |
---|
235 | # Update in the UI will be performed at each 1/10 of the update interval |
---|
236 | self.labeltimer.start(update_frequency/10) |
---|
237 | self.push_update.setText("Update (" + str(int(update_frequency/1000/60)) + " min)") |
---|
238 | |
---|
239 | # starts xterm with palmrun commandline |
---|
240 | ####################################### |
---|
241 | def startpalmrun(self): |
---|
242 | palmrunline = str(self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").text()) |
---|
243 | palmrunline_save = palmrunline |
---|
244 | |
---|
245 | # Disable the main window |
---|
246 | self.tabWidget.setEnabled(False) |
---|
247 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setEnabled(False) |
---|
248 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(False) |
---|
249 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setText("wait...") |
---|
250 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText("Executing palmrun in xterm...") |
---|
251 | |
---|
252 | # Wait until all commands have been executed (ugly) ? |
---|
253 | #for i in range(0,21): |
---|
254 | # qApp->processEvents() |
---|
255 | |
---|
256 | # Start xterm as QProcess |
---|
257 | palmrun = QProcess() |
---|
258 | palmrun.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels |
---|
259 | palmrun.setWorkingDirectory(palm_dir) |
---|
260 | |
---|
261 | geomet = self.frameGeometry() |
---|
262 | |
---|
263 | posx = geomet.x()+geomet.width() |
---|
264 | posy = geomet.y() |
---|
265 | |
---|
266 | if ( os.path.isfile("palmrungui.log") ): |
---|
267 | os.remove("palmrungui.log") |
---|
268 | |
---|
269 | s = " -title \"Executing palmrun...\" -fa \"Monospace\" -l -lf \"palmrungui.log\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy) |
---|
270 | palmrunline = "%s%s ;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmrunline.replace("\"","\'")) |
---|
271 | |
---|
272 | mString = "xterm %s" % (palmrunline) |
---|
273 | palmrun.start(mString) |
---|
274 | |
---|
275 | if( palmrun.waitForStarted() is False ): |
---|
276 | return |
---|
277 | |
---|
278 | # Wait until palmrun has finished or wait for 200 minutes |
---|
279 | palmrun.waitForFinished(3600000) |
---|
280 | |
---|
281 | # Jobs has been submitted or aborted. Continuing... |
---|
282 | # Save the palmrun command to history file |
---|
283 | filename = "%s/.palmrungui.history" % (palm_dir) |
---|
284 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
285 | tag = str(self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").text()) |
---|
286 | |
---|
287 | file = open(filename,"a") |
---|
288 | s = "%s %s (%s)\n" % (tmstamp,palmrunline_save,tag) |
---|
289 | file.write(s) |
---|
290 | file.close() |
---|
291 | |
---|
292 | # Enable main window again |
---|
293 | self.tabWidget.setEnabled(True) |
---|
294 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setEnabled(True) |
---|
295 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setText("palmrun") |
---|
296 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText(palmrunline_save) |
---|
297 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(True) |
---|
298 | |
---|
299 | # Reload recent jobs |
---|
300 | self.recent_jobs(50) |
---|
301 | |
---|
302 | |
---|
303 | |
---|
304 | # Update the label |
---|
305 | def UpdatePush(self): |
---|
306 | remaining_time = int((update_frequency - self.timetimer.elapsed()) / 1000 / 60) |
---|
307 | self.push_update.setText("Update (" + str(remaining_time) + " min)") |
---|
308 | |
---|
309 | |
---|
310 | # starts xterm with palmbuild commandline |
---|
311 | ####################################### |
---|
312 | def startpalmbuild(self): |
---|
313 | palmbuildline = 'palmbuild -c ' + str(self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration").currentText()) |
---|
314 | |
---|
315 | full_build = self.group_execution.findChild(QtWidgets.QCheckBox,"check_rebuild").checkState() |
---|
316 | |
---|
317 | if ( full_build == 2 ): |
---|
318 | for filename in os.listdir(palm_source): |
---|
319 | os.utime(palm_source + "/" + filename, None) |
---|
320 | |
---|
321 | palmrunline_save = str(self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").text()) |
---|
322 | |
---|
323 | # Disable the main window |
---|
324 | palmbuildline_save = palmbuildline |
---|
325 | self.tabWidget.setEnabled(False) |
---|
326 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setEnabled(False) |
---|
327 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(False) |
---|
328 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setText("wait...") |
---|
329 | self.group_execution.findChild(QtWidgets.QPushButton,"button_palmbuild").setText("wait...") |
---|
330 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText("Executing palmbuild in xterm...") |
---|
331 | |
---|
332 | # Wait until all commands have been executed (ugly) ? |
---|
333 | #for i in range(0,21): |
---|
334 | # qApp->processEvents() |
---|
335 | |
---|
336 | # Start xterm as QProcess |
---|
337 | palmbuild = QProcess() |
---|
338 | palmbuild.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels |
---|
339 | palmbuild.setWorkingDirectory(palm_dir) |
---|
340 | |
---|
341 | geomet = self.frameGeometry() |
---|
342 | |
---|
343 | posx = geomet.x()+geomet.width() |
---|
344 | posy = geomet.y() |
---|
345 | |
---|
346 | s = " -title \"Executing palmbuild...\" -fa \"Monospace\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy) |
---|
347 | palmbuildline = "%s%s;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmbuildline.replace("\"","\'")) |
---|
348 | |
---|
349 | mString = "xterm %s" % (palmbuildline) |
---|
350 | palmbuild.start(mString) |
---|
351 | |
---|
352 | if( palmbuild.waitForStarted() is False ): |
---|
353 | return |
---|
354 | |
---|
355 | # Wait until palmbuild has finished or wait for 200 minutes |
---|
356 | palmbuild.waitForFinished(3600000) |
---|
357 | |
---|
358 | |
---|
359 | |
---|
360 | # Enable main window again |
---|
361 | self.tabWidget.setEnabled(True) |
---|
362 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setEnabled(True) |
---|
363 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(True) |
---|
364 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setText("palmrun") |
---|
365 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText(palmrunline_save) |
---|
366 | self.group_execution.findChild(QtWidgets.QPushButton,"button_palmbuild").setText("(re-)build") |
---|
367 | # Reload recent jobs |
---|
368 | self.recent_jobs(50) |
---|
369 | |
---|
370 | # loads recent jobs |
---|
371 | ###################################### |
---|
372 | def recent_jobs(self, number): |
---|
373 | fileDir = "%s/.palmrungui.history" % (palm_dir) |
---|
374 | if os.path.exists(fileDir): |
---|
375 | pass |
---|
376 | else: |
---|
377 | return |
---|
378 | |
---|
379 | file = open(fileDir,"r") |
---|
380 | history = file.readlines() |
---|
381 | tmphistory = list() |
---|
382 | tmptag = list() |
---|
383 | file.close() |
---|
384 | j = 0 |
---|
385 | |
---|
386 | list_jobname = self.group_history.findChild(QtWidgets.QListWidget,"list_jobname") |
---|
387 | list_jobname.clear() |
---|
388 | |
---|
389 | # Read history entries and append to recent job list |
---|
390 | i=len(history)-1 |
---|
391 | count = 0 |
---|
392 | while i>=0 and count<number: |
---|
393 | timestamp = history[i][:16] |
---|
394 | listitem = history[i][17:len(history[i])-1] |
---|
395 | tagitem = listitem |
---|
396 | configitem = listitem |
---|
397 | matchitems = list_jobname.findItems(listitem, QtCore.Qt.MatchExactly) |
---|
398 | |
---|
399 | if ( len(matchitems) == 0 ): |
---|
400 | listitem = list(filter(None,listitem.split(" -r")))[1] |
---|
401 | listitem = listitem.strip() |
---|
402 | listitem = list(filter(None,listitem.split(" ")))[0] |
---|
403 | listitem = listitem.replace("\"","") |
---|
404 | list_jobname.addItem(listitem) |
---|
405 | |
---|
406 | configitem = list(filter(None,configitem.split(" -c"))) |
---|
407 | if ( len(configitem) < 2): |
---|
408 | count = count +1 |
---|
409 | continue |
---|
410 | else: |
---|
411 | configitem = configitem[1].strip() |
---|
412 | configitem = list(filter(None,configitem.split(" ")))[0] |
---|
413 | configitem = configitem.replace("\"","") |
---|
414 | |
---|
415 | s = "%s: %s (%s)" % (timestamp,listitem,configitem) |
---|
416 | tmphistory.append(s) |
---|
417 | |
---|
418 | |
---|
419 | tagitem = list(filter(None,tagitem.split(" (")))[1] |
---|
420 | tagitem = tagitem.replace(")","") |
---|
421 | if ( len(tagitem) == 0 ): |
---|
422 | s = "Tag: empty" |
---|
423 | else: |
---|
424 | s = "Tag: %s" % (tagitem) |
---|
425 | tmptag.append(s) |
---|
426 | count = count +1 |
---|
427 | |
---|
428 | j = j+1 |
---|
429 | |
---|
430 | if ( j == number ): |
---|
431 | break |
---|
432 | i = i-1 |
---|
433 | |
---|
434 | # Send to list |
---|
435 | list_jobname.clear() |
---|
436 | |
---|
437 | i=0 |
---|
438 | while i<len(tmphistory): |
---|
439 | list_jobname.addItem(tmphistory[i]) |
---|
440 | list_jobname.item(i).setToolTip(tmptag[i]) |
---|
441 | i = i+1 |
---|
442 | |
---|
443 | |
---|
444 | # Enables coupled settings |
---|
445 | ############################### |
---|
446 | def enable_coupled(self): |
---|
447 | coupledState = self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").currentText() |
---|
448 | group = self.group_execution.findChild(QtWidgets.QGroupBox, "group_coupled") |
---|
449 | |
---|
450 | if (coupledState == "Restart run (coupled atmosphere ocean)" or coupledState == "Initial run (coupled atmosphere ocean)"): |
---|
451 | self.group_coupled.setEnabled(True) |
---|
452 | else: |
---|
453 | self.group_coupled.setEnabled(False) |
---|
454 | |
---|
455 | |
---|
456 | # select a job via click from list |
---|
457 | ################################# |
---|
458 | def choosejob_list(self): |
---|
459 | # Get selected item from list |
---|
460 | list_jobname = self.group_history.findChild(QtWidgets.QListWidget,"list_jobname") |
---|
461 | filename = str(list_jobname.currentItem().text()) |
---|
462 | |
---|
463 | timestamp = filename[:16] |
---|
464 | jobname = filename[18:].split(" ")[0] |
---|
465 | |
---|
466 | itemint = list_jobname.currentRow() |
---|
467 | |
---|
468 | # Reload list |
---|
469 | self.recent_jobs(50) |
---|
470 | self.load_jobs() |
---|
471 | |
---|
472 | # Set selected item to jobname |
---|
473 | list_jobname.item(itemint).setSelected(True) |
---|
474 | |
---|
475 | # Set selected item to jobname in "available jobs" list |
---|
476 | item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive) |
---|
477 | |
---|
478 | if ( item2int != [] ): |
---|
479 | self.list_jobs.setCurrentItem(item2int[0]) |
---|
480 | self.update_input() |
---|
481 | |
---|
482 | |
---|
483 | fileDir = "%s/.palmrungui.history" % (palm_dir) |
---|
484 | file = open(fileDir,"r") |
---|
485 | history = file.readlines() |
---|
486 | tmphistory = list() |
---|
487 | file.close() |
---|
488 | |
---|
489 | i = len(history) |
---|
490 | while i>=1: |
---|
491 | listitem = history[i-1][17:len(history[i-1])-1] |
---|
492 | listitem = list(filter(None,listitem.split(" -r")))[1] |
---|
493 | listitem = listitem.strip() |
---|
494 | listitem = list(filter(None,listitem.split(" ")))[0] |
---|
495 | listitem = listitem.replace("\"","") |
---|
496 | |
---|
497 | # Select command line with correct timestamp and jobname |
---|
498 | if (history[i-1][:16] == timestamp and listitem == jobname): |
---|
499 | palmrunline = history[i-1] |
---|
500 | palmrunline = palmrunline[17:] |
---|
501 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
502 | palmrunline = list(filter(None,palmrunline.split("(")))[0] |
---|
503 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText(palmrunline) |
---|
504 | |
---|
505 | |
---|
506 | tag = history[i-1].split('\n')[0] |
---|
507 | tag = list(filter(None,tag.split("(")))[1] |
---|
508 | tag = tag.replace(")","") |
---|
509 | |
---|
510 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setText(tag) |
---|
511 | self.setup_gui(palmrunline) |
---|
512 | self.list_jobname.item(itemint).setSelected(True) |
---|
513 | |
---|
514 | return |
---|
515 | i = i-1 |
---|
516 | |
---|
517 | # Change run identifer (initial, restart, coupled...) |
---|
518 | ###################################################### |
---|
519 | def change_rc_list(self): |
---|
520 | drop_job = self.group_execution.findChild(QtWidgets.QComboBox,"drop_job").currentText() |
---|
521 | self.change_commandline("a","") |
---|
522 | |
---|
523 | # Enable PE distribution for atmosphere/ocean |
---|
524 | if ( drop_job == "Restart run (coupled atmosphere ocean)" or drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
525 | drop_atmos = self.group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_atmos").text() |
---|
526 | drop_ocean = self.group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_ocean").text() |
---|
527 | s = "%s %s" % (drop_atmos,drop_ocean) |
---|
528 | self.change_commandline("Y",s) |
---|
529 | |
---|
530 | |
---|
531 | if ( drop_job == "Restart run" or drop_job == "Restart run (coupled atmosphere ocean)"): |
---|
532 | self.change_commandline("r","") |
---|
533 | |
---|
534 | # Check of ocean runs |
---|
535 | else: |
---|
536 | self.delete_commandline("Y") |
---|
537 | if (drop_job == "Precursor run (ocean)"): |
---|
538 | self.activate_flag("y") |
---|
539 | else: |
---|
540 | self.deactivate_flag("y") |
---|
541 | |
---|
542 | # changes commandline depending on parameters |
---|
543 | ########################################################## |
---|
544 | def change_commandline(self, id_str, fwt_str): |
---|
545 | fwt_str = str(fwt_str) |
---|
546 | initialize = False |
---|
547 | palmrunline = str(self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").text()) |
---|
548 | s = " -%s " % (id_str) |
---|
549 | splitline = list(filter(None,palmrunline.split(s))) |
---|
550 | |
---|
551 | if ( len(splitline) == 0 ): |
---|
552 | splitline.append("palmrun") |
---|
553 | splitline.append(" ") |
---|
554 | initialize = True |
---|
555 | |
---|
556 | elif ( len(splitline) == 1 ): |
---|
557 | splitline.append(" ") |
---|
558 | |
---|
559 | param = splitline[1].split("-") |
---|
560 | |
---|
561 | # Change in parameter "r" (jobname) |
---|
562 | if (id_str == "r"): |
---|
563 | filename = str(self.group_execution.findChild(QtWidgets.QLineEdit,"line_jobname").text()) |
---|
564 | s = filename.split("JOBS/") |
---|
565 | param[0] = s[len(s)-1] |
---|
566 | |
---|
567 | if ( initialize == True ):#and self.group_runcontrol.isEnabled() == True ): |
---|
568 | self.group_execution.setEnabled(True) |
---|
569 | self.group_execution.findChild(QtWidgets.QComboBox,"drop_job").setEnabled(True) |
---|
570 | self.group_advanced.setEnabled(True) |
---|
571 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setEnabled(True) |
---|
572 | self.menuBar.findChild(QtWidgets.QMenu,"menuStart").actions()[3].setEnabled(True) |
---|
573 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(True) |
---|
574 | |
---|
575 | elif ( param[0] == ""): |
---|
576 | self.group_execution.setEnabled(False) |
---|
577 | self.group_execution.findChild(QtWidgets.QComboBox,"drop_job").setEnabled(False) |
---|
578 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setEnabled(False) |
---|
579 | self.menuBar.findChild(QtWidgets.QMenu,"menuStart").actions()[3].setEnabled(False) |
---|
580 | self.group_advanced.setEnabled(False) |
---|
581 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(True) |
---|
582 | self.delete_commandline("r") |
---|
583 | self.change_commandline("a","remove") |
---|
584 | return 1 |
---|
585 | |
---|
586 | else: |
---|
587 | |
---|
588 | self.group_execution.setEnabled(True) |
---|
589 | self.drop_job.setEnabled(True) |
---|
590 | self.group_advanced.setEnabled(True) |
---|
591 | |
---|
592 | # Change in parameter "a" (run control list) |
---|
593 | elif (id_str == "a"): |
---|
594 | |
---|
595 | drop_job = self.group_execution.findChild(QtWidgets.QComboBox,"drop_job").currentText() |
---|
596 | rc_flag = "#" |
---|
597 | |
---|
598 | if (drop_job == "Initial run"): |
---|
599 | rc_flag = "#" |
---|
600 | |
---|
601 | elif (drop_job == "Restart run"): |
---|
602 | rc_flag = "r" |
---|
603 | |
---|
604 | elif (drop_job == "Precursor run (atmosphere)"): |
---|
605 | rc_flag = "#" |
---|
606 | |
---|
607 | elif (drop_job == "Precursor run (ocean)"): |
---|
608 | rc_flag = "o#" |
---|
609 | |
---|
610 | elif (drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
611 | rc_flag = "#" |
---|
612 | |
---|
613 | elif (drop_job == "Restart run (coupled atmosphere ocean)"): |
---|
614 | rc_flag = "r" |
---|
615 | |
---|
616 | param[0] = "\"d3%s" % (rc_flag) |
---|
617 | |
---|
618 | |
---|
619 | if (drop_job == "Restart run (coupled atmosphere ocean)" or drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
620 | if (rc_flag == "#"): |
---|
621 | rc_flag = "o#" |
---|
622 | else: |
---|
623 | rc_flag = "or" |
---|
624 | |
---|
625 | param[0] = "%s d3%s" % (param[0],rc_flag) |
---|
626 | |
---|
627 | status_restarts = self.group_execution.findChild(QtWidgets.QCheckBox,"check_restarts").checkState() |
---|
628 | |
---|
629 | if (status_restarts == 2): |
---|
630 | param[0]="%s restart" % (param[0]) |
---|
631 | |
---|
632 | |
---|
633 | status_cycfill = self.group_execution.findChild(QtWidgets.QCheckBox,"check_cycfill").checkState() |
---|
634 | |
---|
635 | if (status_cycfill == 2): |
---|
636 | param[0]="%s rec" % (param[0]) |
---|
637 | |
---|
638 | status_svf = self.group_execution.findChild(QtWidgets.QCheckBox,"check_svf").checkState() |
---|
639 | |
---|
640 | if (status_svf == 2): |
---|
641 | param[0]="%s svfin" % (param[0]) |
---|
642 | |
---|
643 | status_svf_2 = self.group_execution.findChild(QtWidgets.QCheckBox,"check_svf_2").checkState() |
---|
644 | |
---|
645 | if (status_svf_2 == 2): |
---|
646 | param[0]="%s svfout" % (param[0]) |
---|
647 | |
---|
648 | param[0]="%s\"" % (param[0]) |
---|
649 | |
---|
650 | if ( fwt_str == "remove"): |
---|
651 | self.delete_commandline(id_str) |
---|
652 | return 1 |
---|
653 | |
---|
654 | else: |
---|
655 | self.button_start.setEnabled(True) |
---|
656 | self.action_save.setEnabled(True) |
---|
657 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(True) |
---|
658 | |
---|
659 | # Change in any other parameter |
---|
660 | else: |
---|
661 | if ( fwt_str != ""): |
---|
662 | param[0] = "\"%s\"" % (fwt_str) |
---|
663 | |
---|
664 | else: |
---|
665 | self.delete_commandline(id_str) |
---|
666 | return 1 |
---|
667 | |
---|
668 | # Join the new palmrunline |
---|
669 | splitline[1]= " -".join(param) |
---|
670 | |
---|
671 | |
---|
672 | s = " -%s " % (id_str) |
---|
673 | newpalmrunline = s.join(splitline) |
---|
674 | |
---|
675 | # Print the new palmrunline to mainwindow |
---|
676 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
677 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText(newpalmrunline) |
---|
678 | |
---|
679 | # change lineinput depending on sender |
---|
680 | ################################################################################### |
---|
681 | def change_lineinput(self): |
---|
682 | if ( self.sender() == self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration") ): |
---|
683 | tmptext = self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration").currentText() |
---|
684 | if not tmptext: |
---|
685 | self.change_commandline("c"," ") |
---|
686 | self.group_execution.findChild(QtWidgets.QPushButton,'button_palmbuild').setEnabled(False) |
---|
687 | else: |
---|
688 | self.change_commandline("c",tmptext) |
---|
689 | self.group_execution.findChild(QtWidgets.QPushButton,'button_palmbuild').setEnabled(True) |
---|
690 | |
---|
691 | elif ( self.sender() == self.group_execution.findChild(QtWidgets.QLineEdit,"line_q")): |
---|
692 | tmptext = self.group_execution.findChild(QtWidgets.QLineEdit,"line_q").text() |
---|
693 | self.change_commandline("q",tmptext) |
---|
694 | |
---|
695 | elif ( self.sender() == self.group_execution.findChild(QtWidgets.QLineEdit,"line_account")): |
---|
696 | tmptext = self.group_execution.findChild(QtWidgets.QLineEdit,"line_account").text() |
---|
697 | self.change_commandline("A",tmptext) |
---|
698 | |
---|
699 | elif ( self.sender() == self.group_execution.findChild(QtWidgets.QLineEdit,"line_wait")): |
---|
700 | tmptext = self.group_execution.findChild(QtWidgets.QLineEdit,"line_wait").text() |
---|
701 | self.change_commandline("W",tmptext) |
---|
702 | |
---|
703 | elif ( self.sender() == self.group_execution.findChild(QtWidgets.QLineEdit,"line_pe")): |
---|
704 | tmptext = self.group_execution.findChild(QtWidgets.QLineEdit,"line_pe").text() |
---|
705 | self.change_commandline("X",tmptext) |
---|
706 | |
---|
707 | elif ( self.sender() == self.group_execution.findChild(QtWidgets.QLineEdit,"line_tpn")): |
---|
708 | tmptext = self.group_execution.findChild(QtWidgets.QLineEdit,"line_tpn").text() |
---|
709 | self.change_commandline("T",tmptext) |
---|
710 | |
---|
711 | elif ( self.sender() == self.group_execution.findChild(QtWidgets.QLineEdit,"line_time")): |
---|
712 | tmptext = self.group_execution.findChild(QtWidgets.QLineEdit,"line_time").text() |
---|
713 | self.change_commandline("t",tmptext) |
---|
714 | |
---|
715 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_M")): |
---|
716 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_M").text() |
---|
717 | self.change_commandline("M",tmptext) |
---|
718 | |
---|
719 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_m")): |
---|
720 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_m").text() |
---|
721 | self.change_commandline("m",tmptext) |
---|
722 | |
---|
723 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_D")): |
---|
724 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_D").text() |
---|
725 | self.change_commandline("D",tmptext) |
---|
726 | |
---|
727 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_c")): |
---|
728 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_c").text() |
---|
729 | if ( tmptext == ".palmrungui.config"): |
---|
730 | tmptext = "" |
---|
731 | self.change_commandline("c",tmptext) |
---|
732 | |
---|
733 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_s")): |
---|
734 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_s").text() |
---|
735 | self.change_commandline("s",tmptext) |
---|
736 | |
---|
737 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_w")): |
---|
738 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_w").text() |
---|
739 | self.change_commandline("w",tmptext) |
---|
740 | |
---|
741 | elif ( self.sender() == self.group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_atmos") or |
---|
742 | self.sender() == self.group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_ocean")): |
---|
743 | t1 = self.group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_atmos").text() |
---|
744 | t2 = self.group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_ocean").text() |
---|
745 | tmptext = "%s %s" % (t1,t2) |
---|
746 | |
---|
747 | self.change_commandline("Y",tmptext) |
---|
748 | |
---|
749 | # try catch sowas in der art |
---|
750 | pe1 = 0 |
---|
751 | pe2 = 0 |
---|
752 | |
---|
753 | try: |
---|
754 | pe1 = int(t1) |
---|
755 | except ValueError: |
---|
756 | pass |
---|
757 | |
---|
758 | try: |
---|
759 | pe2 = int(t2) |
---|
760 | except ValueError: |
---|
761 | pass |
---|
762 | |
---|
763 | PE_total = pe1+pe2 |
---|
764 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_pe").setText(str(PE_total)) |
---|
765 | self.change_commandline("X",str(PE_total)) |
---|
766 | |
---|
767 | # deletes parameter from commandline |
---|
768 | ##################################################################################### |
---|
769 | def delete_commandline(self, id_str): |
---|
770 | # Read palmrunline |
---|
771 | commandline = self.groupBox.findChild(QtWidgets.QLineEdit,"commandline") |
---|
772 | palmrunline = str(commandline.text()) |
---|
773 | s = " -%s" % (id_str) |
---|
774 | splitline = list(filter(None,palmrunline.split(s))) |
---|
775 | |
---|
776 | if ( len(splitline) == 1): |
---|
777 | return 1 |
---|
778 | else: |
---|
779 | param = splitline[1].split("-") |
---|
780 | param[0] = "" |
---|
781 | splitline[1]= " -".join(param) |
---|
782 | newpalmrunline = "".join(splitline) |
---|
783 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
784 | |
---|
785 | # Print new palmrunline to screen |
---|
786 | commandline.setText(newpalmrunline) |
---|
787 | |
---|
788 | # controls flags |
---|
789 | ################################################################################### |
---|
790 | def check_flags(self): |
---|
791 | status = self.group_execution.findChild(QtWidgets.QCheckBox,"check_delete_tmp_files" ).checkState() |
---|
792 | if (status == 2): |
---|
793 | self.activate_flag("B") |
---|
794 | else: |
---|
795 | self.deactivate_flag("B") |
---|
796 | |
---|
797 | status = self.groupBox.findChild(QtWidgets.QCheckBox,"check_verbose" ).checkState() |
---|
798 | if (status == 2): |
---|
799 | self.activate_flag("v") |
---|
800 | else: |
---|
801 | self.deactivate_flag("v") |
---|
802 | |
---|
803 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_b" ).checkState() |
---|
804 | if (status == 2): |
---|
805 | self.activate_flag("b") |
---|
806 | else: |
---|
807 | self.deactivate_flag("b") |
---|
808 | |
---|
809 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_F" ).checkState() |
---|
810 | if (status == 2): |
---|
811 | self.activate_flag("F") |
---|
812 | else: |
---|
813 | self.deactivate_flag("F") |
---|
814 | |
---|
815 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_I" ).checkState() |
---|
816 | if (status == 2): |
---|
817 | self.activate_flag("I") |
---|
818 | else: |
---|
819 | self.deactivate_flag("I") |
---|
820 | |
---|
821 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_k" ).checkState() |
---|
822 | if (status == 2): |
---|
823 | self.activate_flag("k") |
---|
824 | else: |
---|
825 | self.deactivate_flag("k") |
---|
826 | |
---|
827 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_O" ).checkState() |
---|
828 | if (status == 2): |
---|
829 | self.activate_flag("O") |
---|
830 | else: |
---|
831 | self.deactivate_flag("O") |
---|
832 | |
---|
833 | status = self.group_execution.findChild(QtWidgets.QCheckBox,"check_prebuilt" ).checkState() |
---|
834 | if (status == 2): |
---|
835 | self.activate_flag("V") |
---|
836 | else: |
---|
837 | self.deactivate_flag("V") |
---|
838 | |
---|
839 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_x" ).checkState() |
---|
840 | if (status == 2): |
---|
841 | self.activate_flag("x") |
---|
842 | else: |
---|
843 | self.deactivate_flag("x") |
---|
844 | |
---|
845 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_Z" ).checkState() |
---|
846 | if (status == 2): |
---|
847 | self.activate_flag("Z") |
---|
848 | else: |
---|
849 | self.deactivate_flag("Z") |
---|
850 | |
---|
851 | # changes flag to parameter |
---|
852 | ################################################################################## |
---|
853 | def activate_flag(self, id_str): |
---|
854 | commandline = self.groupBox.findChild(QtWidgets.QLineEdit,"commandline") |
---|
855 | palmrunline = str(commandline.text()) |
---|
856 | s = " -%s" % (id_str) |
---|
857 | splitline = list(filter(None,palmrunline.split(s))) |
---|
858 | |
---|
859 | if ( len(splitline) == 1): |
---|
860 | splitline.append("") |
---|
861 | s = " -%s" % (id_str) |
---|
862 | newpalmrunline = s.join(splitline) |
---|
863 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
864 | commandline.setText(newpalmrunline) |
---|
865 | |
---|
866 | # deletes flag in commandline |
---|
867 | #################################################################################### |
---|
868 | def deactivate_flag(self, id_str): |
---|
869 | commandline = self.groupBox.findChild(QtWidgets.QLineEdit,"commandline") |
---|
870 | palmrunline = str(commandline.text()) |
---|
871 | s = " -%s" % (id_str) |
---|
872 | splitline = list(filter(None,palmrunline.split(s))) |
---|
873 | |
---|
874 | newpalmrunline = "".join(splitline) |
---|
875 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
876 | commandline.setText(newpalmrunline) |
---|
877 | |
---|
878 | # Clears window |
---|
879 | ################################################################################# |
---|
880 | def reset_window(self): |
---|
881 | self.setupUi(self) |
---|
882 | self.tabWidget.setCurrentIndex(0) |
---|
883 | self.palm_logo.setPixmap(QtGui.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png")) |
---|
884 | self.recent_jobs(50) |
---|
885 | self.load_jobs() |
---|
886 | |
---|
887 | |
---|
888 | # Safes current commandline and user parameters to default file |
---|
889 | ################################################################################ |
---|
890 | def save_default(self): |
---|
891 | string_to_file = self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").text() |
---|
892 | |
---|
893 | filename ="%s/.palmrungui.default" % (palm_dir) |
---|
894 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
895 | |
---|
896 | file = open(filename,"w") |
---|
897 | s = "%s %s" % (tmstamp, string_to_file) |
---|
898 | file.write(s) |
---|
899 | file.close() |
---|
900 | |
---|
901 | |
---|
902 | # Executes command which starts watchdog (start palm_wd) |
---|
903 | ######################################################## |
---|
904 | def start_watchdog(self): |
---|
905 | subprocess.Popen(["nohup","palm_wd",">>","/dev/null", "2>&1","&"]) |
---|
906 | |
---|
907 | # Opens "help" dialog |
---|
908 | ################################# |
---|
909 | def help(self): |
---|
910 | dialog = HelpDialog() |
---|
911 | dialog.exec_() |
---|
912 | |
---|
913 | # Opens "about" dialog |
---|
914 | ################################## |
---|
915 | def about_gui(self): |
---|
916 | dialog = AboutDialog() |
---|
917 | dialog.exec_() |
---|
918 | |
---|
919 | # commandline to buttons etc |
---|
920 | ############################## |
---|
921 | def setup_gui(self, palmrun_str): |
---|
922 | |
---|
923 | #self.palm_logo.setPixmap(QtWidgets.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png")) |
---|
924 | |
---|
925 | # Some initial settings |
---|
926 | coupled_run = False |
---|
927 | ocean_run = False |
---|
928 | nojob = False |
---|
929 | |
---|
930 | #Split parameters in palmrunline |
---|
931 | splitline = palmrun_str.split(" -") |
---|
932 | |
---|
933 | if ( splitline[0] != "palmrun"): |
---|
934 | return 1 |
---|
935 | |
---|
936 | else: |
---|
937 | self.group_execution.setEnabled(True) |
---|
938 | |
---|
939 | # Loop for all parameters in palmrunline |
---|
940 | i = len(splitline)-1 |
---|
941 | while i >= 1: |
---|
942 | |
---|
943 | # Determine parameter |
---|
944 | splitparameter = splitline[i].split(" ") |
---|
945 | |
---|
946 | parameter = splitparameter[0] |
---|
947 | splitparameter.pop(0) |
---|
948 | options = " ".join(splitparameter) |
---|
949 | options = options.replace("\"","") |
---|
950 | |
---|
951 | # Check for suitable switch |
---|
952 | if ( parameter == "r"): |
---|
953 | |
---|
954 | if ( options != ""): |
---|
955 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_jobname").setText(options) |
---|
956 | nojob = False |
---|
957 | |
---|
958 | else: |
---|
959 | nojob = True |
---|
960 | |
---|
961 | elif ( parameter == "c"): |
---|
962 | tmpindex = self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration").findText(options.strip(),QtCore.Qt.MatchExactly) |
---|
963 | if tmpindex != -1: |
---|
964 | self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration").setCurrentIndex(tmpindex) |
---|
965 | else: |
---|
966 | self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration").setCurrentIndex(0) |
---|
967 | elif ( parameter == "q"): |
---|
968 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_q").setText(options) |
---|
969 | |
---|
970 | elif ( parameter == "A"): |
---|
971 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_account").setText(options) |
---|
972 | |
---|
973 | elif ( parameter == "W"): |
---|
974 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_wait").setText(options) |
---|
975 | |
---|
976 | elif ( parameter == "X"): |
---|
977 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_pe").setText(options) |
---|
978 | |
---|
979 | elif ( parameter == "T"): |
---|
980 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_tpn").setText(options) |
---|
981 | |
---|
982 | elif ( parameter == "t"): |
---|
983 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_time").setText(options) |
---|
984 | |
---|
985 | elif ( parameter == "B"): |
---|
986 | self.group_execution.findChild(QtWidgets.QCheckBox,"check_delete_tmp_files").setChecked(True) |
---|
987 | |
---|
988 | elif ( parameter == "v"): |
---|
989 | self.groupBox.findChild(QtWidgets.QCheckBox,"check_verbose").setChecked(True) |
---|
990 | |
---|
991 | elif ( parameter == "b"): |
---|
992 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_b").setChecked(True) |
---|
993 | |
---|
994 | elif ( parameter == "F"): |
---|
995 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_F").setChecked(True) |
---|
996 | |
---|
997 | elif ( parameter == "I"): |
---|
998 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_I").setChecked(True) |
---|
999 | |
---|
1000 | elif ( parameter == "k"): |
---|
1001 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_k").setChecked(True) |
---|
1002 | |
---|
1003 | elif ( parameter == "O"): |
---|
1004 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_O").setChecked(True) |
---|
1005 | |
---|
1006 | elif ( parameter == "V"): |
---|
1007 | self.group_execution.findChild(QtWidgets.QCheckBox,"check_prebuilt").setChecked(True) |
---|
1008 | |
---|
1009 | elif ( parameter == "x"): |
---|
1010 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_x").setChecked(True) |
---|
1011 | |
---|
1012 | elif ( parameter == "Z"): |
---|
1013 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_Z").setChecked(True) |
---|
1014 | |
---|
1015 | elif ( parameter == "m"): |
---|
1016 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_m").setText(options) |
---|
1017 | |
---|
1018 | elif ( parameter == "M"): |
---|
1019 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_M").setText(options) |
---|
1020 | |
---|
1021 | elif ( parameter == "D"): |
---|
1022 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_D").setText(options) |
---|
1023 | |
---|
1024 | elif ( parameter == "c"): |
---|
1025 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_c").setText(options) |
---|
1026 | |
---|
1027 | elif ( parameter == "s"): |
---|
1028 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_s").setText(options) |
---|
1029 | |
---|
1030 | elif ( parameter == "w"): |
---|
1031 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_w").setText(options) |
---|
1032 | |
---|
1033 | |
---|
1034 | # Determine settings for coupled restart runs |
---|
1035 | elif ( parameter == "Y"): |
---|
1036 | optionssplit = options.split(" ") |
---|
1037 | |
---|
1038 | group_coupled = self.group_execution.findChild(QtWidgets.QGroupBox,"group_coupled") |
---|
1039 | group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_atmos").setEnabled(True) |
---|
1040 | group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_ocean").setEnabled(True) |
---|
1041 | group_coupled.findChild(QtWidgets.QLabel,"label_coupled1").setEnabled(True) |
---|
1042 | group_coupled.findChild(QtWidgets.QLabel,"label_coupled2").setEnabled(True) |
---|
1043 | group_coupled.findChild(QtWidgets.QLabel,"label_coupled3").setEnabled(True) |
---|
1044 | group_coupled.findChild(QtWidgets.QLabel,"label_coupling").setEnabled(True) |
---|
1045 | |
---|
1046 | if (optionssplit.count() == 2): |
---|
1047 | group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_atmos").setEnabled(optionssplit[0]) |
---|
1048 | group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_ocean").setEnabled(optionssplit[1]) |
---|
1049 | |
---|
1050 | else: |
---|
1051 | group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_atmos").setText("") |
---|
1052 | group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_ocean").setText("") |
---|
1053 | |
---|
1054 | |
---|
1055 | coupled_run = True |
---|
1056 | |
---|
1057 | elif ( parameter == "y"): |
---|
1058 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setCurrentIndex(3) |
---|
1059 | |
---|
1060 | |
---|
1061 | # Determine settings for the run control list |
---|
1062 | elif ( parameter == "a"): |
---|
1063 | |
---|
1064 | optionssplit = options.split(" ") |
---|
1065 | |
---|
1066 | options_2 = None |
---|
1067 | options_all = None |
---|
1068 | |
---|
1069 | j = 0 |
---|
1070 | while j < len(optionssplit): |
---|
1071 | |
---|
1072 | options_all = optionssplit[j] |
---|
1073 | options_2 = optionssplit[j][:2] |
---|
1074 | |
---|
1075 | if (options_2 == "d3"): |
---|
1076 | if (options_all[:3][-1] == "#"): |
---|
1077 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setCurrentIndex(0) |
---|
1078 | elif (options_all[:3][-1] == "r"): |
---|
1079 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setCurrentIndex(1) |
---|
1080 | |
---|
1081 | elif (options_all[:3][-1] == "o"): |
---|
1082 | ocean_run = True |
---|
1083 | |
---|
1084 | if (options_all == "restart"): |
---|
1085 | self.group_execution.findChild(QtWidgets.QCheckBox,"check_restarts").setChecked(True) |
---|
1086 | |
---|
1087 | if (options_all == "rec"): |
---|
1088 | self.group_execution.findChild(QtWidgets.QCheckBox,"check_cycfill").setChecked(True) |
---|
1089 | |
---|
1090 | if (options_all == "svfin"): |
---|
1091 | self.group_execution.findChild(QtWidgets.QCheckBox,"check_svf").setChecked(True) |
---|
1092 | |
---|
1093 | if (options_all == "svfout"): |
---|
1094 | self.group_execution.findChild(QtWidgets.QCheckBox,"check_svf_2").setChecked(True) |
---|
1095 | |
---|
1096 | j = j+1 |
---|
1097 | i = i-1 |
---|
1098 | # Change drop box state in case of ocean precursor or coupled restart runs |
---|
1099 | if ( ocean_run == True ): |
---|
1100 | if ( coupled_run == True ): |
---|
1101 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setCurrentIndex(4) |
---|
1102 | |
---|
1103 | else: |
---|
1104 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setCurrentIndex(3) |
---|
1105 | |
---|
1106 | # Join palmrunline and post it to mainwindow |
---|
1107 | palmrunline = " -".join(splitline) |
---|
1108 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText(palmrunline) |
---|
1109 | |
---|
1110 | # Disable mainwindow if no job was found, otherwise enable |
---|
1111 | if ( nojob == True ): |
---|
1112 | self.group_execution.setEnabled(False) |
---|
1113 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setEnabled(False) |
---|
1114 | self.menuBar.findChild(QtWidgets.QMenu,"menuStart").actions()[3].setEnabled(False) |
---|
1115 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setEnabled(False) |
---|
1116 | self.group_advanced.setEnabled(False) |
---|
1117 | self.check_advanced.setEnabled(False) |
---|
1118 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(False) |
---|
1119 | |
---|
1120 | else: |
---|
1121 | self.group_execution.setEnabled(True) |
---|
1122 | self.groupBox.findChild(QtWidgets.QPushButton,"button_start").setEnabled(True) |
---|
1123 | self.menuBar.findChild(QtWidgets.QMenu,"menuStart").actions()[3].setEnabled(True) |
---|
1124 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setEnabled(True) |
---|
1125 | self.group_advanced.setEnabled(True) |
---|
1126 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(True) |
---|
1127 | |
---|
1128 | |
---|
1129 | self.tabWidget.setCurrentIndex(0) |
---|
1130 | |
---|
1131 | |
---|
1132 | ## Open from history |
---|
1133 | ################################### |
---|
1134 | def open_from_file(self): |
---|
1135 | |
---|
1136 | # Show History |
---|
1137 | opt = OpenHistoryBox() |
---|
1138 | opt.exec_() |
---|
1139 | |
---|
1140 | if ( history_entry != "" ): |
---|
1141 | palmrunline = str(history_entry) |
---|
1142 | palmrunline = palmrunline[17:] |
---|
1143 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
1144 | palmrunline = list(filter(None,palmrunline.split("(")))[0] |
---|
1145 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText(palmrunline) |
---|
1146 | |
---|
1147 | # Set selected item to jobname in "available jobs" list |
---|
1148 | jobname = str(history_entry[17:]) |
---|
1149 | jobname = list(filter(None,jobname.split(" -r")))[1] |
---|
1150 | jobname = jobname.strip() |
---|
1151 | jobname = list(filter(None,jobname.split(" ")))[0] |
---|
1152 | jobname = jobname.replace("\"","") |
---|
1153 | item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive) |
---|
1154 | |
---|
1155 | if ( item2int != [] ): |
---|
1156 | self.list_jobs.setCurrentItem(item2int[0]) |
---|
1157 | self.update_input() |
---|
1158 | |
---|
1159 | # Add tooltip tag |
---|
1160 | tag = str(history_entry).split('\n')[0] |
---|
1161 | tag = list(filter(None,tag.split("(")))[1] |
---|
1162 | tag = tag.replace(")","") |
---|
1163 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setText(tag) |
---|
1164 | |
---|
1165 | # Process palmrungui to set up gui controls |
---|
1166 | self.setup_gui(palmrunline) |
---|
1167 | |
---|
1168 | |
---|
1169 | def update_all(self): |
---|
1170 | |
---|
1171 | self.setEnabled(False) |
---|
1172 | self.list_input.clear() |
---|
1173 | self.list_user.clear() |
---|
1174 | self.list_monitoring.clear() |
---|
1175 | self.list_output.clear() |
---|
1176 | self.load_jobs() |
---|
1177 | self.setEnabled(True) |
---|
1178 | self.update_input() |
---|
1179 | |
---|
1180 | |
---|
1181 | # Load jobs into list |
---|
1182 | def load_jobs(self): |
---|
1183 | |
---|
1184 | selected_job = self.list_jobs.currentItem() |
---|
1185 | |
---|
1186 | if ( selected_job is not None ): |
---|
1187 | jobname = selected_job.text() |
---|
1188 | else: |
---|
1189 | jobname = "" |
---|
1190 | |
---|
1191 | self.list_jobs.clear() |
---|
1192 | self.line_path.setText(job_dir + "/") |
---|
1193 | |
---|
1194 | list_of_files = os.listdir(job_dir) |
---|
1195 | |
---|
1196 | |
---|
1197 | for i in range(0,len(list_of_files)): |
---|
1198 | tmp_file = job_dir + "/" + list_of_files[i] |
---|
1199 | |
---|
1200 | if ( os.path.isdir(tmp_file) ): |
---|
1201 | self.list_jobs.addItem(str(list_of_files[i])) |
---|
1202 | |
---|
1203 | |
---|
1204 | |
---|
1205 | item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive) |
---|
1206 | |
---|
1207 | if ( item2int != [] ): |
---|
1208 | self.list_jobs.setCurrentItem(item2int[0]) |
---|
1209 | |
---|
1210 | |
---|
1211 | # Update input and user code lists |
---|
1212 | def update_input(self): |
---|
1213 | |
---|
1214 | self.labeltimer.stop() |
---|
1215 | |
---|
1216 | |
---|
1217 | self.list_input.clear() |
---|
1218 | self.list_user.clear() |
---|
1219 | self.list_monitoring.clear() |
---|
1220 | self.list_output.clear() |
---|
1221 | |
---|
1222 | jobitem = self.list_jobs.currentItem() |
---|
1223 | |
---|
1224 | if ( jobitem != None ): |
---|
1225 | |
---|
1226 | job_to_show = job_dir + "/" + jobitem.text() + "/INPUT" |
---|
1227 | |
---|
1228 | if ( os.path.isdir(job_to_show) ): |
---|
1229 | |
---|
1230 | list_of_files = os.listdir(job_to_show) |
---|
1231 | |
---|
1232 | for i in range(0,len(list_of_files)): |
---|
1233 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
1234 | |
---|
1235 | if ( os.path.isfile(tmp_file) ): |
---|
1236 | self.list_input.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")") |
---|
1237 | |
---|
1238 | job_to_show = job_dir + "/" + jobitem.text() + "/USER_CODE" |
---|
1239 | |
---|
1240 | if ( os.path.isdir(job_to_show) ): |
---|
1241 | |
---|
1242 | list_of_files = os.listdir(job_to_show) |
---|
1243 | |
---|
1244 | for i in range(0,len(list_of_files)): |
---|
1245 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
1246 | |
---|
1247 | if ( os.path.isfile(tmp_file) ): |
---|
1248 | self.list_user.addItem(str(list_of_files[i])) |
---|
1249 | |
---|
1250 | job_to_show = job_dir + "/" + jobitem.text() + "/MONITORING" |
---|
1251 | |
---|
1252 | if ( os.path.isdir(job_to_show) ): |
---|
1253 | |
---|
1254 | list_of_files = os.listdir(job_to_show) |
---|
1255 | |
---|
1256 | for i in range(0,len(list_of_files)): |
---|
1257 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
1258 | |
---|
1259 | if ( os.path.isfile(tmp_file) ): |
---|
1260 | self.list_monitoring.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")") |
---|
1261 | |
---|
1262 | job_to_show = job_dir + "/" + jobitem.text() + "/OUTPUT" |
---|
1263 | |
---|
1264 | if ( os.path.isdir(job_to_show) ): |
---|
1265 | |
---|
1266 | list_of_files = os.listdir(job_to_show) |
---|
1267 | |
---|
1268 | for i in range(0,len(list_of_files)): |
---|
1269 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
1270 | |
---|
1271 | if ( os.path.isfile(tmp_file) ): |
---|
1272 | self.list_output.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")") |
---|
1273 | |
---|
1274 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_jobname").setText(jobitem.text()) |
---|
1275 | self.group_history.findChild(QtWidgets.QListWidget,"list_jobname").clearSelection() |
---|
1276 | |
---|
1277 | self.timetimer.start() |
---|
1278 | self.timer.start(update_frequency) |
---|
1279 | self.labeltimer.start(update_frequency/10) |
---|
1280 | self.push_update.setText("Update (" + str(int(update_frequency/1000/60)) + " min)") |
---|
1281 | QtWidgets.QApplication.processEvents() |
---|
1282 | |
---|
1283 | # Change palmrunline accordingly |
---|
1284 | self.change_commandline("r","") |
---|
1285 | self.change_commandline("a","") |
---|
1286 | |
---|
1287 | # Create a new (empty) job |
---|
1288 | def create_new_job(self): |
---|
1289 | |
---|
1290 | self.setEnabled(False) |
---|
1291 | |
---|
1292 | text, ret = QtWidgets.QInputDialog.getText(self, "Create new job", "Enter new job name:", QtWidgets.QLineEdit.Normal, text = '') |
---|
1293 | |
---|
1294 | if ( ret ): |
---|
1295 | new_job_name = str(text) |
---|
1296 | else: |
---|
1297 | self.setEnabled(True) |
---|
1298 | return |
---|
1299 | |
---|
1300 | new_input_dir = job_dir + "/" + new_job_name + "/INPUT" |
---|
1301 | |
---|
1302 | # check if a job exists with the new job name. If not, the new job is created and an empty _p3d file is created. |
---|
1303 | if ( os.path.isdir(new_input_dir) ): |
---|
1304 | notify = QtWidgets.QMessageBox.warning(self,'Create new job directory',"Error. Could not create job directory. A job with the new name already exists.") |
---|
1305 | self.setEnabled(True) |
---|
1306 | return |
---|
1307 | else: |
---|
1308 | os.makedirs(new_input_dir) |
---|
1309 | os.mknod(new_input_dir + '/' + new_job_name + '_p3d') |
---|
1310 | |
---|
1311 | # write default namelists into _p3d file |
---|
1312 | filename = open(new_input_dir + '/' + new_job_name + '_p3d', "w") |
---|
1313 | filename.write('&initialization_parameters\n nx = 39,\n ny = 39,\n nz = 40,\n dx = 50.0,\n dy = 50.0,\n dz = 50.0,\n/\n\n') |
---|
1314 | filename.write('&runtime_parameters\n end_time = 3600.0,\n/\n') |
---|
1315 | filename.close() |
---|
1316 | |
---|
1317 | |
---|
1318 | # create empty USER_CODE folder for convenience |
---|
1319 | new_user_dir = job_dir + "/" + new_job_name + "/USER_CODE" |
---|
1320 | os.makedirs(new_user_dir) |
---|
1321 | |
---|
1322 | |
---|
1323 | self.load_jobs() |
---|
1324 | self.list_input.clear() |
---|
1325 | self.list_user.clear() |
---|
1326 | self.list_monitoring.clear() |
---|
1327 | self.list_output.clear() |
---|
1328 | self.setEnabled(True) |
---|
1329 | |
---|
1330 | |
---|
1331 | # Make a copy of a job |
---|
1332 | def copy_job(self): |
---|
1333 | |
---|
1334 | self.setEnabled(False) |
---|
1335 | old_job_name = self.list_jobs.currentItem().text() |
---|
1336 | |
---|
1337 | text, ret = QtWidgets.QInputDialog.getText(self, "Copy job", "Enter new job name:", QtWidgets.QLineEdit.Normal, text = old_job_name) |
---|
1338 | if ( ret ): |
---|
1339 | new_job_name = str(text) |
---|
1340 | else: |
---|
1341 | self.setEnabled(True) |
---|
1342 | return |
---|
1343 | |
---|
1344 | new_input_dir = job_dir + "/" + new_job_name + "/INPUT" |
---|
1345 | |
---|
1346 | # check if a job exists with the new job name |
---|
1347 | if ( os.path.isdir(new_input_dir) ): |
---|
1348 | notify = QtWidgets.QMessageBox.warning(self,'Create new job directory',"Error. Could not create job directory. A job with the new name already exists.") |
---|
1349 | self.setEnabled(True) |
---|
1350 | return |
---|
1351 | else: |
---|
1352 | os.makedirs(new_input_dir) |
---|
1353 | |
---|
1354 | # copy and rename input files (if present) |
---|
1355 | job_to_copy = job_dir + "/" + old_job_name + "/INPUT" |
---|
1356 | |
---|
1357 | if ( os.path.isdir(job_to_copy) ): |
---|
1358 | |
---|
1359 | list_of_files = os.listdir(job_to_copy) |
---|
1360 | |
---|
1361 | for i in range(0,len(list_of_files)): |
---|
1362 | |
---|
1363 | tmp_file = job_to_copy + "/" + list_of_files[i] |
---|
1364 | new_file = new_input_dir + "/" + list_of_files[i].replace(old_job_name, new_job_name) |
---|
1365 | shutil.copy(tmp_file, new_file) |
---|
1366 | |
---|
1367 | |
---|
1368 | |
---|
1369 | |
---|
1370 | new_user_dir = job_dir + "/" + new_job_name + "/USER_CODE" |
---|
1371 | |
---|
1372 | # check if user code exists in the new job directory |
---|
1373 | if ( os.path.isdir(new_user_dir) ): |
---|
1374 | notify = QtWidgets.QMessageBox.warning(self,'Create new user code directory',"Error. Could not create user code directory. A user code directiory with the new name already exists.") |
---|
1375 | self.setEnabled(True) |
---|
1376 | return |
---|
1377 | else: |
---|
1378 | os.makedirs(new_user_dir) |
---|
1379 | |
---|
1380 | |
---|
1381 | # copy user code files (if present) |
---|
1382 | user_to_copy = job_dir + "/" + old_job_name + "/USER_CODE" |
---|
1383 | |
---|
1384 | if ( os.path.isdir(user_to_copy) ): |
---|
1385 | |
---|
1386 | list_of_files = os.listdir(user_to_copy) |
---|
1387 | |
---|
1388 | for i in range(0,len(list_of_files)): |
---|
1389 | |
---|
1390 | tmp_file = user_to_copy + "/" + list_of_files[i] |
---|
1391 | new_file = new_user_dir + "/" + list_of_files[i] |
---|
1392 | shutil.copy(tmp_file, new_file) |
---|
1393 | |
---|
1394 | self.load_jobs() |
---|
1395 | self.list_input.clear() |
---|
1396 | self.list_user.clear() |
---|
1397 | self.list_monitoring.clear() |
---|
1398 | self.list_output.clear() |
---|
1399 | self.setEnabled(True) |
---|
1400 | |
---|
1401 | |
---|
1402 | # Create a whole set of jobs |
---|
1403 | def create_set(self): |
---|
1404 | |
---|
1405 | global set_list |
---|
1406 | # disable mainwindow |
---|
1407 | self.setEnabled(False) |
---|
1408 | |
---|
1409 | # show Options Dialog |
---|
1410 | opt = CreateSetBox() |
---|
1411 | opt.exec_() |
---|
1412 | |
---|
1413 | old_job_name = self.list_jobs.currentItem().text() |
---|
1414 | |
---|
1415 | for j in range(0,len(set_list)): |
---|
1416 | |
---|
1417 | if ( set_list[j] != "" ): |
---|
1418 | new_job_name = str(set_list[j]) |
---|
1419 | new_input_dir = job_dir + "/" + str(set_list[j]) + "/INPUT" |
---|
1420 | else: |
---|
1421 | continue |
---|
1422 | |
---|
1423 | # check if a job exists with the new job name |
---|
1424 | if ( os.path.isdir(new_input_dir) ): |
---|
1425 | notify = QtWidgets.QMessageBox.warning(self,'Create new job directory',"Error. Could not create job directory. A job with the new name already exists.") |
---|
1426 | self.setEnabled(True) |
---|
1427 | return |
---|
1428 | else: |
---|
1429 | os.makedirs(new_input_dir) |
---|
1430 | |
---|
1431 | # copy and rename input files (if present) |
---|
1432 | job_to_copy = job_dir + "/" + old_job_name + "/INPUT" |
---|
1433 | |
---|
1434 | if ( os.path.isdir(job_to_copy) ): |
---|
1435 | |
---|
1436 | list_of_files = os.listdir(job_to_copy) |
---|
1437 | |
---|
1438 | for i in range(0,len(list_of_files)): |
---|
1439 | |
---|
1440 | tmp_file = job_to_copy + "/" + list_of_files[i] |
---|
1441 | new_file = new_input_dir + "/" + list_of_files[i].replace(old_job_name, new_job_name) |
---|
1442 | shutil.copy(tmp_file, new_file) |
---|
1443 | |
---|
1444 | |
---|
1445 | new_user_dir = job_dir + "/" + new_job_name + "/USER_CODE" |
---|
1446 | |
---|
1447 | # check if user code exists in the new job directory |
---|
1448 | if ( os.path.isdir(new_user_dir) ): |
---|
1449 | notify = QtWidgets.QMessageBox.warning(self,'Create new user code directory',"Error. Could not create user code directory. A user code directiory with the new name already exists.") |
---|
1450 | self.setEnabled(True) |
---|
1451 | return |
---|
1452 | else: |
---|
1453 | os.makedirs(new_user_dir) |
---|
1454 | |
---|
1455 | |
---|
1456 | # copy user code files (if present) |
---|
1457 | user_to_copy = job_dir + "/" + old_job_name + "/USER_CODE" |
---|
1458 | |
---|
1459 | if ( os.path.isdir(user_to_copy) ): |
---|
1460 | |
---|
1461 | list_of_files = os.listdir(user_to_copy) |
---|
1462 | |
---|
1463 | for i in range(0,len(list_of_files)): |
---|
1464 | |
---|
1465 | tmp_file = user_to_copy + "/" + list_of_files[i] |
---|
1466 | new_file = new_user_dir + "/" + list_of_files[i] |
---|
1467 | shutil.copy(tmp_file, new_file) |
---|
1468 | |
---|
1469 | self.load_jobs() |
---|
1470 | self.list_input.clear() |
---|
1471 | self.list_user.clear() |
---|
1472 | self.list_monitoring.clear() |
---|
1473 | self.list_output.clear() |
---|
1474 | |
---|
1475 | self.setEnabled(True) |
---|
1476 | set_list = [] |
---|
1477 | |
---|
1478 | |
---|
1479 | # Add a custom context menu for the job selection list |
---|
1480 | def openmenujob(self, position): |
---|
1481 | |
---|
1482 | menu = QtWidgets.QMenu() |
---|
1483 | |
---|
1484 | |
---|
1485 | newAction = QtWidgets.QAction('Create new job', self) |
---|
1486 | newAction.triggered.connect(self.create_new_job) |
---|
1487 | menu.addAction(newAction) |
---|
1488 | selection = self.list_jobs.selectedItems() |
---|
1489 | |
---|
1490 | if ( len(selection) != 0 ): |
---|
1491 | |
---|
1492 | |
---|
1493 | copyAction = QtWidgets.QAction('Copy job', self) |
---|
1494 | copyAction.triggered.connect(self.copy_job) |
---|
1495 | createAction = QtWidgets.QAction('Create set from job', self) |
---|
1496 | createAction.triggered.connect(self.create_set) |
---|
1497 | delAction = QtWidgets.QAction('Delete job', self) |
---|
1498 | delAction.triggered.connect(self.DeleteJob) |
---|
1499 | |
---|
1500 | menu.addAction(copyAction) |
---|
1501 | menu.addAction(createAction) |
---|
1502 | menu.addAction(delAction) |
---|
1503 | |
---|
1504 | action = menu.exec_(self.list_jobs.mapToGlobal(position)) |
---|
1505 | |
---|
1506 | # Add a custom context menu |
---|
1507 | def openmenuinput(self, position): |
---|
1508 | |
---|
1509 | menu = QtWidgets.QMenu() |
---|
1510 | |
---|
1511 | selection = self.list_input.selectedItems() |
---|
1512 | |
---|
1513 | if ( len(selection) != 0 ): |
---|
1514 | |
---|
1515 | |
---|
1516 | openAction = QtWidgets.QAction('Open file(s)', self) |
---|
1517 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
1518 | openAction.triggered.connect(self.OpenFilesInput) |
---|
1519 | |
---|
1520 | |
---|
1521 | delAction = QtWidgets.QAction('Delete selected file(s)', self) |
---|
1522 | delAction.triggered.connect(self.DeleteFilesInput) |
---|
1523 | |
---|
1524 | menu.addAction(openAction) |
---|
1525 | menu.addAction(delAction) |
---|
1526 | |
---|
1527 | delallAction = QtWidgets.QAction('Delete all files', self) |
---|
1528 | delallAction.triggered.connect(self.DeleteAllFilesInput) |
---|
1529 | menu.addAction(delallAction) |
---|
1530 | |
---|
1531 | action = menu.exec_(self.list_input.mapToGlobal(position)) |
---|
1532 | |
---|
1533 | # Add a custom context menu |
---|
1534 | def openmenuuser(self, position): |
---|
1535 | |
---|
1536 | menu = QtWidgets.QMenu() |
---|
1537 | |
---|
1538 | selection = self.list_user.selectedItems() |
---|
1539 | |
---|
1540 | if ( len(selection) != 0 ): |
---|
1541 | |
---|
1542 | openAction = QtWidgets.QAction('Open file(s)', self) |
---|
1543 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
1544 | openAction.triggered.connect(self.OpenFilesUser) |
---|
1545 | |
---|
1546 | |
---|
1547 | delAction = QtWidgets.QAction('Delete file(s)', self) |
---|
1548 | delAction.triggered.connect(self.DeleteFilesUser) |
---|
1549 | |
---|
1550 | menu.addAction(openAction) |
---|
1551 | menu.addAction(delAction) |
---|
1552 | |
---|
1553 | delallAction = QtWidgets.QAction('Delete all files', self) |
---|
1554 | delallAction.triggered.connect(self.DeleteAllFilesUser) |
---|
1555 | menu.addAction(delallAction) |
---|
1556 | |
---|
1557 | action = menu.exec_(self.list_user.mapToGlobal(position)) |
---|
1558 | |
---|
1559 | # Add a custom context menu |
---|
1560 | def openmenuoutput(self, position): |
---|
1561 | |
---|
1562 | menu = QtWidgets.QMenu() |
---|
1563 | |
---|
1564 | selection = self.list_output.selectedItems() |
---|
1565 | |
---|
1566 | if ( len(selection) != 0 ): |
---|
1567 | |
---|
1568 | openAction = QtWidgets.QAction('Open file(s)', self) |
---|
1569 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
1570 | openAction.triggered.connect(self.OpenFilesOutput) |
---|
1571 | |
---|
1572 | delAction = QtWidgets.QAction('Delete file(s)', self) |
---|
1573 | delAction.triggered.connect(self.DeleteFilesOutput) |
---|
1574 | |
---|
1575 | |
---|
1576 | |
---|
1577 | menu.addAction(openAction) |
---|
1578 | menu.addAction(delAction) |
---|
1579 | |
---|
1580 | delallAction = QtWidgets.QAction('Delete all files', self) |
---|
1581 | delallAction.triggered.connect(self.DeleteAllFilesOutput) |
---|
1582 | menu.addAction(delallAction) |
---|
1583 | |
---|
1584 | action = menu.exec_(self.list_output.mapToGlobal(position)) |
---|
1585 | |
---|
1586 | # Add a custom context menu |
---|
1587 | def openmenumonitoring(self, position): |
---|
1588 | |
---|
1589 | menu = QtWidgets.QMenu() |
---|
1590 | |
---|
1591 | selection = self.list_monitoring.selectedItems() |
---|
1592 | |
---|
1593 | if ( len(selection) != 0 ): |
---|
1594 | |
---|
1595 | openAction = QtWidgets.QAction('Open file(s)', self) |
---|
1596 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
1597 | openAction.triggered.connect(self.OpenFilesMonitoring) |
---|
1598 | |
---|
1599 | delAction = QtWidgets.QAction('Delete file(s)', self) |
---|
1600 | delAction.triggered.connect(self.DeleteFilesMonitoring) |
---|
1601 | |
---|
1602 | |
---|
1603 | |
---|
1604 | menu.addAction(openAction) |
---|
1605 | menu.addAction(delAction) |
---|
1606 | |
---|
1607 | delallAction = QtWidgets.QAction('Delete all files', self) |
---|
1608 | delallAction.triggered.connect(self.DeleteAllFilesMonitoring) |
---|
1609 | menu.addAction(delallAction) |
---|
1610 | |
---|
1611 | action = menu.exec_(self.list_monitoring.mapToGlobal(position)) |
---|
1612 | |
---|
1613 | def OpenConfig(self): |
---|
1614 | |
---|
1615 | config = str(self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration").currentText()) |
---|
1616 | if ( config != "" ): |
---|
1617 | filename = ".palm.config." + config |
---|
1618 | open_file = "xdg-open " + filename |
---|
1619 | os.system(str(open_file)) |
---|
1620 | |
---|
1621 | def OpenFilesInput(self): |
---|
1622 | |
---|
1623 | sel_job = self.list_jobs.currentItem().text() |
---|
1624 | sel_files = self.list_input.selectedItems() |
---|
1625 | |
---|
1626 | input_dir = job_dir + "/" + sel_job + "/INPUT/" |
---|
1627 | |
---|
1628 | open_files = "" |
---|
1629 | for i in range(0,len(sel_files)): |
---|
1630 | open_files = open_files + "xdg-open " + input_dir + sel_files[i].text().split("(")[0] + "; " |
---|
1631 | |
---|
1632 | os.system(str(open_files)) |
---|
1633 | |
---|
1634 | def OpenFilesUser(self): |
---|
1635 | |
---|
1636 | sel_job = self.list_jobs.currentItem().text() |
---|
1637 | sel_files = self.list_user.selectedItems() |
---|
1638 | |
---|
1639 | input_dir = job_dir + "/" + sel_job + "/USER_CODE/" |
---|
1640 | |
---|
1641 | open_files = "" |
---|
1642 | for i in range(0,len(sel_files)): |
---|
1643 | open_files = open_files + "xdg-open " + input_dir + sel_files[i].text() + "; " |
---|
1644 | |
---|
1645 | os.system(str(open_files)) |
---|
1646 | selection = self.list_jobs.selectedItems() |
---|
1647 | |
---|
1648 | def OpenFilesMonitoring(self): |
---|
1649 | |
---|
1650 | sel_job = self.list_jobs.currentItem().text() |
---|
1651 | sel_files = self.list_monitoring.selectedItems() |
---|
1652 | |
---|
1653 | input_dir = job_dir + "/" + sel_job + "/MONITORING/" |
---|
1654 | |
---|
1655 | open_files = "" |
---|
1656 | for i in range(0,len(sel_files)): |
---|
1657 | open_files = open_files + "xdg-open " + input_dir + sel_files[i].text().split("(")[0] + "; " |
---|
1658 | |
---|
1659 | os.system(str(open_files)) |
---|
1660 | selection = self.list_jobs.selectedItems() |
---|
1661 | |
---|
1662 | def OpenFilesOutput(self): |
---|
1663 | |
---|
1664 | sel_job = self.list_jobs.currentItem().text() |
---|
1665 | sel_files = self.list_output.selectedItems() |
---|
1666 | |
---|
1667 | input_dir = job_dir + "/" + sel_job + "/OUTPUT/" |
---|
1668 | |
---|
1669 | open_files = "" |
---|
1670 | for i in range(0,len(sel_files)): |
---|
1671 | open_files = open_files + "xdg-open " + input_dir + sel_files[i].text().split("(")[0] + "; " |
---|
1672 | |
---|
1673 | os.system(str(open_files)) |
---|
1674 | selection = self.list_jobs.selectedItems() |
---|
1675 | |
---|
1676 | def DeleteFilesInput(self): |
---|
1677 | |
---|
1678 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
1679 | |
---|
1680 | if status == QtWidgets.QMessageBox.Yes: |
---|
1681 | |
---|
1682 | sel_job = self.list_jobs.currentItem().text() |
---|
1683 | sel_files = self.list_input.selectedItems() |
---|
1684 | |
---|
1685 | input_dir = job_dir + "/" + sel_job + "/INPUT/" |
---|
1686 | |
---|
1687 | for i in range(0,len(sel_files)): |
---|
1688 | filename = input_dir + sel_files[i].text().split("(")[0].strip() |
---|
1689 | os.remove(filename) |
---|
1690 | |
---|
1691 | self.update_all() |
---|
1692 | |
---|
1693 | |
---|
1694 | def DeleteFilesUser(self): |
---|
1695 | |
---|
1696 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
1697 | |
---|
1698 | if status == QtWidgets.QMessageBox.Yes: |
---|
1699 | |
---|
1700 | sel_job = self.list_jobs.currentItem().text() |
---|
1701 | sel_files = self.list_user.selectedItems() |
---|
1702 | |
---|
1703 | input_dir = job_dir + "/" + sel_job + "/USER_CODE/" |
---|
1704 | |
---|
1705 | for i in range(0,len(sel_files)): |
---|
1706 | filename = input_dir + sel_files[i].text().split("(")[0].strip() |
---|
1707 | os.remove(filename) |
---|
1708 | |
---|
1709 | self.update_all() |
---|
1710 | |
---|
1711 | |
---|
1712 | def DeleteFilesMonitoring(self): |
---|
1713 | |
---|
1714 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
1715 | |
---|
1716 | if status == QtWidgets.QMessageBox.Yes: |
---|
1717 | |
---|
1718 | sel_job = self.list_jobs.currentItem().text() |
---|
1719 | sel_files = self.list_monitoring.selectedItems() |
---|
1720 | |
---|
1721 | input_dir = job_dir + "/" + sel_job + "/MONITORING/" |
---|
1722 | |
---|
1723 | for i in range(0,len(sel_files)): |
---|
1724 | filename = input_dir + sel_files[i].text().split("(")[0].strip() |
---|
1725 | os.remove(filename) |
---|
1726 | |
---|
1727 | self.update_all() |
---|
1728 | |
---|
1729 | |
---|
1730 | def DeleteFilesOutput(self): |
---|
1731 | |
---|
1732 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
1733 | |
---|
1734 | if status == QtWidgets.QMessageBox.Yes: |
---|
1735 | |
---|
1736 | sel_job = self.list_jobs.currentItem().text() |
---|
1737 | sel_files = self.list_output.selectedItems() |
---|
1738 | |
---|
1739 | input_dir = job_dir + "/" + sel_job + "/OUTPUT/" |
---|
1740 | |
---|
1741 | for i in range(0,len(sel_files)): |
---|
1742 | filename = input_dir + sel_files[i].text().split("(")[0].strip() |
---|
1743 | os.remove(filename) |
---|
1744 | |
---|
1745 | self.update_all() |
---|
1746 | |
---|
1747 | |
---|
1748 | def DeleteAllFilesInput(self): |
---|
1749 | |
---|
1750 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
1751 | |
---|
1752 | if status == QtWidgets.QMessageBox.Yes: |
---|
1753 | |
---|
1754 | check = self.list_jobs.currentItem() |
---|
1755 | if ( check ): |
---|
1756 | sel_job = self.list_jobs.currentItem().text() |
---|
1757 | sel_files = self.list_input.selectedItems() |
---|
1758 | |
---|
1759 | input_dir = job_dir + "/" + sel_job + "/INPUT/" |
---|
1760 | |
---|
1761 | if os.path.exists(str(input_dir)): |
---|
1762 | shutil.rmtree(str(input_dir)) |
---|
1763 | os.makedirs(str(input_dir)) |
---|
1764 | |
---|
1765 | self.update_all() |
---|
1766 | |
---|
1767 | |
---|
1768 | def DeleteAllFilesUser(self): |
---|
1769 | |
---|
1770 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
1771 | |
---|
1772 | if status == QtWidgets.QMessageBox.Yes: |
---|
1773 | |
---|
1774 | check = self.list_jobs.currentItem() |
---|
1775 | if ( check ): |
---|
1776 | sel_job = self.list_jobs.currentItem().text() |
---|
1777 | sel_files = self.list_input.selectedItems() |
---|
1778 | |
---|
1779 | input_dir = job_dir + "/" + sel_job + "/USER_CODE/" |
---|
1780 | |
---|
1781 | if os.path.exists(str(input_dir)): |
---|
1782 | shutil.rmtree(str(input_dir)) |
---|
1783 | os.makedirs(str(input_dir)) |
---|
1784 | |
---|
1785 | self.update_all() |
---|
1786 | |
---|
1787 | |
---|
1788 | |
---|
1789 | def DeleteAllFilesOutput(self): |
---|
1790 | |
---|
1791 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
1792 | |
---|
1793 | if status == QtWidgets.QMessageBox.Yes: |
---|
1794 | |
---|
1795 | check = self.list_jobs.currentItem() |
---|
1796 | if ( check ): |
---|
1797 | sel_job = self.list_jobs.currentItem().text() |
---|
1798 | sel_files = self.list_input.selectedItems() |
---|
1799 | |
---|
1800 | input_dir = job_dir + "/" + sel_job + "/OUTPUT/" |
---|
1801 | |
---|
1802 | if os.path.exists(str(input_dir)): |
---|
1803 | shutil.rmtree(str(input_dir)) |
---|
1804 | os.makedirs(str(input_dir)) |
---|
1805 | |
---|
1806 | self.update_all() |
---|
1807 | |
---|
1808 | |
---|
1809 | |
---|
1810 | def DeleteAllFilesMonitoring(self): |
---|
1811 | |
---|
1812 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
1813 | |
---|
1814 | if status == QtWidgets.QMessageBox.Yes: |
---|
1815 | |
---|
1816 | check = self.list_jobs.currentItem() |
---|
1817 | if ( check ): |
---|
1818 | sel_job = self.list_jobs.currentItem().text() |
---|
1819 | sel_files = self.list_input.selectedItems() |
---|
1820 | |
---|
1821 | input_dir = job_dir + "/" + sel_job + "/MONITORING/" |
---|
1822 | |
---|
1823 | if os.path.exists(str(input_dir)): |
---|
1824 | shutil.rmtree(str(input_dir)) |
---|
1825 | os.makedirs(str(input_dir)) |
---|
1826 | |
---|
1827 | self.update_all() |
---|
1828 | |
---|
1829 | |
---|
1830 | |
---|
1831 | def DeleteJob(self): |
---|
1832 | |
---|
1833 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete this job?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
1834 | |
---|
1835 | if status == QtWidgets.QMessageBox.Yes: |
---|
1836 | |
---|
1837 | sel_job = self.list_jobs.currentItem().text() |
---|
1838 | |
---|
1839 | input_dir = job_dir + "/" + sel_job |
---|
1840 | shutil.rmtree(str(input_dir)) |
---|
1841 | |
---|
1842 | self.update_all() |
---|
1843 | |
---|
1844 | # Message box for showing RUN_CONTROL output |
---|
1845 | class CreateSetBox(QtWidgets.QDialog): |
---|
1846 | def __init__(self): |
---|
1847 | |
---|
1848 | super(CreateSetBox, self).__init__() |
---|
1849 | |
---|
1850 | uic.loadUi(palm_bin + '/palmrungui_files/create_set.ui', self) |
---|
1851 | |
---|
1852 | self.show() |
---|
1853 | |
---|
1854 | return |
---|
1855 | |
---|
1856 | # Cancel button |
---|
1857 | def rejected(self): |
---|
1858 | |
---|
1859 | self.close() |
---|
1860 | |
---|
1861 | return |
---|
1862 | |
---|
1863 | # OK button |
---|
1864 | def accept(self): |
---|
1865 | |
---|
1866 | global set_list |
---|
1867 | |
---|
1868 | text = self.list.toPlainText() |
---|
1869 | set_list = text.split('\n') |
---|
1870 | self.close() |
---|
1871 | |
---|
1872 | return |
---|
1873 | |
---|
1874 | # Message box for showing RUN_CONTROL output |
---|
1875 | class OpenHistoryBox(QtWidgets.QDialog): |
---|
1876 | def __init__(self): |
---|
1877 | |
---|
1878 | super(OpenHistoryBox, self).__init__() |
---|
1879 | |
---|
1880 | uic.loadUi(palm_bin + '/palmrungui_files/history.ui', self) |
---|
1881 | |
---|
1882 | if os.path.exists(palm_dir + "/.palmrungui.history"): |
---|
1883 | pass |
---|
1884 | else: |
---|
1885 | return |
---|
1886 | |
---|
1887 | filename = open(palm_dir + "/.palmrungui.history","r") |
---|
1888 | history = filename.readlines() |
---|
1889 | filename.close() |
---|
1890 | |
---|
1891 | |
---|
1892 | list_jobname = self.findChild(QtWidgets.QListWidget,"list_history") |
---|
1893 | |
---|
1894 | # Read history entries and append to recent job list |
---|
1895 | len_history=len(history)-1 |
---|
1896 | i = 0 |
---|
1897 | while i<=len_history: |
---|
1898 | list_jobname.addItem(history[i]) |
---|
1899 | i = i + 1 |
---|
1900 | |
---|
1901 | self.show() |
---|
1902 | |
---|
1903 | return |
---|
1904 | |
---|
1905 | # Select item / activate Load button |
---|
1906 | def ItemSelected(self): |
---|
1907 | |
---|
1908 | self.push_open.setEnabled(True) |
---|
1909 | |
---|
1910 | return |
---|
1911 | |
---|
1912 | |
---|
1913 | # Load job from history |
---|
1914 | def OpenFromHistory(self): |
---|
1915 | |
---|
1916 | global history_entry |
---|
1917 | history_entry = self.list_history.selectedItems()[0].text() |
---|
1918 | |
---|
1919 | self.close() |
---|
1920 | |
---|
1921 | return |
---|
1922 | |
---|
1923 | # Close history window |
---|
1924 | def DiscardHistory(self): |
---|
1925 | |
---|
1926 | global history_entry |
---|
1927 | history_entry = "" |
---|
1928 | self.close() |
---|
1929 | |
---|
1930 | return |
---|
1931 | |
---|
1932 | # Clear history |
---|
1933 | def ClearHistory(self): |
---|
1934 | |
---|
1935 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete your history?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
1936 | |
---|
1937 | if status == QtWidgets.QMessageBox.Yes: |
---|
1938 | |
---|
1939 | if os.path.exists(palm_dir + "/.palmrungui.history"): |
---|
1940 | os.remove(palm_dir + "/.palmrungui.history") |
---|
1941 | |
---|
1942 | |
---|
1943 | return |
---|
1944 | |
---|
1945 | if __name__ == "__main__": |
---|
1946 | app = QtWidgets.QApplication(sys.argv) |
---|
1947 | window = Mainwindow() |
---|
1948 | window.show() |
---|
1949 | sys.exit(app.exec_()) |
---|