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