[4670] | 1 | #!/usr/bin/env python3 |
---|
[2413] | 2 | # -*- coding: utf-8 -*- |
---|
| 3 | #--------------------------------------------------------------------------------# |
---|
[2696] | 4 | # This file is part of the PALM model system. |
---|
[2413] | 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 | # |
---|
[4481] | 17 | # Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
[2413] | 18 | #--------------------------------------------------------------------------------# |
---|
| 19 | # |
---|
| 20 | # Current revisions: |
---|
| 21 | # ----------------- |
---|
[4789] | 22 | # |
---|
| 23 | # |
---|
[2413] | 24 | # Former revisions: |
---|
| 25 | # ----------------- |
---|
| 26 | # $Id: palmrungui 4789 2020-11-18 09:05:50Z eckhard $ |
---|
[4789] | 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 |
---|
[4670] | 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 |
---|
[4482] | 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 |
---|
[4481] | 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 |
---|
[4470] | 45 | # Added file size output, more I/O functionalities, new/removed buttons |
---|
| 46 | # |
---|
| 47 | # 4428 2020-02-27 11:43:53Z maronga |
---|
[4428] | 48 | # Bugfix for update button |
---|
| 49 | # |
---|
| 50 | # 4427 2020-02-27 11:29:51Z maronga |
---|
[4427] | 51 | # Small fixes and adjustments |
---|
| 52 | # |
---|
| 53 | # 4420 2020-02-24 14:13:56Z maronga |
---|
[4420] | 54 | # Bugfix: minor fixes related to start buttons |
---|
| 55 | # |
---|
| 56 | # 4411 2020-02-18 14:28:02Z maronga |
---|
[4411] | 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 |
---|
[4405] | 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 |
---|
[4394] | 65 | # Bugfix: harmonized naming convention of configuration files |
---|
| 66 | # |
---|
| 67 | # 4393 2020-02-04 21:24:48Z maronga |
---|
[4393] | 68 | # Removed PALM_BIN dependency and os calls |
---|
| 69 | # |
---|
| 70 | # 3487 2018-11-05 07:18:02Z maronga |
---|
[3487] | 71 | # Renamed options -d and -h to -r and -c. |
---|
| 72 | # |
---|
| 73 | # 2825 2018-02-20 21:48:27Z maronga |
---|
[2825] | 74 | # Adjusted to work with newest version of palmrun |
---|
| 75 | # |
---|
| 76 | # 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 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 |
---|
[2484] | 83 | # Added PALM logo |
---|
| 84 | # |
---|
| 85 | # 2480 2017-09-19 06:24:14Z maronga |
---|
[2480] | 86 | # option -A (project account number) added |
---|
| 87 | # |
---|
| 88 | # 2477 2017-09-18 08:42:29Z maronga |
---|
[2477] | 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 |
---|
[2413] | 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 |
---|
[4670] | 112 | from PyQt5 import QtCore, QtGui, uic, QtWidgets |
---|
| 113 | from PyQt5.QtWidgets import QMainWindow, QApplication |
---|
| 114 | from PyQt5.QtCore import QProcess, pyqtSlot, QTimer |
---|
[2413] | 115 | from time import strftime |
---|
| 116 | import os |
---|
[4405] | 117 | import shutil |
---|
[2413] | 118 | |
---|
[4470] | 119 | global update_frequency |
---|
| 120 | update_frequency = 5*60000 |
---|
[2413] | 121 | |
---|
| 122 | # Determine PALM directories |
---|
| 123 | try: |
---|
[4393] | 124 | devnull = open(os.devnull, 'w') |
---|
| 125 | palm_dir = os.getcwd() |
---|
| 126 | palm_bin = palm_dir + '/trunk/SCRIPTS' |
---|
[4470] | 127 | palm_source = palm_dir + '/trunk/SOURCE' |
---|
[4393] | 128 | job_dir = palm_dir + '/JOBS' |
---|
| 129 | user_dir = palm_dir + '/USER_CODE' |
---|
[4670] | 130 | with open(palm_bin + '/palmrungui', 'r', encoding='utf8') as fh: |
---|
[4393] | 131 | # file found |
---|
| 132 | out = None |
---|
[2413] | 133 | except: |
---|
[4670] | 134 | print ("Error. palmrungui probably called in wrong directory.") |
---|
[2413] | 135 | raise SystemExit |
---|
| 136 | |
---|
| 137 | |
---|
[4470] | 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 | |
---|
[4670] | 147 | def ilen(iterable): |
---|
| 148 | return reduce(lambda sum, element: sum + 1, iterable, 0) |
---|
[4470] | 149 | |
---|
[2413] | 150 | palmrunline = "" |
---|
[4405] | 151 | set_list = [] |
---|
[2413] | 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 | |
---|
[4670] | 157 | class HelpDialog(QtWidgets.QDialog,Ui_helpDialog): |
---|
[2413] | 158 | def __init__(self, parent=None): |
---|
| 159 | super(HelpDialog,self).__init__() |
---|
| 160 | self.setupUi(self) |
---|
| 161 | |
---|
[4670] | 162 | class AboutDialog(QtWidgets.QDialog,Ui_aboutDialog): |
---|
[2413] | 163 | def __init__(self, parent=None): |
---|
| 164 | super(AboutDialog,self).__init__() |
---|
| 165 | self.setupUi(self) |
---|
| 166 | |
---|
[4670] | 167 | class Mainwindow(QtWidgets.QMainWindow, Ui_MainWindow): |
---|
[2413] | 168 | def __init__(self, parent=None): |
---|
| 169 | super(Mainwindow, self).__init__() |
---|
[2484] | 170 | self.setupUi(self) |
---|
[4670] | 171 | |
---|
| 172 | self.palm_logo.setPixmap(QtGui.QPixmap(palm_bin + "/palmrungui_files/logo.png")) |
---|
| 173 | with open(palm_bin + "/palmrungui", encoding='utf8') as search: |
---|
[4470] | 174 | for line in search: |
---|
| 175 | line = line.rstrip() |
---|
| 176 | if "$Id" in line: |
---|
| 177 | version = "Version: r" + line.split(" ")[3] + " (" + line.split(" ")[4] + ")" |
---|
[4670] | 178 | self.groupBox.findChild(QtWidgets.QLabel,"label_version").setText(version) |
---|
[4470] | 179 | break |
---|
[2477] | 180 | self.recent_jobs(50) |
---|
[4405] | 181 | self.load_jobs() |
---|
| 182 | |
---|
[4670] | 183 | |
---|
| 184 | |
---|
[4411] | 185 | # look up configuration files and add to combo box |
---|
| 186 | |
---|
[4670] | 187 | self.group_execution.findChild(QtWidgets.QComboBox,"combo_configuration").addItem("") |
---|
[4411] | 188 | |
---|
| 189 | for files in os.listdir(palm_dir): |
---|
| 190 | if files.startswith(".palm.config"): |
---|
[4670] | 191 | tmpstring = list(filter(None,files.split(".palm.config.")))[0] |
---|
| 192 | self.group_execution.findChild(QtWidgets.QComboBox,"combo_configuration").addItem(tmpstring) |
---|
[4411] | 193 | |
---|
[4670] | 194 | commandline = self.groupBox.findChild(QtWidgets.QLineEdit,"commandline") |
---|
[2413] | 195 | commandline.setText("") |
---|
| 196 | |
---|
| 197 | self.tabWidget.setCurrentIndex(0) |
---|
| 198 | |
---|
[4670] | 199 | |
---|
[4394] | 200 | filename = "%s/.palmrungui.default" % (palm_dir) |
---|
[2413] | 201 | if os.path.exists(filename): |
---|
[4670] | 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() |
---|
[2413] | 209 | |
---|
[4670] | 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) |
---|
[4405] | 215 | |
---|
[4670] | 216 | QtWidgets.QApplication.processEvents() |
---|
[4405] | 217 | |
---|
[4670] | 218 | # Start refresh timer. On timeout perform update |
---|
[4405] | 219 | |
---|
[4470] | 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 |
---|
[4670] | 230 | |
---|
[4470] | 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 | |
---|
[2413] | 239 | # starts xterm with palmrun commandline |
---|
| 240 | ####################################### |
---|
| 241 | def startpalmrun(self): |
---|
[4670] | 242 | palmrunline = str(self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").text()) |
---|
[4411] | 243 | palmrunline_save = palmrunline |
---|
[4670] | 244 | |
---|
[2413] | 245 | # Disable the main window |
---|
| 246 | self.tabWidget.setEnabled(False) |
---|
[4670] | 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...") |
---|
[4470] | 251 | |
---|
[2413] | 252 | # Wait until all commands have been executed (ugly) ? |
---|
| 253 | #for i in range(0,21): |
---|
| 254 | # qApp->processEvents() |
---|
[4470] | 255 | |
---|
[2413] | 256 | # Start xterm as QProcess |
---|
| 257 | palmrun = QProcess() |
---|
| 258 | palmrun.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels |
---|
[4393] | 259 | palmrun.setWorkingDirectory(palm_dir) |
---|
[4470] | 260 | |
---|
[2413] | 261 | geomet = self.frameGeometry() |
---|
[4470] | 262 | |
---|
[2413] | 263 | posx = geomet.x()+geomet.width() |
---|
| 264 | posy = geomet.y() |
---|
[4470] | 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 | |
---|
[2413] | 272 | mString = "xterm %s" % (palmrunline) |
---|
[4411] | 273 | palmrun.start(mString) |
---|
[4470] | 274 | |
---|
[2413] | 275 | if( palmrun.waitForStarted() is False ): |
---|
| 276 | return |
---|
[4470] | 277 | |
---|
[2413] | 278 | # Wait until palmrun has finished or wait for 200 minutes |
---|
[4411] | 279 | palmrun.waitForFinished(3600000) |
---|
[4470] | 280 | |
---|
[2413] | 281 | # Jobs has been submitted or aborted. Continuing... |
---|
| 282 | # Save the palmrun command to history file |
---|
[4394] | 283 | filename = "%s/.palmrungui.history" % (palm_dir) |
---|
[2413] | 284 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
[4670] | 285 | tag = str(self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").text()) |
---|
[2413] | 286 | |
---|
| 287 | file = open(filename,"a") |
---|
[4670] | 288 | s = "%s %s (%s)\n" % (tmstamp,palmrunline_save,tag) |
---|
[2413] | 289 | file.write(s) |
---|
| 290 | file.close() |
---|
| 291 | |
---|
| 292 | # Enable main window again |
---|
| 293 | self.tabWidget.setEnabled(True) |
---|
[4670] | 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) |
---|
[2413] | 298 | |
---|
| 299 | # Reload recent jobs |
---|
[2477] | 300 | self.recent_jobs(50) |
---|
[2413] | 301 | |
---|
| 302 | |
---|
[4470] | 303 | |
---|
| 304 | # Update the label |
---|
| 305 | def UpdatePush(self): |
---|
[4670] | 306 | remaining_time = int((update_frequency - self.timetimer.elapsed()) / 1000 / 60) |
---|
[4470] | 307 | self.push_update.setText("Update (" + str(remaining_time) + " min)") |
---|
| 308 | |
---|
| 309 | |
---|
[4411] | 310 | # starts xterm with palmbuild commandline |
---|
| 311 | ####################################### |
---|
| 312 | def startpalmbuild(self): |
---|
[4670] | 313 | palmbuildline = 'palmbuild -c ' + str(self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration").currentText()) |
---|
[4470] | 314 | |
---|
[4670] | 315 | full_build = self.group_execution.findChild(QtWidgets.QCheckBox,"check_rebuild").checkState() |
---|
[4470] | 316 | |
---|
| 317 | if ( full_build == 2 ): |
---|
| 318 | for filename in os.listdir(palm_source): |
---|
| 319 | os.utime(palm_source + "/" + filename, None) |
---|
| 320 | |
---|
[4670] | 321 | palmrunline_save = str(self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").text()) |
---|
[4470] | 322 | |
---|
[4411] | 323 | # Disable the main window |
---|
[4420] | 324 | palmbuildline_save = palmbuildline |
---|
[4411] | 325 | self.tabWidget.setEnabled(False) |
---|
[4670] | 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...") |
---|
[4411] | 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) |
---|
[4670] | 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") |
---|
[4411] | 367 | # Reload recent jobs |
---|
| 368 | self.recent_jobs(50) |
---|
| 369 | |
---|
[2413] | 370 | # loads recent jobs |
---|
| 371 | ###################################### |
---|
| 372 | def recent_jobs(self, number): |
---|
[4394] | 373 | fileDir = "%s/.palmrungui.history" % (palm_dir) |
---|
[2413] | 374 | if os.path.exists(fileDir): |
---|
| 375 | pass |
---|
| 376 | else: |
---|
| 377 | return |
---|
[4470] | 378 | |
---|
[2413] | 379 | file = open(fileDir,"r") |
---|
| 380 | history = file.readlines() |
---|
| 381 | tmphistory = list() |
---|
[4411] | 382 | tmptag = list() |
---|
| 383 | file.close() |
---|
| 384 | j = 0 |
---|
[2413] | 385 | |
---|
[4670] | 386 | list_jobname = self.group_history.findChild(QtWidgets.QListWidget,"list_jobname") |
---|
[2413] | 387 | list_jobname.clear() |
---|
| 388 | |
---|
| 389 | # Read history entries and append to recent job list |
---|
| 390 | i=len(history)-1 |
---|
| 391 | count = 0 |
---|
[2477] | 392 | while i>=0 and count<number: |
---|
[2413] | 393 | timestamp = history[i][:16] |
---|
| 394 | listitem = history[i][17:len(history[i])-1] |
---|
[4411] | 395 | tagitem = listitem |
---|
[4470] | 396 | configitem = listitem |
---|
[2413] | 397 | matchitems = list_jobname.findItems(listitem, QtCore.Qt.MatchExactly) |
---|
| 398 | |
---|
| 399 | if ( len(matchitems) == 0 ): |
---|
[4670] | 400 | listitem = list(filter(None,listitem.split(" -r")))[1] |
---|
[4470] | 401 | listitem = listitem.strip() |
---|
[4670] | 402 | listitem = list(filter(None,listitem.split(" ")))[0] |
---|
[4470] | 403 | listitem = listitem.replace("\"","") |
---|
[4411] | 404 | list_jobname.addItem(listitem) |
---|
[4470] | 405 | |
---|
[4670] | 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] |
---|
[4470] | 413 | configitem = configitem.replace("\"","") |
---|
| 414 | |
---|
| 415 | s = "%s: %s (%s)" % (timestamp,listitem,configitem) |
---|
[4411] | 416 | tmphistory.append(s) |
---|
| 417 | |
---|
| 418 | |
---|
[4670] | 419 | tagitem = list(filter(None,tagitem.split(" (")))[1] |
---|
[4411] | 420 | tagitem = tagitem.replace(")","") |
---|
| 421 | if ( len(tagitem) == 0 ): |
---|
| 422 | s = "Tag: empty" |
---|
| 423 | else: |
---|
| 424 | s = "Tag: %s" % (tagitem) |
---|
| 425 | tmptag.append(s) |
---|
[2413] | 426 | count = count +1 |
---|
[4411] | 427 | |
---|
[2413] | 428 | j = j+1 |
---|
| 429 | |
---|
| 430 | if ( j == number ): |
---|
| 431 | break |
---|
| 432 | i = i-1 |
---|
| 433 | |
---|
| 434 | # Send to list |
---|
[4411] | 435 | list_jobname.clear() |
---|
[2413] | 436 | |
---|
| 437 | i=0 |
---|
| 438 | while i<len(tmphistory): |
---|
[4411] | 439 | list_jobname.addItem(tmphistory[i]) |
---|
| 440 | list_jobname.item(i).setToolTip(tmptag[i]) |
---|
[2413] | 441 | i = i+1 |
---|
| 442 | |
---|
| 443 | |
---|
| 444 | # Enables coupled settings |
---|
| 445 | ############################### |
---|
| 446 | def enable_coupled(self): |
---|
[4670] | 447 | coupledState = self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").currentText() |
---|
| 448 | group = self.group_execution.findChild(QtWidgets.QGroupBox, "group_coupled") |
---|
[2413] | 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 | |
---|
[2477] | 456 | # select a job via click from list |
---|
[2413] | 457 | ################################# |
---|
| 458 | def choosejob_list(self): |
---|
| 459 | # Get selected item from list |
---|
[4670] | 460 | list_jobname = self.group_history.findChild(QtWidgets.QListWidget,"list_jobname") |
---|
[2413] | 461 | filename = str(list_jobname.currentItem().text()) |
---|
[4470] | 462 | |
---|
[4411] | 463 | timestamp = filename[:16] |
---|
[4470] | 464 | jobname = filename[18:].split(" ")[0] |
---|
| 465 | |
---|
[2413] | 466 | itemint = list_jobname.currentRow() |
---|
[4405] | 467 | |
---|
[2413] | 468 | # Reload list |
---|
[2477] | 469 | self.recent_jobs(50) |
---|
[4405] | 470 | self.load_jobs() |
---|
[2413] | 471 | |
---|
| 472 | # Set selected item to jobname |
---|
[4411] | 473 | list_jobname.item(itemint).setSelected(True) |
---|
[2413] | 474 | |
---|
[4405] | 475 | # Set selected item to jobname in "available jobs" list |
---|
| 476 | item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive) |
---|
[4411] | 477 | |
---|
| 478 | if ( item2int != [] ): |
---|
| 479 | self.list_jobs.setCurrentItem(item2int[0]) |
---|
[4405] | 480 | self.update_input() |
---|
[4411] | 481 | |
---|
[2413] | 482 | |
---|
[4394] | 483 | fileDir = "%s/.palmrungui.history" % (palm_dir) |
---|
[2413] | 484 | file = open(fileDir,"r") |
---|
| 485 | history = file.readlines() |
---|
| 486 | tmphistory = list() |
---|
[4411] | 487 | file.close() |
---|
[2413] | 488 | |
---|
| 489 | i = len(history) |
---|
| 490 | while i>=1: |
---|
| 491 | listitem = history[i-1][17:len(history[i-1])-1] |
---|
[4670] | 492 | listitem = list(filter(None,listitem.split(" -r")))[1] |
---|
[4470] | 493 | listitem = listitem.strip() |
---|
[4670] | 494 | listitem = list(filter(None,listitem.split(" ")))[0] |
---|
[4470] | 495 | listitem = listitem.replace("\"","") |
---|
[2413] | 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] |
---|
[4670] | 502 | palmrunline = list(filter(None,palmrunline.split("(")))[0] |
---|
| 503 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText(palmrunline) |
---|
[2477] | 504 | |
---|
[4411] | 505 | |
---|
| 506 | tag = history[i-1].split('\n')[0] |
---|
[4670] | 507 | tag = list(filter(None,tag.split("(")))[1] |
---|
[4411] | 508 | tag = tag.replace(")","") |
---|
| 509 | |
---|
[4670] | 510 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setText(tag) |
---|
[4411] | 511 | self.setup_gui(palmrunline) |
---|
| 512 | self.list_jobname.item(itemint).setSelected(True) |
---|
| 513 | |
---|
[2413] | 514 | return |
---|
| 515 | i = i-1 |
---|
| 516 | |
---|
| 517 | # Change run identifer (initial, restart, coupled...) |
---|
| 518 | ###################################################### |
---|
| 519 | def change_rc_list(self): |
---|
[4670] | 520 | drop_job = self.group_execution.findChild(QtWidgets.QComboBox,"drop_job").currentText() |
---|
[2413] | 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)"): |
---|
[4670] | 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() |
---|
[2413] | 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)"): |
---|
[3487] | 532 | self.change_commandline("r","") |
---|
[2413] | 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 |
---|
[4670] | 547 | palmrunline = str(self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").text()) |
---|
[2413] | 548 | s = " -%s " % (id_str) |
---|
[4670] | 549 | splitline = list(filter(None,palmrunline.split(s))) |
---|
[2413] | 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 | |
---|
[3487] | 561 | # Change in parameter "r" (jobname) |
---|
| 562 | if (id_str == "r"): |
---|
[4670] | 563 | filename = str(self.group_execution.findChild(QtWidgets.QLineEdit,"line_jobname").text()) |
---|
[2413] | 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) |
---|
[4670] | 569 | self.group_execution.findChild(QtWidgets.QComboBox,"drop_job").setEnabled(True) |
---|
[2413] | 570 | self.group_advanced.setEnabled(True) |
---|
[4670] | 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) |
---|
[2413] | 574 | |
---|
| 575 | elif ( param[0] == ""): |
---|
| 576 | self.group_execution.setEnabled(False) |
---|
[4670] | 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) |
---|
[2413] | 580 | self.group_advanced.setEnabled(False) |
---|
[4670] | 581 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(True) |
---|
[3487] | 582 | self.delete_commandline("r") |
---|
[2413] | 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 | |
---|
[4670] | 595 | drop_job = self.group_execution.findChild(QtWidgets.QComboBox,"drop_job").currentText() |
---|
[2413] | 596 | rc_flag = "#" |
---|
| 597 | |
---|
| 598 | if (drop_job == "Initial run"): |
---|
| 599 | rc_flag = "#" |
---|
| 600 | |
---|
| 601 | elif (drop_job == "Restart run"): |
---|
[2477] | 602 | rc_flag = "r" |
---|
[2413] | 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)"): |
---|
[2477] | 614 | rc_flag = "r" |
---|
[2413] | 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: |
---|
[2825] | 623 | rc_flag = "or" |
---|
[2413] | 624 | |
---|
| 625 | param[0] = "%s d3%s" % (param[0],rc_flag) |
---|
| 626 | |
---|
[4670] | 627 | status_restarts = self.group_execution.findChild(QtWidgets.QCheckBox,"check_restarts").checkState() |
---|
[2413] | 628 | |
---|
| 629 | if (status_restarts == 2): |
---|
| 630 | param[0]="%s restart" % (param[0]) |
---|
| 631 | |
---|
| 632 | |
---|
[4670] | 633 | status_cycfill = self.group_execution.findChild(QtWidgets.QCheckBox,"check_cycfill").checkState() |
---|
[2413] | 634 | |
---|
| 635 | if (status_cycfill == 2): |
---|
[4670] | 636 | param[0]="%s rec" % (param[0]) |
---|
| 637 | |
---|
| 638 | status_svf = self.group_execution.findChild(QtWidgets.QCheckBox,"check_svf").checkState() |
---|
| 639 | |
---|
[2825] | 640 | if (status_svf == 2): |
---|
[4670] | 641 | param[0]="%s svfin" % (param[0]) |
---|
| 642 | |
---|
| 643 | status_svf_2 = self.group_execution.findChild(QtWidgets.QCheckBox,"check_svf_2").checkState() |
---|
[2413] | 644 | |
---|
[4670] | 645 | if (status_svf_2 == 2): |
---|
| 646 | param[0]="%s svfout" % (param[0]) |
---|
| 647 | |
---|
[2413] | 648 | param[0]="%s\"" % (param[0]) |
---|
[4670] | 649 | |
---|
[2413] | 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) |
---|
[4670] | 657 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(True) |
---|
[2413] | 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 | |
---|
[4670] | 675 | # Print the new palmrunline to mainwindow |
---|
[2413] | 676 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
[4670] | 677 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText(newpalmrunline) |
---|
[2413] | 678 | |
---|
| 679 | # change lineinput depending on sender |
---|
| 680 | ################################################################################### |
---|
| 681 | def change_lineinput(self): |
---|
[4670] | 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: |
---|
[4411] | 685 | self.change_commandline("c"," ") |
---|
[4670] | 686 | self.group_execution.findChild(QtWidgets.QPushButton,'button_palmbuild').setEnabled(False) |
---|
[4411] | 687 | else: |
---|
| 688 | self.change_commandline("c",tmptext) |
---|
[4670] | 689 | self.group_execution.findChild(QtWidgets.QPushButton,'button_palmbuild').setEnabled(True) |
---|
[2413] | 690 | |
---|
[4670] | 691 | elif ( self.sender() == self.group_execution.findChild(QtWidgets.QLineEdit,"line_q")): |
---|
| 692 | tmptext = self.group_execution.findChild(QtWidgets.QLineEdit,"line_q").text() |
---|
[2413] | 693 | self.change_commandline("q",tmptext) |
---|
| 694 | |
---|
[4670] | 695 | elif ( self.sender() == self.group_execution.findChild(QtWidgets.QLineEdit,"line_account")): |
---|
| 696 | tmptext = self.group_execution.findChild(QtWidgets.QLineEdit,"line_account").text() |
---|
[2480] | 697 | self.change_commandline("A",tmptext) |
---|
[4789] | 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 | |
---|
[4670] | 703 | elif ( self.sender() == self.group_execution.findChild(QtWidgets.QLineEdit,"line_pe")): |
---|
| 704 | tmptext = self.group_execution.findChild(QtWidgets.QLineEdit,"line_pe").text() |
---|
[2413] | 705 | self.change_commandline("X",tmptext) |
---|
| 706 | |
---|
[4670] | 707 | elif ( self.sender() == self.group_execution.findChild(QtWidgets.QLineEdit,"line_tpn")): |
---|
| 708 | tmptext = self.group_execution.findChild(QtWidgets.QLineEdit,"line_tpn").text() |
---|
[2413] | 709 | self.change_commandline("T",tmptext) |
---|
| 710 | |
---|
[4670] | 711 | elif ( self.sender() == self.group_execution.findChild(QtWidgets.QLineEdit,"line_time")): |
---|
| 712 | tmptext = self.group_execution.findChild(QtWidgets.QLineEdit,"line_time").text() |
---|
[2413] | 713 | self.change_commandline("t",tmptext) |
---|
| 714 | |
---|
[4670] | 715 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_M")): |
---|
| 716 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_M").text() |
---|
[2413] | 717 | self.change_commandline("M",tmptext) |
---|
| 718 | |
---|
[4670] | 719 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_m")): |
---|
| 720 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_m").text() |
---|
[2413] | 721 | self.change_commandline("m",tmptext) |
---|
| 722 | |
---|
[4670] | 723 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_D")): |
---|
| 724 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_D").text() |
---|
[2413] | 725 | self.change_commandline("D",tmptext) |
---|
| 726 | |
---|
[4670] | 727 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_c")): |
---|
| 728 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_c").text() |
---|
[4394] | 729 | if ( tmptext == ".palmrungui.config"): |
---|
[2413] | 730 | tmptext = "" |
---|
| 731 | self.change_commandline("c",tmptext) |
---|
| 732 | |
---|
[4670] | 733 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_s")): |
---|
| 734 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_s").text() |
---|
[2413] | 735 | self.change_commandline("s",tmptext) |
---|
| 736 | |
---|
[4670] | 737 | elif ( self.sender() == self.group_advanced.findChild(QtWidgets.QLineEdit,"line_w")): |
---|
| 738 | tmptext = self.group_advanced.findChild(QtWidgets.QLineEdit,"line_w").text() |
---|
[2413] | 739 | self.change_commandline("w",tmptext) |
---|
| 740 | |
---|
[4670] | 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() |
---|
[2413] | 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 |
---|
[4670] | 757 | |
---|
[2413] | 758 | try: |
---|
| 759 | pe2 = int(t2) |
---|
| 760 | except ValueError: |
---|
| 761 | pass |
---|
[4670] | 762 | |
---|
[2413] | 763 | PE_total = pe1+pe2 |
---|
[4670] | 764 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_pe").setText(str(PE_total)) |
---|
[2413] | 765 | self.change_commandline("X",str(PE_total)) |
---|
[4670] | 766 | |
---|
[2413] | 767 | # deletes parameter from commandline |
---|
| 768 | ##################################################################################### |
---|
| 769 | def delete_commandline(self, id_str): |
---|
| 770 | # Read palmrunline |
---|
[4670] | 771 | commandline = self.groupBox.findChild(QtWidgets.QLineEdit,"commandline") |
---|
[2413] | 772 | palmrunline = str(commandline.text()) |
---|
| 773 | s = " -%s" % (id_str) |
---|
[4670] | 774 | splitline = list(filter(None,palmrunline.split(s))) |
---|
[2413] | 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): |
---|
[4670] | 791 | status = self.group_execution.findChild(QtWidgets.QCheckBox,"check_delete_tmp_files" ).checkState() |
---|
[2413] | 792 | if (status == 2): |
---|
| 793 | self.activate_flag("B") |
---|
| 794 | else: |
---|
| 795 | self.deactivate_flag("B") |
---|
| 796 | |
---|
[4789] | 797 | status = self.groupBox.findChild(QtWidgets.QCheckBox,"check_verbose" ).checkState() |
---|
[2413] | 798 | if (status == 2): |
---|
| 799 | self.activate_flag("v") |
---|
| 800 | else: |
---|
| 801 | self.deactivate_flag("v") |
---|
| 802 | |
---|
[4670] | 803 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_b" ).checkState() |
---|
[2413] | 804 | if (status == 2): |
---|
| 805 | self.activate_flag("b") |
---|
| 806 | else: |
---|
| 807 | self.deactivate_flag("b") |
---|
| 808 | |
---|
[4670] | 809 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_F" ).checkState() |
---|
[2413] | 810 | if (status == 2): |
---|
| 811 | self.activate_flag("F") |
---|
| 812 | else: |
---|
| 813 | self.deactivate_flag("F") |
---|
| 814 | |
---|
[4670] | 815 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_I" ).checkState() |
---|
[2413] | 816 | if (status == 2): |
---|
| 817 | self.activate_flag("I") |
---|
| 818 | else: |
---|
| 819 | self.deactivate_flag("I") |
---|
| 820 | |
---|
[4670] | 821 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_k" ).checkState() |
---|
[2413] | 822 | if (status == 2): |
---|
| 823 | self.activate_flag("k") |
---|
| 824 | else: |
---|
| 825 | self.deactivate_flag("k") |
---|
| 826 | |
---|
[4670] | 827 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_O" ).checkState() |
---|
[2413] | 828 | if (status == 2): |
---|
| 829 | self.activate_flag("O") |
---|
| 830 | else: |
---|
| 831 | self.deactivate_flag("O") |
---|
| 832 | |
---|
[4670] | 833 | status = self.group_execution.findChild(QtWidgets.QCheckBox,"check_prebuilt" ).checkState() |
---|
[2413] | 834 | if (status == 2): |
---|
[4670] | 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): |
---|
[2413] | 841 | self.activate_flag("x") |
---|
| 842 | else: |
---|
| 843 | self.deactivate_flag("x") |
---|
| 844 | |
---|
[4670] | 845 | status = self.group_advanced.findChild(QtWidgets.QCheckBox,"check_Z" ).checkState() |
---|
[2413] | 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): |
---|
[4670] | 854 | commandline = self.groupBox.findChild(QtWidgets.QLineEdit,"commandline") |
---|
[2413] | 855 | palmrunline = str(commandline.text()) |
---|
| 856 | s = " -%s" % (id_str) |
---|
[4670] | 857 | splitline = list(filter(None,palmrunline.split(s))) |
---|
[2413] | 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): |
---|
[4670] | 869 | commandline = self.groupBox.findChild(QtWidgets.QLineEdit,"commandline") |
---|
[2413] | 870 | palmrunline = str(commandline.text()) |
---|
| 871 | s = " -%s" % (id_str) |
---|
[4670] | 872 | splitline = list(filter(None,palmrunline.split(s))) |
---|
[2413] | 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) |
---|
[4670] | 883 | self.palm_logo.setPixmap(QtGui.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png")) |
---|
[2477] | 884 | self.recent_jobs(50) |
---|
[4405] | 885 | self.load_jobs() |
---|
[2413] | 886 | |
---|
[4470] | 887 | |
---|
[2413] | 888 | # Safes current commandline and user parameters to default file |
---|
| 889 | ################################################################################ |
---|
| 890 | def save_default(self): |
---|
[4670] | 891 | string_to_file = self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").text() |
---|
| 892 | |
---|
[4394] | 893 | filename ="%s/.palmrungui.default" % (palm_dir) |
---|
[2413] | 894 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
[4670] | 895 | |
---|
[2413] | 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): |
---|
[2484] | 922 | |
---|
[4670] | 923 | #self.palm_logo.setPixmap(QtWidgets.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png")) |
---|
[2484] | 924 | |
---|
[2413] | 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: |
---|
[4405] | 937 | self.group_execution.setEnabled(True) |
---|
[2413] | 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 |
---|
[3487] | 952 | if ( parameter == "r"): |
---|
[2413] | 953 | |
---|
| 954 | if ( options != ""): |
---|
[4670] | 955 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_jobname").setText(options) |
---|
[2413] | 956 | nojob = False |
---|
| 957 | |
---|
| 958 | else: |
---|
| 959 | nojob = True |
---|
| 960 | |
---|
[3487] | 961 | elif ( parameter == "c"): |
---|
[4670] | 962 | tmpindex = self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration").findText(options.strip(),QtCore.Qt.MatchExactly) |
---|
[4411] | 963 | if tmpindex != -1: |
---|
[4670] | 964 | self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration").setCurrentIndex(tmpindex) |
---|
[4411] | 965 | else: |
---|
[4670] | 966 | self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration").setCurrentIndex(0) |
---|
[2413] | 967 | elif ( parameter == "q"): |
---|
[4670] | 968 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_q").setText(options) |
---|
[2413] | 969 | |
---|
[2480] | 970 | elif ( parameter == "A"): |
---|
[4670] | 971 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_account").setText(options) |
---|
[4789] | 972 | |
---|
| 973 | elif ( parameter == "W"): |
---|
| 974 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_wait").setText(options) |
---|
| 975 | |
---|
[2413] | 976 | elif ( parameter == "X"): |
---|
[4670] | 977 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_pe").setText(options) |
---|
[2413] | 978 | |
---|
| 979 | elif ( parameter == "T"): |
---|
[4670] | 980 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_tpn").setText(options) |
---|
[2413] | 981 | |
---|
| 982 | elif ( parameter == "t"): |
---|
[4670] | 983 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_time").setText(options) |
---|
[2413] | 984 | |
---|
| 985 | elif ( parameter == "B"): |
---|
[4670] | 986 | self.group_execution.findChild(QtWidgets.QCheckBox,"check_delete_tmp_files").setChecked(True) |
---|
[2413] | 987 | |
---|
| 988 | elif ( parameter == "v"): |
---|
[4789] | 989 | self.groupBox.findChild(QtWidgets.QCheckBox,"check_verbose").setChecked(True) |
---|
[2413] | 990 | |
---|
| 991 | elif ( parameter == "b"): |
---|
[4670] | 992 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_b").setChecked(True) |
---|
[2413] | 993 | |
---|
| 994 | elif ( parameter == "F"): |
---|
[4670] | 995 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_F").setChecked(True) |
---|
[2413] | 996 | |
---|
| 997 | elif ( parameter == "I"): |
---|
[4670] | 998 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_I").setChecked(True) |
---|
[2413] | 999 | |
---|
| 1000 | elif ( parameter == "k"): |
---|
[4670] | 1001 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_k").setChecked(True) |
---|
[2413] | 1002 | |
---|
| 1003 | elif ( parameter == "O"): |
---|
[4670] | 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 | |
---|
[2413] | 1009 | elif ( parameter == "x"): |
---|
[4670] | 1010 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_x").setChecked(True) |
---|
| 1011 | |
---|
[2413] | 1012 | elif ( parameter == "Z"): |
---|
[4670] | 1013 | self.group_advanced.findChild(QtWidgets.QCheckBox,"check_Z").setChecked(True) |
---|
[2413] | 1014 | |
---|
| 1015 | elif ( parameter == "m"): |
---|
[4670] | 1016 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_m").setText(options) |
---|
[2413] | 1017 | |
---|
| 1018 | elif ( parameter == "M"): |
---|
[4670] | 1019 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_M").setText(options) |
---|
[2413] | 1020 | |
---|
| 1021 | elif ( parameter == "D"): |
---|
[4670] | 1022 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_D").setText(options) |
---|
[2413] | 1023 | |
---|
| 1024 | elif ( parameter == "c"): |
---|
[4670] | 1025 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_c").setText(options) |
---|
[2413] | 1026 | |
---|
| 1027 | elif ( parameter == "s"): |
---|
[4670] | 1028 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_s").setText(options) |
---|
[2413] | 1029 | |
---|
| 1030 | elif ( parameter == "w"): |
---|
[4670] | 1031 | self.group_advanced.findChild(QtWidgets.QLineEdit,"line_w").setText(options) |
---|
[2413] | 1032 | |
---|
| 1033 | |
---|
| 1034 | # Determine settings for coupled restart runs |
---|
| 1035 | elif ( parameter == "Y"): |
---|
| 1036 | optionssplit = options.split(" ") |
---|
| 1037 | |
---|
[4670] | 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) |
---|
[2413] | 1045 | |
---|
| 1046 | if (optionssplit.count() == 2): |
---|
[4670] | 1047 | group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_atmos").setEnabled(optionssplit[0]) |
---|
| 1048 | group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_ocean").setEnabled(optionssplit[1]) |
---|
[2413] | 1049 | |
---|
| 1050 | else: |
---|
[4670] | 1051 | group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_atmos").setText("") |
---|
| 1052 | group_coupled.findChild(QtWidgets.QLineEdit,"line_PE_ocean").setText("") |
---|
[2413] | 1053 | |
---|
| 1054 | |
---|
| 1055 | coupled_run = True |
---|
| 1056 | |
---|
| 1057 | elif ( parameter == "y"): |
---|
[4670] | 1058 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setCurrentIndex(3) |
---|
[2413] | 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] |
---|
[2825] | 1074 | |
---|
[2477] | 1075 | if (options_2 == "d3"): |
---|
| 1076 | if (options_all[:3][-1] == "#"): |
---|
[4670] | 1077 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setCurrentIndex(0) |
---|
[2477] | 1078 | elif (options_all[:3][-1] == "r"): |
---|
[4670] | 1079 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setCurrentIndex(1) |
---|
[2413] | 1080 | |
---|
[2477] | 1081 | elif (options_all[:3][-1] == "o"): |
---|
[2413] | 1082 | ocean_run = True |
---|
| 1083 | |
---|
| 1084 | if (options_all == "restart"): |
---|
[4670] | 1085 | self.group_execution.findChild(QtWidgets.QCheckBox,"check_restarts").setChecked(True) |
---|
[4470] | 1086 | |
---|
[4789] | 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 | |
---|
[2413] | 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 ): |
---|
[4670] | 1101 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setCurrentIndex(4) |
---|
[2413] | 1102 | |
---|
| 1103 | else: |
---|
[4670] | 1104 | self.group_execution.findChild(QtWidgets.QComboBox, "drop_job").setCurrentIndex(3) |
---|
[2413] | 1105 | |
---|
| 1106 | # Join palmrunline and post it to mainwindow |
---|
| 1107 | palmrunline = " -".join(splitline) |
---|
[4670] | 1108 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText(palmrunline) |
---|
[2413] | 1109 | |
---|
| 1110 | # Disable mainwindow if no job was found, otherwise enable |
---|
| 1111 | if ( nojob == True ): |
---|
| 1112 | self.group_execution.setEnabled(False) |
---|
[4670] | 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) |
---|
[2413] | 1116 | self.group_advanced.setEnabled(False) |
---|
| 1117 | self.check_advanced.setEnabled(False) |
---|
[4670] | 1118 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(False) |
---|
[2413] | 1119 | |
---|
| 1120 | else: |
---|
| 1121 | self.group_execution.setEnabled(True) |
---|
[4670] | 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) |
---|
[2413] | 1125 | self.group_advanced.setEnabled(True) |
---|
[4670] | 1126 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setEnabled(True) |
---|
[4470] | 1127 | |
---|
| 1128 | |
---|
[2413] | 1129 | self.tabWidget.setCurrentIndex(0) |
---|
[4470] | 1130 | |
---|
| 1131 | |
---|
| 1132 | ## Open from history |
---|
| 1133 | ################################### |
---|
[2413] | 1134 | def open_from_file(self): |
---|
| 1135 | |
---|
[4470] | 1136 | # Show History |
---|
| 1137 | opt = OpenHistoryBox() |
---|
| 1138 | opt.exec_() |
---|
[4405] | 1139 | |
---|
[4481] | 1140 | if ( history_entry != "" ): |
---|
| 1141 | palmrunline = str(history_entry) |
---|
| 1142 | palmrunline = palmrunline[17:] |
---|
| 1143 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
[4670] | 1144 | palmrunline = list(filter(None,palmrunline.split("(")))[0] |
---|
| 1145 | self.groupBox.findChild(QtWidgets.QLineEdit,"commandline").setText(palmrunline) |
---|
[4470] | 1146 | |
---|
[4481] | 1147 | # Set selected item to jobname in "available jobs" list |
---|
| 1148 | jobname = str(history_entry[17:]) |
---|
[4670] | 1149 | jobname = list(filter(None,jobname.split(" -r")))[1] |
---|
[4481] | 1150 | jobname = jobname.strip() |
---|
[4670] | 1151 | jobname = list(filter(None,jobname.split(" ")))[0] |
---|
[4481] | 1152 | jobname = jobname.replace("\"","") |
---|
| 1153 | item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive) |
---|
[4470] | 1154 | |
---|
[4481] | 1155 | if ( item2int != [] ): |
---|
| 1156 | self.list_jobs.setCurrentItem(item2int[0]) |
---|
| 1157 | self.update_input() |
---|
[4470] | 1158 | |
---|
[4481] | 1159 | # Add tooltip tag |
---|
| 1160 | tag = str(history_entry).split('\n')[0] |
---|
[4670] | 1161 | tag = list(filter(None,tag.split("(")))[1] |
---|
[4481] | 1162 | tag = tag.replace(")","") |
---|
[4670] | 1163 | self.groupBox.findChild(QtWidgets.QLineEdit,"line_tag").setText(tag) |
---|
[4405] | 1164 | |
---|
[4481] | 1165 | # Process palmrungui to set up gui controls |
---|
| 1166 | self.setup_gui(palmrunline) |
---|
[4470] | 1167 | |
---|
| 1168 | |
---|
[4405] | 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) |
---|
[4427] | 1178 | self.update_input() |
---|
[4405] | 1179 | |
---|
[4470] | 1180 | |
---|
[4405] | 1181 | # Load jobs into list |
---|
| 1182 | def load_jobs(self): |
---|
| 1183 | |
---|
[4427] | 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 | |
---|
[4405] | 1191 | self.list_jobs.clear() |
---|
| 1192 | self.line_path.setText(job_dir + "/") |
---|
| 1193 | |
---|
| 1194 | list_of_files = os.listdir(job_dir) |
---|
[4411] | 1195 | |
---|
| 1196 | |
---|
[4405] | 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) ): |
---|
[4411] | 1201 | self.list_jobs.addItem(str(list_of_files[i])) |
---|
| 1202 | |
---|
[4405] | 1203 | |
---|
| 1204 | |
---|
[4427] | 1205 | item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive) |
---|
| 1206 | |
---|
| 1207 | if ( item2int != [] ): |
---|
| 1208 | self.list_jobs.setCurrentItem(item2int[0]) |
---|
| 1209 | |
---|
| 1210 | |
---|
[4405] | 1211 | # Update input and user code lists |
---|
| 1212 | def update_input(self): |
---|
[4470] | 1213 | |
---|
| 1214 | self.labeltimer.stop() |
---|
| 1215 | |
---|
[4405] | 1216 | |
---|
| 1217 | self.list_input.clear() |
---|
| 1218 | self.list_user.clear() |
---|
| 1219 | self.list_monitoring.clear() |
---|
| 1220 | self.list_output.clear() |
---|
[4428] | 1221 | |
---|
| 1222 | jobitem = self.list_jobs.currentItem() |
---|
| 1223 | |
---|
| 1224 | if ( jobitem != None ): |
---|
| 1225 | |
---|
| 1226 | job_to_show = job_dir + "/" + jobitem.text() + "/INPUT" |
---|
[4405] | 1227 | |
---|
[4428] | 1228 | if ( os.path.isdir(job_to_show) ): |
---|
[4405] | 1229 | |
---|
[4428] | 1230 | list_of_files = os.listdir(job_to_show) |
---|
[4405] | 1231 | |
---|
[4428] | 1232 | for i in range(0,len(list_of_files)): |
---|
| 1233 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
[4405] | 1234 | |
---|
[4428] | 1235 | if ( os.path.isfile(tmp_file) ): |
---|
[4470] | 1236 | self.list_input.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")") |
---|
[4405] | 1237 | |
---|
[4428] | 1238 | job_to_show = job_dir + "/" + jobitem.text() + "/USER_CODE" |
---|
[4405] | 1239 | |
---|
[4428] | 1240 | if ( os.path.isdir(job_to_show) ): |
---|
[4405] | 1241 | |
---|
[4428] | 1242 | list_of_files = os.listdir(job_to_show) |
---|
[4405] | 1243 | |
---|
[4428] | 1244 | for i in range(0,len(list_of_files)): |
---|
| 1245 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
[4405] | 1246 | |
---|
[4428] | 1247 | if ( os.path.isfile(tmp_file) ): |
---|
| 1248 | self.list_user.addItem(str(list_of_files[i])) |
---|
[4405] | 1249 | |
---|
[4428] | 1250 | job_to_show = job_dir + "/" + jobitem.text() + "/MONITORING" |
---|
[4405] | 1251 | |
---|
[4428] | 1252 | if ( os.path.isdir(job_to_show) ): |
---|
[4405] | 1253 | |
---|
[4428] | 1254 | list_of_files = os.listdir(job_to_show) |
---|
[4405] | 1255 | |
---|
[4428] | 1256 | for i in range(0,len(list_of_files)): |
---|
| 1257 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
[4405] | 1258 | |
---|
[4428] | 1259 | if ( os.path.isfile(tmp_file) ): |
---|
[4470] | 1260 | self.list_monitoring.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")") |
---|
[4405] | 1261 | |
---|
[4428] | 1262 | job_to_show = job_dir + "/" + jobitem.text() + "/OUTPUT" |
---|
| 1263 | |
---|
| 1264 | if ( os.path.isdir(job_to_show) ): |
---|
[4470] | 1265 | |
---|
[4428] | 1266 | list_of_files = os.listdir(job_to_show) |
---|
[4470] | 1267 | |
---|
[4428] | 1268 | for i in range(0,len(list_of_files)): |
---|
| 1269 | tmp_file = job_to_show + "/" + list_of_files[i] |
---|
[4405] | 1270 | |
---|
[4428] | 1271 | if ( os.path.isfile(tmp_file) ): |
---|
[4470] | 1272 | self.list_output.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")") |
---|
[4405] | 1273 | |
---|
[4670] | 1274 | self.group_execution.findChild(QtWidgets.QLineEdit,"line_jobname").setText(jobitem.text()) |
---|
| 1275 | self.group_history.findChild(QtWidgets.QListWidget,"list_jobname").clearSelection() |
---|
[4405] | 1276 | |
---|
[4470] | 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)") |
---|
[4670] | 1281 | QtWidgets.QApplication.processEvents() |
---|
[4470] | 1282 | |
---|
[4405] | 1283 | # Change palmrunline accordingly |
---|
| 1284 | self.change_commandline("r","") |
---|
[4470] | 1285 | self.change_commandline("a","") |
---|
| 1286 | |
---|
[4482] | 1287 | # Create a new (empty) job |
---|
| 1288 | def create_new_job(self): |
---|
| 1289 | |
---|
| 1290 | self.setEnabled(False) |
---|
| 1291 | |
---|
[4670] | 1292 | text, ret = QtWidgets.QInputDialog.getText(self, "Create new job", "Enter new job name:", QtWidgets.QLineEdit.Normal, text = '') |
---|
[4482] | 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) ): |
---|
[4670] | 1304 | notify = QtWidgets.QMessageBox.warning(self,'Create new job directory',"Error. Could not create job directory. A job with the new name already exists.") |
---|
[4482] | 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 | |
---|
[4405] | 1331 | # Make a copy of a job |
---|
| 1332 | def copy_job(self): |
---|
[4670] | 1333 | |
---|
[4405] | 1334 | self.setEnabled(False) |
---|
| 1335 | old_job_name = self.list_jobs.currentItem().text() |
---|
| 1336 | |
---|
[4670] | 1337 | text, ret = QtWidgets.QInputDialog.getText(self, "Copy job", "Enter new job name:", QtWidgets.QLineEdit.Normal, text = old_job_name) |
---|
[4405] | 1338 | if ( ret ): |
---|
| 1339 | new_job_name = str(text) |
---|
| 1340 | else: |
---|
[4670] | 1341 | self.setEnabled(True) |
---|
| 1342 | return |
---|
| 1343 | |
---|
[4405] | 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) ): |
---|
[4670] | 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 |
---|
[4405] | 1351 | else: |
---|
[4670] | 1352 | os.makedirs(new_input_dir) |
---|
[4405] | 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) |
---|
[4482] | 1360 | |
---|
[4405] | 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" |
---|
[4482] | 1371 | |
---|
[4405] | 1372 | # check if user code exists in the new job directory |
---|
| 1373 | if ( os.path.isdir(new_user_dir) ): |
---|
[4670] | 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 |
---|
[4405] | 1377 | else: |
---|
[4670] | 1378 | os.makedirs(new_user_dir) |
---|
[4405] | 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) ): |
---|
[4670] | 1425 | notify = QtWidgets.QMessageBox.warning(self,'Create new job directory',"Error. Could not create job directory. A job with the new name already exists.") |
---|
[4405] | 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" |
---|
[4670] | 1446 | |
---|
[4405] | 1447 | # check if user code exists in the new job directory |
---|
| 1448 | if ( os.path.isdir(new_user_dir) ): |
---|
[4670] | 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 |
---|
[4405] | 1452 | else: |
---|
[4670] | 1453 | os.makedirs(new_user_dir) |
---|
[4405] | 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 = [] |
---|
[4470] | 1477 | |
---|
| 1478 | |
---|
| 1479 | # Add a custom context menu for the job selection list |
---|
| 1480 | def openmenujob(self, position): |
---|
| 1481 | |
---|
[4670] | 1482 | menu = QtWidgets.QMenu() |
---|
[4470] | 1483 | |
---|
[4482] | 1484 | |
---|
[4670] | 1485 | newAction = QtWidgets.QAction('Create new job', self) |
---|
[4482] | 1486 | newAction.triggered.connect(self.create_new_job) |
---|
| 1487 | menu.addAction(newAction) |
---|
[4470] | 1488 | selection = self.list_jobs.selectedItems() |
---|
| 1489 | |
---|
| 1490 | if ( len(selection) != 0 ): |
---|
| 1491 | |
---|
[4482] | 1492 | |
---|
[4670] | 1493 | copyAction = QtWidgets.QAction('Copy job', self) |
---|
[4470] | 1494 | copyAction.triggered.connect(self.copy_job) |
---|
[4670] | 1495 | createAction = QtWidgets.QAction('Create set from job', self) |
---|
[4470] | 1496 | createAction.triggered.connect(self.create_set) |
---|
[4670] | 1497 | delAction = QtWidgets.QAction('Delete job', self) |
---|
[4470] | 1498 | delAction.triggered.connect(self.DeleteJob) |
---|
| 1499 | |
---|
| 1500 | menu.addAction(copyAction) |
---|
| 1501 | menu.addAction(createAction) |
---|
| 1502 | menu.addAction(delAction) |
---|
| 1503 | |
---|
[4482] | 1504 | action = menu.exec_(self.list_jobs.mapToGlobal(position)) |
---|
| 1505 | |
---|
[4405] | 1506 | # Add a custom context menu |
---|
| 1507 | def openmenuinput(self, position): |
---|
| 1508 | |
---|
[4670] | 1509 | menu = QtWidgets.QMenu() |
---|
[4405] | 1510 | |
---|
| 1511 | selection = self.list_input.selectedItems() |
---|
[2413] | 1512 | |
---|
[4405] | 1513 | if ( len(selection) != 0 ): |
---|
[2413] | 1514 | |
---|
[4470] | 1515 | |
---|
[4670] | 1516 | openAction = QtWidgets.QAction('Open file(s)', self) |
---|
[4405] | 1517 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
| 1518 | openAction.triggered.connect(self.OpenFilesInput) |
---|
[4470] | 1519 | |
---|
| 1520 | |
---|
[4670] | 1521 | delAction = QtWidgets.QAction('Delete selected file(s)', self) |
---|
[4470] | 1522 | delAction.triggered.connect(self.DeleteFilesInput) |
---|
| 1523 | |
---|
| 1524 | menu.addAction(openAction) |
---|
| 1525 | menu.addAction(delAction) |
---|
| 1526 | |
---|
[4670] | 1527 | delallAction = QtWidgets.QAction('Delete all files', self) |
---|
[4482] | 1528 | delallAction.triggered.connect(self.DeleteAllFilesInput) |
---|
| 1529 | menu.addAction(delallAction) |
---|
[4405] | 1530 | |
---|
[4482] | 1531 | action = menu.exec_(self.list_input.mapToGlobal(position)) |
---|
| 1532 | |
---|
[4405] | 1533 | # Add a custom context menu |
---|
| 1534 | def openmenuuser(self, position): |
---|
| 1535 | |
---|
[4670] | 1536 | menu = QtWidgets.QMenu() |
---|
[4405] | 1537 | |
---|
| 1538 | selection = self.list_user.selectedItems() |
---|
| 1539 | |
---|
| 1540 | if ( len(selection) != 0 ): |
---|
| 1541 | |
---|
[4670] | 1542 | openAction = QtWidgets.QAction('Open file(s)', self) |
---|
[4405] | 1543 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
| 1544 | openAction.triggered.connect(self.OpenFilesUser) |
---|
[4470] | 1545 | |
---|
| 1546 | |
---|
[4670] | 1547 | delAction = QtWidgets.QAction('Delete file(s)', self) |
---|
[4470] | 1548 | delAction.triggered.connect(self.DeleteFilesUser) |
---|
| 1549 | |
---|
| 1550 | menu.addAction(openAction) |
---|
| 1551 | menu.addAction(delAction) |
---|
[4405] | 1552 | |
---|
[4670] | 1553 | delallAction = QtWidgets.QAction('Delete all files', self) |
---|
[4482] | 1554 | delallAction.triggered.connect(self.DeleteAllFilesUser) |
---|
| 1555 | menu.addAction(delallAction) |
---|
| 1556 | |
---|
| 1557 | action = menu.exec_(self.list_user.mapToGlobal(position)) |
---|
| 1558 | |
---|
[4405] | 1559 | # Add a custom context menu |
---|
| 1560 | def openmenuoutput(self, position): |
---|
| 1561 | |
---|
[4670] | 1562 | menu = QtWidgets.QMenu() |
---|
[4405] | 1563 | |
---|
| 1564 | selection = self.list_output.selectedItems() |
---|
[4482] | 1565 | |
---|
[4405] | 1566 | if ( len(selection) != 0 ): |
---|
| 1567 | |
---|
[4670] | 1568 | openAction = QtWidgets.QAction('Open file(s)', self) |
---|
[4405] | 1569 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
| 1570 | openAction.triggered.connect(self.OpenFilesOutput) |
---|
[4470] | 1571 | |
---|
[4670] | 1572 | delAction = QtWidgets.QAction('Delete file(s)', self) |
---|
[4470] | 1573 | delAction.triggered.connect(self.DeleteFilesOutput) |
---|
| 1574 | |
---|
[4482] | 1575 | |
---|
| 1576 | |
---|
[4470] | 1577 | menu.addAction(openAction) |
---|
| 1578 | menu.addAction(delAction) |
---|
[4405] | 1579 | |
---|
[4670] | 1580 | delallAction = QtWidgets.QAction('Delete all files', self) |
---|
[4482] | 1581 | delallAction.triggered.connect(self.DeleteAllFilesOutput) |
---|
| 1582 | menu.addAction(delallAction) |
---|
| 1583 | |
---|
| 1584 | action = menu.exec_(self.list_output.mapToGlobal(position)) |
---|
| 1585 | |
---|
[4405] | 1586 | # Add a custom context menu |
---|
| 1587 | def openmenumonitoring(self, position): |
---|
| 1588 | |
---|
[4670] | 1589 | menu = QtWidgets.QMenu() |
---|
[4405] | 1590 | |
---|
| 1591 | selection = self.list_monitoring.selectedItems() |
---|
| 1592 | |
---|
| 1593 | if ( len(selection) != 0 ): |
---|
| 1594 | |
---|
[4670] | 1595 | openAction = QtWidgets.QAction('Open file(s)', self) |
---|
[4405] | 1596 | openAction.setStatusTip('Open file(s) in your favorite editor') |
---|
| 1597 | openAction.triggered.connect(self.OpenFilesMonitoring) |
---|
[4470] | 1598 | |
---|
[4670] | 1599 | delAction = QtWidgets.QAction('Delete file(s)', self) |
---|
[4470] | 1600 | delAction.triggered.connect(self.DeleteFilesMonitoring) |
---|
| 1601 | |
---|
[4482] | 1602 | |
---|
| 1603 | |
---|
[4470] | 1604 | menu.addAction(openAction) |
---|
| 1605 | menu.addAction(delAction) |
---|
[4405] | 1606 | |
---|
[4670] | 1607 | delallAction = QtWidgets.QAction('Delete all files', self) |
---|
[4482] | 1608 | delallAction.triggered.connect(self.DeleteAllFilesMonitoring) |
---|
| 1609 | menu.addAction(delallAction) |
---|
| 1610 | |
---|
| 1611 | action = menu.exec_(self.list_monitoring.mapToGlobal(position)) |
---|
| 1612 | |
---|
[4470] | 1613 | def OpenConfig(self): |
---|
| 1614 | |
---|
[4670] | 1615 | config = str(self.group_execution.findChild(QtWidgets.QComboBox, "combo_configuration").currentText()) |
---|
[4470] | 1616 | if ( config != "" ): |
---|
| 1617 | filename = ".palm.config." + config |
---|
| 1618 | open_file = "xdg-open " + filename |
---|
| 1619 | os.system(str(open_file)) |
---|
| 1620 | |
---|
[4405] | 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)): |
---|
[4470] | 1630 | open_files = open_files + "xdg-open " + input_dir + sel_files[i].text().split("(")[0] + "; " |
---|
[4405] | 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)): |
---|
[4470] | 1657 | open_files = open_files + "xdg-open " + input_dir + sel_files[i].text().split("(")[0] + "; " |
---|
[4405] | 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)): |
---|
[4470] | 1671 | open_files = open_files + "xdg-open " + input_dir + sel_files[i].text().split("(")[0] + "; " |
---|
[4405] | 1672 | |
---|
| 1673 | os.system(str(open_files)) |
---|
| 1674 | selection = self.list_jobs.selectedItems() |
---|
[4470] | 1675 | |
---|
| 1676 | def DeleteFilesInput(self): |
---|
| 1677 | |
---|
[4670] | 1678 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
[4470] | 1679 | |
---|
[4670] | 1680 | if status == QtWidgets.QMessageBox.Yes: |
---|
[4470] | 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)): |
---|
[4670] | 1688 | filename = input_dir + sel_files[i].text().split("(")[0].strip() |
---|
[4470] | 1689 | os.remove(filename) |
---|
| 1690 | |
---|
| 1691 | self.update_all() |
---|
| 1692 | |
---|
| 1693 | |
---|
| 1694 | def DeleteFilesUser(self): |
---|
| 1695 | |
---|
[4670] | 1696 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
[4470] | 1697 | |
---|
[4670] | 1698 | if status == QtWidgets.QMessageBox.Yes: |
---|
[4470] | 1699 | |
---|
| 1700 | sel_job = self.list_jobs.currentItem().text() |
---|
| 1701 | sel_files = self.list_user.selectedItems() |
---|
| 1702 | |
---|
[4481] | 1703 | input_dir = job_dir + "/" + sel_job + "/USER_CODE/" |
---|
[4470] | 1704 | |
---|
| 1705 | for i in range(0,len(sel_files)): |
---|
[4670] | 1706 | filename = input_dir + sel_files[i].text().split("(")[0].strip() |
---|
[4470] | 1707 | os.remove(filename) |
---|
| 1708 | |
---|
| 1709 | self.update_all() |
---|
| 1710 | |
---|
| 1711 | |
---|
| 1712 | def DeleteFilesMonitoring(self): |
---|
| 1713 | |
---|
[4670] | 1714 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
[4470] | 1715 | |
---|
[4670] | 1716 | if status == QtWidgets.QMessageBox.Yes: |
---|
[4470] | 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)): |
---|
[4670] | 1724 | filename = input_dir + sel_files[i].text().split("(")[0].strip() |
---|
[4470] | 1725 | os.remove(filename) |
---|
| 1726 | |
---|
| 1727 | self.update_all() |
---|
| 1728 | |
---|
| 1729 | |
---|
| 1730 | def DeleteFilesOutput(self): |
---|
| 1731 | |
---|
[4670] | 1732 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
[4470] | 1733 | |
---|
[4670] | 1734 | if status == QtWidgets.QMessageBox.Yes: |
---|
[4470] | 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)): |
---|
[4670] | 1742 | filename = input_dir + sel_files[i].text().split("(")[0].strip() |
---|
[4470] | 1743 | os.remove(filename) |
---|
| 1744 | |
---|
| 1745 | self.update_all() |
---|
| 1746 | |
---|
[4482] | 1747 | |
---|
| 1748 | def DeleteAllFilesInput(self): |
---|
| 1749 | |
---|
[4670] | 1750 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
[4482] | 1751 | |
---|
[4670] | 1752 | if status == QtWidgets.QMessageBox.Yes: |
---|
[4482] | 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 | |
---|
[4670] | 1770 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
[4482] | 1771 | |
---|
[4670] | 1772 | if status == QtWidgets.QMessageBox.Yes: |
---|
[4482] | 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 | |
---|
[4670] | 1791 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
[4482] | 1792 | |
---|
[4670] | 1793 | if status == QtWidgets.QMessageBox.Yes: |
---|
[4482] | 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 | |
---|
[4670] | 1812 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete all files?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
[4482] | 1813 | |
---|
[4670] | 1814 | if status == QtWidgets.QMessageBox.Yes: |
---|
[4482] | 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 | |
---|
[4470] | 1831 | def DeleteJob(self): |
---|
| 1832 | |
---|
[4670] | 1833 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete this job?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
[4470] | 1834 | |
---|
[4670] | 1835 | if status == QtWidgets.QMessageBox.Yes: |
---|
[4470] | 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 | |
---|
[4405] | 1844 | # Message box for showing RUN_CONTROL output |
---|
[4670] | 1845 | class CreateSetBox(QtWidgets.QDialog): |
---|
[4405] | 1846 | def __init__(self): |
---|
[4470] | 1847 | |
---|
[4405] | 1848 | super(CreateSetBox, self).__init__() |
---|
[4470] | 1849 | |
---|
[4405] | 1850 | uic.loadUi(palm_bin + '/palmrungui_files/create_set.ui', self) |
---|
[4470] | 1851 | |
---|
[4405] | 1852 | self.show() |
---|
[4470] | 1853 | |
---|
[4405] | 1854 | return |
---|
| 1855 | |
---|
| 1856 | # Cancel button |
---|
| 1857 | def rejected(self): |
---|
[4470] | 1858 | |
---|
[4405] | 1859 | self.close() |
---|
[4470] | 1860 | |
---|
[4405] | 1861 | return |
---|
| 1862 | |
---|
| 1863 | # OK button |
---|
| 1864 | def accept(self): |
---|
[4470] | 1865 | |
---|
[4405] | 1866 | global set_list |
---|
[4470] | 1867 | |
---|
[4405] | 1868 | text = self.list.toPlainText() |
---|
| 1869 | set_list = text.split('\n') |
---|
| 1870 | self.close() |
---|
[4470] | 1871 | |
---|
[4405] | 1872 | return |
---|
| 1873 | |
---|
[4470] | 1874 | # Message box for showing RUN_CONTROL output |
---|
[4670] | 1875 | class OpenHistoryBox(QtWidgets.QDialog): |
---|
[4470] | 1876 | def __init__(self): |
---|
[4405] | 1877 | |
---|
[4470] | 1878 | super(OpenHistoryBox, self).__init__() |
---|
[4405] | 1879 | |
---|
[4470] | 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 | |
---|
[4670] | 1892 | list_jobname = self.findChild(QtWidgets.QListWidget,"list_history") |
---|
[4470] | 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 | |
---|
[4481] | 1926 | global history_entry |
---|
| 1927 | history_entry = "" |
---|
[4470] | 1928 | self.close() |
---|
| 1929 | |
---|
| 1930 | return |
---|
| 1931 | |
---|
| 1932 | # Clear history |
---|
| 1933 | def ClearHistory(self): |
---|
| 1934 | |
---|
[4670] | 1935 | status = QtWidgets.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete your history?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) |
---|
[4470] | 1936 | |
---|
[4670] | 1937 | if status == QtWidgets.QMessageBox.Yes: |
---|
[4470] | 1938 | |
---|
| 1939 | if os.path.exists(palm_dir + "/.palmrungui.history"): |
---|
| 1940 | os.remove(palm_dir + "/.palmrungui.history") |
---|
| 1941 | |
---|
| 1942 | |
---|
| 1943 | return |
---|
| 1944 | |
---|
[2413] | 1945 | if __name__ == "__main__": |
---|
[4670] | 1946 | app = QtWidgets.QApplication(sys.argv) |
---|
[2413] | 1947 | window = Mainwindow() |
---|
| 1948 | window.show() |
---|
[2825] | 1949 | sys.exit(app.exec_()) |
---|