[2825] | 1 | #!/usr/bin/env python |
---|
[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 | # |
---|
[2718] | 17 | # Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
[2413] | 18 | #--------------------------------------------------------------------------------# |
---|
| 19 | # |
---|
| 20 | # Current revisions: |
---|
| 21 | # ----------------- |
---|
| 22 | # |
---|
| 23 | # |
---|
| 24 | # Former revisions: |
---|
| 25 | # ----------------- |
---|
| 26 | # $Id: palmrungui 2825 2018-02-20 21:48:27Z eckhard $ |
---|
[2825] | 27 | # Adjusted to work with newest version of palmrun |
---|
| 28 | # |
---|
| 29 | # 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 30 | # Corrected "Former revisions" section |
---|
| 31 | # |
---|
| 32 | # 2696 2017-12-14 17:12:51Z kanani |
---|
| 33 | # Change in file header (GPL part) |
---|
| 34 | # |
---|
| 35 | # 2484 2017-09-20 14:22:42Z maronga |
---|
[2484] | 36 | # Added PALM logo |
---|
| 37 | # |
---|
| 38 | # 2480 2017-09-19 06:24:14Z maronga |
---|
[2480] | 39 | # option -A (project account number) added |
---|
| 40 | # |
---|
| 41 | # 2477 2017-09-18 08:42:29Z maronga |
---|
[2477] | 42 | # Renamed restart run appendix from "f" to "r". Bugfix for displaying restart runs.> |
---|
| 43 | # Revised list of recently submitted jobs |
---|
| 44 | # |
---|
| 45 | # 2413 2017-09-06 12:48:29Z maronga |
---|
[2413] | 46 | # Renamed to palmrungui and adapted for use with palmrun instead of mrun. |
---|
| 47 | # |
---|
| 48 | # 2316 2017-07-20 07:53:42Z maronga |
---|
| 49 | # Initial revision in python |
---|
| 50 | # |
---|
| 51 | # |
---|
| 52 | # |
---|
| 53 | # Description: |
---|
| 54 | # ------------ |
---|
| 55 | # Graphical user interface for the palmrun script. |
---|
| 56 | # @author Felix Gaschler |
---|
| 57 | # @author Björn Maronga (maronga@muk.uni-hannover.de) |
---|
| 58 | # |
---|
| 59 | # Instructions: |
---|
| 60 | # ------------- |
---|
| 61 | # |
---|
| 62 | #------------------------------------------------------------------------------! |
---|
| 63 | |
---|
| 64 | import sys |
---|
| 65 | import subprocess |
---|
| 66 | from PyQt4 import QtCore, QtGui, uic |
---|
| 67 | from PyQt4.QtCore import QProcess |
---|
| 68 | from time import strftime |
---|
| 69 | import os |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | # Determine PALM directories |
---|
| 73 | try: |
---|
| 74 | devnull = open(os.devnull, 'w') |
---|
| 75 | out = subprocess.check_output("echo $PALM_BIN", shell=True, stderr=subprocess.STDOUT) |
---|
| 76 | palm_bin = out.rstrip() |
---|
| 77 | palm_dir = out.split("palm")[0] + "palm/" + out.split("palm")[1].split("/")[1] |
---|
| 78 | out = None |
---|
| 79 | except: |
---|
| 80 | print "Error. $PALM_BIN is not set." |
---|
| 81 | raise SystemExit |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | palmrunline = "" |
---|
| 85 | name_of_file = os.path.basename(__file__) |
---|
| 86 | |
---|
| 87 | palmrungui_path = os.path.realpath(__file__) |
---|
| 88 | version_path = palmrungui_path[:len(palmrungui_path)-14-len(name_of_file)-1] |
---|
| 89 | |
---|
| 90 | Ui_MainWindow = uic.loadUiType("%s/palmrungui_files/mainwindow.ui" % (palm_bin))[0] |
---|
| 91 | Ui_helpDialog = uic.loadUiType("%s/palmrungui_files/help.ui" % (palm_bin))[0] |
---|
| 92 | Ui_aboutDialog = uic.loadUiType("%s/palmrungui_files/about.ui" % (palm_bin))[0] |
---|
| 93 | |
---|
| 94 | class HelpDialog(QtGui.QDialog,Ui_helpDialog): |
---|
| 95 | def __init__(self, parent=None): |
---|
| 96 | super(HelpDialog,self).__init__() |
---|
| 97 | self.setupUi(self) |
---|
| 98 | |
---|
| 99 | class AboutDialog(QtGui.QDialog,Ui_aboutDialog): |
---|
| 100 | def __init__(self, parent=None): |
---|
| 101 | super(AboutDialog,self).__init__() |
---|
| 102 | self.setupUi(self) |
---|
| 103 | |
---|
| 104 | class Mainwindow(QtGui.QMainWindow, Ui_MainWindow): |
---|
| 105 | def __init__(self, parent=None): |
---|
| 106 | super(Mainwindow, self).__init__() |
---|
[2484] | 107 | self.setupUi(self) |
---|
[2413] | 108 | |
---|
[2484] | 109 | self.palm_logo.setPixmap(QtGui.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png")) |
---|
| 110 | |
---|
[2477] | 111 | self.recent_jobs(50) |
---|
[2413] | 112 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
| 113 | commandline.setText("") |
---|
| 114 | |
---|
| 115 | self.tabWidget.setCurrentIndex(0) |
---|
| 116 | |
---|
[2484] | 117 | |
---|
[2413] | 118 | filename = "%s/.palmrun.gui.default" % (version_path) |
---|
| 119 | if os.path.exists(filename): |
---|
| 120 | pass |
---|
| 121 | else: |
---|
| 122 | return |
---|
| 123 | |
---|
| 124 | file = open(filename, "r") |
---|
| 125 | if ( file is not None ): |
---|
| 126 | # File opened successfully |
---|
| 127 | palmrunline = file.readline() |
---|
| 128 | #if neue zeile zeichen |
---|
| 129 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
| 130 | file.close() |
---|
| 131 | |
---|
| 132 | # In case a palmrunline was found, load it to mainwindow |
---|
| 133 | if ( palmrunline != ""): |
---|
| 134 | palmrunline = palmrunline[17:] |
---|
| 135 | commandline.setText(palmrunline) |
---|
| 136 | self.setup_gui(palmrunline) |
---|
| 137 | |
---|
| 138 | |
---|
| 139 | # starts xterm with palmrun commandline |
---|
| 140 | ####################################### |
---|
| 141 | def startpalmrun(self): |
---|
| 142 | palmrunline = str(self.groupBox.findChild(QtGui.QLineEdit,"commandline").text()) |
---|
| 143 | userline = str(self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text()) |
---|
| 144 | |
---|
| 145 | # Check for empty line |
---|
| 146 | palmrunline_save = palmrunline; |
---|
| 147 | if (userline != ""): |
---|
| 148 | palmrunline = "%s %s" % (palmrunline,userline) |
---|
| 149 | history_line = palmrunline |
---|
| 150 | |
---|
| 151 | # Disable the main window |
---|
| 152 | self.tabWidget.setEnabled(False) |
---|
| 153 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False) |
---|
| 154 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("wait...") |
---|
| 155 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText("Executing palmrun in xterm...") |
---|
| 156 | |
---|
| 157 | # Wait until all commands have been executed (ugly) ? |
---|
| 158 | #for i in range(0,21): |
---|
| 159 | # qApp->processEvents() |
---|
| 160 | |
---|
| 161 | # Start xterm as QProcess |
---|
| 162 | palmrun = QProcess() |
---|
| 163 | palmrun.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels |
---|
| 164 | palmrun.setWorkingDirectory(version_path) |
---|
| 165 | |
---|
| 166 | geomet = self.frameGeometry() |
---|
| 167 | |
---|
| 168 | posx = geomet.x()+geomet.width() |
---|
| 169 | posy = geomet.y() |
---|
| 170 | |
---|
| 171 | s = " -title \"Executing palmrun...\" -fa \"Monospace\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy) |
---|
| 172 | palmrunline = "%s%s;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmrunline.replace("\"","\'")) |
---|
| 173 | |
---|
| 174 | mString = "xterm %s" % (palmrunline) |
---|
| 175 | palmrun.start(mString); |
---|
| 176 | |
---|
| 177 | if( palmrun.waitForStarted() is False ): |
---|
| 178 | return |
---|
| 179 | |
---|
| 180 | # Wait until palmrun has finished or wait for 200 minutes |
---|
| 181 | palmrun.waitForFinished(3600000); |
---|
| 182 | |
---|
| 183 | # Jobs has been submitted or aborted. Continuing... |
---|
| 184 | # Save the palmrun command to history file |
---|
| 185 | filename = "%s/.palm.history" % (version_path) |
---|
| 186 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
| 187 | |
---|
| 188 | file = open(filename,"a") |
---|
| 189 | s = "%s %s\n" % (tmstamp,history_line) |
---|
| 190 | file.write(s) |
---|
| 191 | file.close() |
---|
| 192 | |
---|
| 193 | # Enable main window again |
---|
| 194 | self.tabWidget.setEnabled(True) |
---|
| 195 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True) |
---|
| 196 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("Start palmrun") |
---|
| 197 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline_save); |
---|
| 198 | |
---|
| 199 | # Reload recent jobs |
---|
[2477] | 200 | self.recent_jobs(50) |
---|
[2413] | 201 | |
---|
| 202 | |
---|
| 203 | # loads recent jobs |
---|
| 204 | ###################################### |
---|
| 205 | def recent_jobs(self, number): |
---|
| 206 | fileDir = "%s/.palm.history" % (version_path) |
---|
| 207 | if os.path.exists(fileDir): |
---|
| 208 | pass |
---|
| 209 | else: |
---|
| 210 | return |
---|
| 211 | |
---|
| 212 | file = open(fileDir,"r") |
---|
| 213 | history = file.readlines() |
---|
| 214 | tmphistory = list() |
---|
| 215 | file.close(); |
---|
| 216 | j = 0; |
---|
| 217 | |
---|
| 218 | list_jobname = self.group_job.findChild(QtGui.QListWidget,"list_jobname") |
---|
| 219 | list_jobname.clear() |
---|
| 220 | |
---|
| 221 | # Read history entries and append to recent job list |
---|
| 222 | i=len(history)-1 |
---|
| 223 | count = 0 |
---|
[2477] | 224 | while i>=0 and count<number: |
---|
[2413] | 225 | timestamp = history[i][:16] |
---|
| 226 | listitem = history[i][17:len(history[i])-1] |
---|
| 227 | matchitems = list_jobname.findItems(listitem, QtCore.Qt.MatchExactly) |
---|
| 228 | |
---|
| 229 | if ( len(matchitems) == 0 ): |
---|
[2477] | 230 | listitem = filter(None,listitem.split(" -d"))[1] |
---|
| 231 | listitem = filter(None,listitem.split(" -"))[0] |
---|
| 232 | listitem = listitem.replace(" ",""); |
---|
[2413] | 233 | list_jobname.addItem(listitem); |
---|
| 234 | s = "%s (%s)" % (listitem,timestamp) |
---|
| 235 | tmphistory.append(s); |
---|
| 236 | count = count +1 |
---|
| 237 | j = j+1 |
---|
| 238 | |
---|
| 239 | if ( j == number ): |
---|
| 240 | break |
---|
| 241 | i = i-1 |
---|
| 242 | |
---|
| 243 | # Send to list |
---|
| 244 | list_jobname.clear(); |
---|
| 245 | |
---|
| 246 | i=0 |
---|
| 247 | while i<len(tmphistory): |
---|
| 248 | list_jobname.addItem(tmphistory[i]); |
---|
| 249 | i = i+1 |
---|
| 250 | |
---|
| 251 | |
---|
| 252 | # Enables coupled settings |
---|
| 253 | ############################### |
---|
| 254 | def enable_coupled(self): |
---|
| 255 | coupledState = self.group_job.findChild(QtGui.QComboBox, "drop_job").currentText() |
---|
| 256 | group = self.group_execution.findChild(QtGui.QGroupBox, "group_coupled") |
---|
| 257 | |
---|
| 258 | if (coupledState == "Restart run (coupled atmosphere ocean)" or coupledState == "Initial run (coupled atmosphere ocean)"): |
---|
| 259 | self.group_coupled.setEnabled(True) |
---|
| 260 | else: |
---|
| 261 | self.group_coupled.setEnabled(False) |
---|
| 262 | |
---|
| 263 | |
---|
| 264 | # select a job via "select"-button |
---|
| 265 | ################################ |
---|
| 266 | def choosejob(self): |
---|
| 267 | jobDir = "%s/JOBS" % (version_path) |
---|
| 268 | |
---|
| 269 | # Pick a job from dialog |
---|
| 270 | filename = QtGui.QFileDialog.getExistingDirectory(self, "Open a folder", jobDir, QtGui.QFileDialog.ShowDirsOnly) |
---|
| 271 | |
---|
| 272 | # If a file was selected, load it into mainwindow |
---|
| 273 | if ( filename != ""): |
---|
| 274 | jobname = os.path.basename(unicode(filename)) |
---|
| 275 | self.group_job.findChild(QtGui.QLineEdit,"line_jobname").setText(jobname) |
---|
| 276 | self.group_job.findChild(QtGui.QListWidget,"list_jobname").clearSelection() |
---|
| 277 | |
---|
| 278 | # Change palmrunline accordingly |
---|
| 279 | self.change_commandline("d","") |
---|
| 280 | self.change_commandline("a","") |
---|
| 281 | return |
---|
| 282 | else: |
---|
| 283 | return |
---|
| 284 | |
---|
| 285 | |
---|
[2477] | 286 | # select a job via click from list |
---|
[2413] | 287 | ################################# |
---|
| 288 | def choosejob_list(self): |
---|
| 289 | # Get selected item from list |
---|
| 290 | list_jobname = self.group_job.findChild(QtGui.QListWidget,"list_jobname") |
---|
| 291 | filename = str(list_jobname.currentItem().text()) |
---|
| 292 | itemint = list_jobname.currentRow() |
---|
| 293 | |
---|
| 294 | # Reload list |
---|
| 295 | self.setupUi(self) |
---|
[2477] | 296 | self.recent_jobs(50) |
---|
[2413] | 297 | |
---|
| 298 | # Set selected item to jobname |
---|
| 299 | list_jobname.item(itemint).setSelected(True); |
---|
| 300 | |
---|
| 301 | timestamp = filename[len(filename)-17:][:16] |
---|
| 302 | jobname = filename[:len(filename) - 19]; |
---|
| 303 | |
---|
| 304 | fileDir = "%s/.palm.history" % (version_path) |
---|
| 305 | file = open(fileDir,"r") |
---|
| 306 | history = file.readlines() |
---|
| 307 | tmphistory = list() |
---|
| 308 | file.close(); |
---|
| 309 | |
---|
| 310 | i = len(history) |
---|
| 311 | while i>=1: |
---|
| 312 | listitem = history[i-1][17:len(history[i-1])-1] |
---|
| 313 | listitem = filter(None,listitem.split(" -d"))[1] |
---|
| 314 | listitem = filter(None,listitem.split(" -"))[0] |
---|
| 315 | listitem = listitem.replace(" ",""); |
---|
| 316 | |
---|
| 317 | # Select command line with correct timestamp and jobname |
---|
| 318 | if (history[i-1][:16] == timestamp and listitem == jobname): |
---|
| 319 | palmrunline = history[i-1] |
---|
| 320 | palmrunline = palmrunline[17:] |
---|
| 321 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
| 322 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline); |
---|
| 323 | self.setup_gui(palmrunline); |
---|
[2477] | 324 | self.list_jobname.item(itemint).setSelected(True); |
---|
| 325 | |
---|
[2413] | 326 | return |
---|
| 327 | i = i-1 |
---|
| 328 | |
---|
| 329 | # Change run identifer (initial, restart, coupled...) |
---|
| 330 | ###################################################### |
---|
| 331 | def change_rc_list(self): |
---|
| 332 | drop_job = self.group_job.findChild(QtGui.QComboBox,"drop_job").currentText() |
---|
| 333 | self.change_commandline("a","") |
---|
| 334 | |
---|
| 335 | # Enable PE distribution for atmosphere/ocean |
---|
| 336 | if ( drop_job == "Restart run (coupled atmosphere ocean)" or drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
| 337 | drop_atmos = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").text() |
---|
| 338 | drop_ocean = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").text() |
---|
| 339 | s = "%s %s" % (drop_atmos,drop_ocean) |
---|
| 340 | self.change_commandline("Y",s) |
---|
| 341 | |
---|
| 342 | |
---|
| 343 | if ( drop_job == "Restart run" or drop_job == "Restart run (coupled atmosphere ocean)"): |
---|
| 344 | self.change_commandline("d","") |
---|
| 345 | |
---|
| 346 | # Check of ocean runs |
---|
| 347 | else: |
---|
| 348 | self.delete_commandline("Y") |
---|
| 349 | if (drop_job == "Precursor run (ocean)"): |
---|
| 350 | self.activate_flag("y") |
---|
| 351 | else: |
---|
| 352 | self.deactivate_flag("y") |
---|
| 353 | |
---|
| 354 | # changes commandline depending on parameters |
---|
| 355 | ########################################################## |
---|
| 356 | def change_commandline(self, id_str, fwt_str): |
---|
| 357 | fwt_str = str(fwt_str) |
---|
| 358 | initialize = False |
---|
| 359 | palmrunline = str(self.groupBox.findChild(QtGui.QLineEdit,"commandline").text()) |
---|
| 360 | s = " -%s " % (id_str) |
---|
| 361 | splitline = filter(None,palmrunline.split(s)) |
---|
| 362 | |
---|
| 363 | if ( len(splitline) == 0 ): |
---|
| 364 | splitline.append("palmrun") |
---|
| 365 | splitline.append(" ") |
---|
| 366 | initialize = True |
---|
| 367 | |
---|
| 368 | elif ( len(splitline) == 1 ): |
---|
| 369 | splitline.append(" ") |
---|
| 370 | |
---|
| 371 | param = splitline[1].split("-") |
---|
| 372 | |
---|
| 373 | # Change in parameter "d" (jobname) |
---|
| 374 | if (id_str == "d"): |
---|
| 375 | filename = str(self.group_job.findChild(QtGui.QLineEdit,"line_jobname").text()) |
---|
| 376 | s = filename.split("JOBS/") |
---|
| 377 | param[0] = s[len(s)-1] |
---|
| 378 | |
---|
| 379 | if ( initialize == True ):#and self.group_runcontrol.isEnabled() == True ): |
---|
| 380 | self.group_execution.setEnabled(True) |
---|
| 381 | self.group_job.findChild(QtGui.QComboBox,"drop_job").setEnabled(True) |
---|
| 382 | self.group_advanced.setEnabled(True) |
---|
| 383 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True) |
---|
| 384 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(True) |
---|
| 385 | |
---|
| 386 | elif ( param[0] == ""): |
---|
| 387 | self.group_execution.setEnabled(False) |
---|
| 388 | self.group_job.findChild(QtGui.QComboBox,"drop_job").setEnabled(False) |
---|
| 389 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False) |
---|
| 390 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(False) |
---|
| 391 | self.group_advanced.setEnabled(False) |
---|
| 392 | self.delete_commandline("d") |
---|
| 393 | self.change_commandline("a","remove") |
---|
| 394 | self.group_job.findChild(QtGui.QLabel,"label_usercode").setText("") |
---|
| 395 | return 1 |
---|
| 396 | |
---|
| 397 | else: |
---|
| 398 | # Check if user code is available |
---|
[2477] | 399 | usercode = "%s/JOBS/%s/USER_CODE" % (version_path,param[0]) |
---|
| 400 | |
---|
[2413] | 401 | if (os.path.exists(usercode) is True): |
---|
| 402 | self.group_job.findChild(QtGui.QLabel,"label_usercode").setText("<font color='green'>User code found.</font>") |
---|
| 403 | |
---|
| 404 | else: |
---|
| 405 | self.group_job.findChild(QtGui.QLabel,"label_usercode").setText("<font color='red'>Warning: no user code found!</font>") |
---|
| 406 | |
---|
| 407 | |
---|
| 408 | # Check if _pdf file is available, otherwise notice user |
---|
| 409 | drop_job = self.group_job.findChild(QtGui.QComboBox,"drop_job").currentText() |
---|
| 410 | if ( self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").checkState() == 2 or |
---|
| 411 | drop_job == "Restart run" or drop_job == "Restart run (coupled atmosphere ocean)" ): |
---|
| 412 | |
---|
| 413 | jobname = self.group_job.findChild(QtGui.QLineEdit, "line_jobname").text() |
---|
[2477] | 414 | restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (version_path,jobname,jobname) |
---|
[2413] | 415 | |
---|
| 416 | if (os.path.exists(restartfile) == True): |
---|
| 417 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
| 418 | |
---|
| 419 | |
---|
| 420 | if ( drop_job == "Restart run (coupled atmosphere ocean)" ): |
---|
[2477] | 421 | restartfileo = "%s/JOBS/%s/INPUT/%s_p3dor" % (version_path,jobname,jobname) |
---|
[2413] | 422 | if (os.path.exists(restartfileo) == True): |
---|
| 423 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("hooo") |
---|
| 424 | |
---|
| 425 | else: |
---|
[2477] | 426 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dor file found!</font>") |
---|
[2413] | 427 | |
---|
| 428 | else: |
---|
[2477] | 429 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>") |
---|
[2413] | 430 | |
---|
| 431 | |
---|
| 432 | |
---|
| 433 | self.group_execution.setEnabled(True) |
---|
| 434 | self.drop_job.setEnabled(True) |
---|
| 435 | self.group_advanced.setEnabled(True) |
---|
| 436 | |
---|
| 437 | # Change in parameter "a" (run control list) |
---|
| 438 | elif (id_str == "a"): |
---|
| 439 | |
---|
| 440 | drop_job = self.group_job.findChild(QtGui.QComboBox,"drop_job").currentText() |
---|
| 441 | rc_flag = "#" |
---|
| 442 | |
---|
| 443 | if (drop_job == "Initial run"): |
---|
| 444 | rc_flag = "#" |
---|
| 445 | |
---|
| 446 | elif (drop_job == "Restart run"): |
---|
[2477] | 447 | rc_flag = "r" |
---|
[2413] | 448 | |
---|
| 449 | elif (drop_job == "Precursor run (atmosphere)"): |
---|
| 450 | rc_flag = "#" |
---|
| 451 | |
---|
| 452 | elif (drop_job == "Precursor run (ocean)"): |
---|
| 453 | rc_flag = "o#" |
---|
| 454 | |
---|
| 455 | elif (drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
| 456 | rc_flag = "#" |
---|
| 457 | |
---|
| 458 | elif (drop_job == "Restart run (coupled atmosphere ocean)"): |
---|
[2477] | 459 | rc_flag = "r" |
---|
[2413] | 460 | |
---|
| 461 | param[0] = "\"d3%s" % (rc_flag) |
---|
| 462 | |
---|
| 463 | |
---|
| 464 | if (drop_job == "Restart run (coupled atmosphere ocean)" or drop_job == "Initial run (coupled atmosphere ocean)"): |
---|
| 465 | if (rc_flag == "#"): |
---|
| 466 | rc_flag = "o#" |
---|
| 467 | else: |
---|
[2825] | 468 | rc_flag = "or" |
---|
[2413] | 469 | |
---|
| 470 | param[0] = "%s d3%s" % (param[0],rc_flag) |
---|
| 471 | |
---|
| 472 | status_restarts = self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").checkState() |
---|
| 473 | |
---|
| 474 | if (status_restarts == 2): |
---|
| 475 | param[0]="%s restart" % (param[0]) |
---|
| 476 | |
---|
[2477] | 477 | # Check if _p3dr file is available, otherwise notice user |
---|
[2413] | 478 | if (status_restarts == 2): |
---|
| 479 | jobname = str(self.group_job.findChild(QtGui.QLineEdit, "line_jobname").text())[len(version_path)+len("/JOBS/"):] |
---|
[2477] | 480 | restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (version_path,jobname,jobname) |
---|
[2413] | 481 | |
---|
| 482 | if (os.path.exists(restartfile) == True): |
---|
| 483 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
| 484 | |
---|
| 485 | else: |
---|
[2477] | 486 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>") |
---|
[2413] | 487 | |
---|
| 488 | else: |
---|
| 489 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
| 490 | |
---|
| 491 | status_cycfill = self.group_execution.findChild(QtGui.QCheckBox,"check_cycfill").checkState() |
---|
| 492 | |
---|
| 493 | if (status_cycfill == 2): |
---|
[2825] | 494 | param[0]="%s fill" % (param[0]) |
---|
| 495 | |
---|
| 496 | status_svf = self.group_execution.findChild(QtGui.QCheckBox,"check_svf").checkState() |
---|
| 497 | |
---|
| 498 | if (status_svf == 2): |
---|
| 499 | param[0]="%s svf" % (param[0]) |
---|
[2413] | 500 | |
---|
| 501 | param[0]="%s\"" % (param[0]) |
---|
[2825] | 502 | |
---|
| 503 | |
---|
[2413] | 504 | if ( fwt_str == "remove"): |
---|
| 505 | self.delete_commandline(id_str) |
---|
| 506 | return 1 |
---|
| 507 | |
---|
| 508 | else: |
---|
| 509 | self.button_start.setEnabled(True) |
---|
| 510 | self.action_save.setEnabled(True) |
---|
| 511 | |
---|
| 512 | # Change in any other parameter |
---|
| 513 | else: |
---|
| 514 | if ( fwt_str != ""): |
---|
| 515 | param[0] = "\"%s\"" % (fwt_str) |
---|
| 516 | |
---|
| 517 | else: |
---|
| 518 | self.delete_commandline(id_str) |
---|
| 519 | return 1 |
---|
| 520 | |
---|
| 521 | # Join the new palmrunline |
---|
| 522 | splitline[1]= " -".join(param) |
---|
| 523 | |
---|
| 524 | |
---|
| 525 | s = " -%s " % (id_str) |
---|
| 526 | newpalmrunline = s.join(splitline) |
---|
| 527 | |
---|
| 528 | # Pr the new palmrunline to mainwindow |
---|
| 529 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
| 530 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(newpalmrunline) |
---|
| 531 | |
---|
| 532 | # change lineinput depending on sender |
---|
| 533 | ################################################################################### |
---|
| 534 | def change_lineinput(self): |
---|
| 535 | if ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit, "line_host") ): |
---|
| 536 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_host").text() |
---|
| 537 | self.change_commandline("h",tmptext) |
---|
| 538 | |
---|
| 539 | elif ( self.sender() == self.group_job.findChild(QtGui.QLineEdit, "line_jobname") ): |
---|
| 540 | tmptext = self.group_job.findChild(QtGui.QLineEdit,"line_jobname").text() |
---|
| 541 | self.change_commandline("d",tmptext) |
---|
| 542 | |
---|
| 543 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_q")): |
---|
| 544 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_q").text() |
---|
| 545 | self.change_commandline("q",tmptext) |
---|
| 546 | |
---|
| 547 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_account")): |
---|
| 548 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_account").text() |
---|
[2480] | 549 | self.change_commandline("A",tmptext) |
---|
[2413] | 550 | |
---|
| 551 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_pe")): |
---|
| 552 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_pe").text() |
---|
| 553 | self.change_commandline("X",tmptext) |
---|
| 554 | |
---|
| 555 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_tpn")): |
---|
| 556 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_tpn").text() |
---|
| 557 | self.change_commandline("T",tmptext) |
---|
| 558 | |
---|
| 559 | elif ( self.sender() == self.group_execution.findChild(QtGui.QLineEdit,"line_time")): |
---|
| 560 | tmptext = self.group_execution.findChild(QtGui.QLineEdit,"line_time").text() |
---|
| 561 | self.change_commandline("t",tmptext) |
---|
| 562 | |
---|
| 563 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_M")): |
---|
| 564 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_M").text() |
---|
| 565 | self.change_commandline("M",tmptext) |
---|
| 566 | |
---|
| 567 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_m")): |
---|
| 568 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_m").text() |
---|
| 569 | self.change_commandline("m",tmptext) |
---|
| 570 | |
---|
| 571 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_D")): |
---|
| 572 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_D").text() |
---|
| 573 | self.change_commandline("D",tmptext) |
---|
| 574 | |
---|
| 575 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_c")): |
---|
| 576 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_c").text() |
---|
| 577 | if ( tmptext == ".palmgui.config"): |
---|
| 578 | tmptext = "" |
---|
| 579 | self.change_commandline("c",tmptext) |
---|
| 580 | |
---|
| 581 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_s")): |
---|
| 582 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_s").text() |
---|
| 583 | self.change_commandline("s",tmptext) |
---|
| 584 | |
---|
| 585 | elif ( self.sender() == self.group_advanced.findChild(QtGui.QLineEdit,"line_w")): |
---|
| 586 | tmptext = self.group_advanced.findChild(QtGui.QLineEdit,"line_w").text() |
---|
| 587 | self.change_commandline("w",tmptext) |
---|
| 588 | |
---|
| 589 | elif ( self.sender() == self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos") or |
---|
| 590 | self.sender() == self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean")): |
---|
| 591 | t1 = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").text() |
---|
| 592 | t2 = self.group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").text() |
---|
| 593 | tmptext = "%s %s" % (t1,t2) |
---|
| 594 | |
---|
| 595 | self.change_commandline("Y",tmptext) |
---|
| 596 | |
---|
| 597 | # try catch sowas in der art |
---|
| 598 | pe1 = 0 |
---|
| 599 | pe2 = 0 |
---|
| 600 | |
---|
| 601 | try: |
---|
| 602 | pe1 = int(t1) |
---|
| 603 | except ValueError: |
---|
| 604 | pass |
---|
| 605 | |
---|
| 606 | try: |
---|
| 607 | pe2 = int(t2) |
---|
| 608 | except ValueError: |
---|
| 609 | pass |
---|
| 610 | |
---|
| 611 | PE_total = pe1+pe2 |
---|
| 612 | self.group_execution.findChild(QtGui.QLineEdit,"line_pe").setText(str(PE_total)) |
---|
| 613 | self.change_commandline("X",str(PE_total)) |
---|
| 614 | |
---|
| 615 | # deletes parameter from commandline |
---|
| 616 | ##################################################################################### |
---|
| 617 | def delete_commandline(self, id_str): |
---|
| 618 | # Read palmrunline |
---|
| 619 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
| 620 | palmrunline = str(commandline.text()) |
---|
| 621 | s = " -%s" % (id_str) |
---|
| 622 | splitline = filter(None,palmrunline.split(s)) |
---|
| 623 | |
---|
| 624 | if ( len(splitline) == 1): |
---|
| 625 | return 1 |
---|
| 626 | else: |
---|
| 627 | param = splitline[1].split("-") |
---|
| 628 | param[0] = "" |
---|
| 629 | splitline[1]= " -".join(param) |
---|
| 630 | newpalmrunline = "".join(splitline) |
---|
| 631 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
| 632 | |
---|
| 633 | # Print new palmrunline to screen |
---|
| 634 | commandline.setText(newpalmrunline) |
---|
| 635 | |
---|
| 636 | # controls flags |
---|
| 637 | ################################################################################### |
---|
| 638 | def check_flags(self): |
---|
| 639 | status = self.group_execution.findChild(QtGui.QCheckBox,"check_delete_tmp_files" ).checkState() |
---|
| 640 | if (status == 2): |
---|
| 641 | self.activate_flag("B") |
---|
| 642 | else: |
---|
| 643 | self.deactivate_flag("B") |
---|
| 644 | |
---|
| 645 | status = self.group_execution.findChild(QtGui.QCheckBox,"check_verbose" ).checkState() |
---|
| 646 | if (status == 2): |
---|
| 647 | self.activate_flag("v") |
---|
| 648 | else: |
---|
| 649 | self.deactivate_flag("v") |
---|
| 650 | |
---|
| 651 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_b" ).checkState() |
---|
| 652 | if (status == 2): |
---|
| 653 | self.activate_flag("b") |
---|
| 654 | else: |
---|
| 655 | self.deactivate_flag("b") |
---|
| 656 | |
---|
| 657 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_F" ).checkState() |
---|
| 658 | if (status == 2): |
---|
| 659 | self.activate_flag("F") |
---|
| 660 | else: |
---|
| 661 | self.deactivate_flag("F") |
---|
| 662 | |
---|
| 663 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_I" ).checkState() |
---|
| 664 | if (status == 2): |
---|
| 665 | self.activate_flag("I") |
---|
| 666 | else: |
---|
| 667 | self.deactivate_flag("I") |
---|
| 668 | |
---|
| 669 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_k" ).checkState() |
---|
| 670 | if (status == 2): |
---|
| 671 | self.activate_flag("k") |
---|
| 672 | else: |
---|
| 673 | self.deactivate_flag("k") |
---|
| 674 | |
---|
| 675 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_O" ).checkState() |
---|
| 676 | if (status == 2): |
---|
| 677 | self.activate_flag("O") |
---|
| 678 | else: |
---|
| 679 | self.deactivate_flag("O") |
---|
| 680 | |
---|
| 681 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_x" ).checkState() |
---|
| 682 | if (status == 2): |
---|
| 683 | self.activate_flag("x") |
---|
| 684 | else: |
---|
| 685 | self.deactivate_flag("x") |
---|
| 686 | |
---|
| 687 | status = self.group_advanced.findChild(QtGui.QCheckBox,"check_Z" ).checkState() |
---|
| 688 | if (status == 2): |
---|
| 689 | self.activate_flag("Z") |
---|
| 690 | else: |
---|
| 691 | self.deactivate_flag("Z") |
---|
| 692 | |
---|
| 693 | # changes flag to parameter |
---|
| 694 | ################################################################################## |
---|
| 695 | def activate_flag(self, id_str): |
---|
| 696 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
| 697 | palmrunline = str(commandline.text()) |
---|
| 698 | s = " -%s" % (id_str) |
---|
| 699 | splitline = filter(None,palmrunline.split(s)) |
---|
| 700 | |
---|
| 701 | if ( len(splitline) == 1): |
---|
| 702 | splitline.append("") |
---|
| 703 | s = " -%s" % (id_str) |
---|
| 704 | newpalmrunline = s.join(splitline) |
---|
| 705 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
| 706 | commandline.setText(newpalmrunline) |
---|
| 707 | |
---|
| 708 | # deletes flag in commandline |
---|
| 709 | #################################################################################### |
---|
| 710 | def deactivate_flag(self, id_str): |
---|
| 711 | commandline = self.groupBox.findChild(QtGui.QLineEdit,"commandline") |
---|
| 712 | palmrunline = str(commandline.text()) |
---|
| 713 | s = " -%s" % (id_str) |
---|
| 714 | splitline = filter(None,palmrunline.split(s)) |
---|
| 715 | |
---|
| 716 | newpalmrunline = "".join(splitline) |
---|
| 717 | newpalmrunline = newpalmrunline.replace(" "," ") |
---|
| 718 | commandline.setText(newpalmrunline) |
---|
| 719 | |
---|
| 720 | # Clears window |
---|
| 721 | ################################################################################# |
---|
| 722 | def reset_window(self): |
---|
| 723 | self.setupUi(self) |
---|
| 724 | self.tabWidget.setCurrentIndex(0) |
---|
[2477] | 725 | self.recent_jobs(50) |
---|
[2413] | 726 | |
---|
| 727 | # Safes current commandline and user Parameters to .sav file |
---|
| 728 | ################################################################################# |
---|
| 729 | def save_to_file(self): |
---|
| 730 | user_string = self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text() |
---|
| 731 | cmd_string = self.groupBox.findChild(QtGui.QLineEdit,"commandline").text() |
---|
| 732 | |
---|
| 733 | string_to_file = cmd_string |
---|
| 734 | if (user_string != ""): |
---|
| 735 | string_to_file = "%s%s" % (string_to_file,user_string) |
---|
| 736 | |
---|
| 737 | #filename = QtGui.QInputDialog.getText(self, "Save File naming Dialog", "Insert filename", QtGui.QLineEdit.Normal) |
---|
| 738 | filename = str(QtGui.QFileDialog.getSaveFileName(self, "Save File","filename.sav")) |
---|
| 739 | extension = ".sav" |
---|
| 740 | filename = "%s%s" % (filename, "") |
---|
| 741 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
| 742 | |
---|
| 743 | file = open(filename,"w") |
---|
| 744 | s = "%s %s" % (tmstamp, string_to_file) |
---|
| 745 | file.write(s) |
---|
| 746 | file.close() |
---|
| 747 | |
---|
| 748 | # Safes current commandline and user parameters to default file |
---|
| 749 | ################################################################################ |
---|
| 750 | def save_default(self): |
---|
| 751 | user_string = self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text() |
---|
| 752 | cmd_string = self.groupBox.findChild(QtGui.QLineEdit,"commandline").text() |
---|
| 753 | |
---|
| 754 | string_to_file = cmd_string |
---|
| 755 | if (user_string != ""): |
---|
| 756 | string_to_file = "%s%s" % (string_to_file,user_string) |
---|
| 757 | |
---|
| 758 | filename ="%s/.palmgui.default" % (version_path) |
---|
| 759 | tmstamp = strftime("%Y/%m/%d %H:%M") |
---|
| 760 | |
---|
| 761 | file = open(filename,"w") |
---|
| 762 | s = "%s %s" % (tmstamp, string_to_file) |
---|
| 763 | file.write(s) |
---|
| 764 | file.close() |
---|
| 765 | |
---|
| 766 | # Execute command which starts jobmanager (start palm_jm) |
---|
| 767 | ####################################################### |
---|
| 768 | def start_jobmanager(self): |
---|
| 769 | subprocess.Popen(["nohup","palm_jm",">>","/dev/null", "2>&1","&"]) |
---|
| 770 | |
---|
| 771 | # Executes command which starts watchdog (start palm_wd) |
---|
| 772 | ######################################################## |
---|
| 773 | def start_watchdog(self): |
---|
| 774 | subprocess.Popen(["nohup","palm_wd",">>","/dev/null", "2>&1","&"]) |
---|
| 775 | |
---|
| 776 | # Opens "help" dialog |
---|
| 777 | ################################# |
---|
| 778 | def help(self): |
---|
| 779 | dialog = HelpDialog() |
---|
| 780 | dialog.exec_() |
---|
| 781 | |
---|
| 782 | # Opens "about" dialog |
---|
| 783 | ################################## |
---|
| 784 | def about_gui(self): |
---|
| 785 | dialog = AboutDialog() |
---|
| 786 | dialog.exec_() |
---|
| 787 | |
---|
| 788 | # commandline to buttons etc |
---|
| 789 | ############################## |
---|
| 790 | def setup_gui(self, palmrun_str): |
---|
[2484] | 791 | |
---|
| 792 | self.palm_logo.setPixmap(QtGui.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png")) |
---|
| 793 | |
---|
[2413] | 794 | # Some initial settings |
---|
| 795 | user = "" |
---|
| 796 | coupled_run = False |
---|
| 797 | ocean_run = False |
---|
| 798 | nojob = False |
---|
| 799 | |
---|
| 800 | #Split parameters in palmrunline |
---|
| 801 | splitline = palmrun_str.split(" -") |
---|
| 802 | |
---|
| 803 | if ( splitline[0] != "palmrun"): |
---|
| 804 | return 1 |
---|
| 805 | |
---|
| 806 | else: |
---|
| 807 | self.group_job.setEnabled(True) |
---|
| 808 | |
---|
| 809 | # Loop for all parameters in palmrunline |
---|
| 810 | i = len(splitline)-1 |
---|
| 811 | while i >= 1: |
---|
| 812 | |
---|
| 813 | # Determine parameter |
---|
| 814 | splitparameter = splitline[i].split(" ") |
---|
| 815 | |
---|
| 816 | parameter = splitparameter[0] |
---|
| 817 | splitparameter.pop(0) |
---|
| 818 | options = " ".join(splitparameter) |
---|
| 819 | options = options.replace("\"","") |
---|
| 820 | |
---|
| 821 | # Check for suitable switch |
---|
| 822 | if ( parameter == "d"): |
---|
| 823 | |
---|
| 824 | if ( options != ""): |
---|
| 825 | self.group_job.findChild(QtGui.QLineEdit,"line_jobname").setText(options) |
---|
| 826 | nojob = False |
---|
| 827 | |
---|
| 828 | else: |
---|
| 829 | nojob = True |
---|
| 830 | |
---|
| 831 | elif ( parameter == "h"): |
---|
| 832 | self.group_execution.findChild(QtGui.QLineEdit,"line_host").setText(options) |
---|
| 833 | |
---|
| 834 | elif ( parameter == "q"): |
---|
| 835 | self.group_execution.findChild(QtGui.QLineEdit,"line_q").setText(options) |
---|
| 836 | |
---|
[2480] | 837 | elif ( parameter == "A"): |
---|
[2413] | 838 | self.group_execution.findChild(QtGui.QLineEdit,"line_account").setText(options) |
---|
| 839 | |
---|
| 840 | elif ( parameter == "X"): |
---|
| 841 | self.group_execution.findChild(QtGui.QLineEdit,"line_pe").setText(options) |
---|
| 842 | |
---|
| 843 | elif ( parameter == "T"): |
---|
| 844 | self.group_execution.findChild(QtGui.QLineEdit,"line_tpn").setText(options) |
---|
| 845 | |
---|
| 846 | elif ( parameter == "t"): |
---|
| 847 | self.group_execution.findChild(QtGui.QLineEdit,"line_time").setText(options) |
---|
| 848 | |
---|
| 849 | elif ( parameter == "B"): |
---|
| 850 | self.group_execution.findChild(QtGui.QCheckBox,"check_delete_tmp_files").setChecked(True) |
---|
| 851 | |
---|
| 852 | elif ( parameter == "v"): |
---|
| 853 | self.group_execution.findChild(QtGui.QCheckBox,"check_verbose").setChecked(True) |
---|
| 854 | |
---|
| 855 | elif ( parameter == "b"): |
---|
| 856 | self.group_advanced.findChild(QtGui.QCheckBox,"check_b").setChecked(True) |
---|
| 857 | |
---|
| 858 | elif ( parameter == "F"): |
---|
| 859 | self.group_advanced.findChild(QtGui.QCheckBox,"check_F").setChecked(True) |
---|
| 860 | |
---|
| 861 | elif ( parameter == "I"): |
---|
| 862 | self.group_advanced.findChild(QtGui.QCheckBox,"check_I").setChecked(True) |
---|
| 863 | |
---|
| 864 | elif ( parameter == "k"): |
---|
| 865 | self.group_advanced.findChild(QtGui.QCheckBox,"check_k").setChecked(True) |
---|
| 866 | |
---|
| 867 | elif ( parameter == "O"): |
---|
| 868 | self.group_advanced.findChild(QtGui.QCheckBox,"check_O").setChecked(True) |
---|
| 869 | |
---|
| 870 | elif ( parameter == "x"): |
---|
| 871 | self.group_advanced.findChild(QtGui.QCheckBox,"check_x").setChecked(True) |
---|
| 872 | |
---|
| 873 | elif ( parameter == "Z"): |
---|
| 874 | self.group_advanced.findChild(QtGui.QCheckBox,"check_Z").setChecked(True) |
---|
| 875 | |
---|
| 876 | elif ( parameter == "m"): |
---|
| 877 | self.group_advanced.findChild(QtGui.QLineEdit,"line_m").setText(options) |
---|
| 878 | |
---|
| 879 | elif ( parameter == "M"): |
---|
| 880 | self.group_advanced.findChild(QtGui.QLineEdit,"line_M").setText(options) |
---|
| 881 | |
---|
| 882 | elif ( parameter == "D"): |
---|
| 883 | self.group_advanced.findChild(QtGui.QLineEdit,"line_D").setText(options) |
---|
| 884 | |
---|
| 885 | elif ( parameter == "c"): |
---|
| 886 | self.group_advanced.findChild(QtGui.QLineEdit,"line_c").setText(options) |
---|
| 887 | |
---|
| 888 | elif ( parameter == "s"): |
---|
| 889 | self.group_advanced.findChild(QtGui.QLineEdit,"line_s").setText(options) |
---|
| 890 | |
---|
| 891 | elif ( parameter == "w"): |
---|
| 892 | self.group_advanced.findChild(QtGui.QLineEdit,"line_w").setText(options) |
---|
| 893 | |
---|
| 894 | |
---|
| 895 | # Determine settings for coupled restart runs |
---|
| 896 | elif ( parameter == "Y"): |
---|
| 897 | optionssplit = options.split(" ") |
---|
| 898 | |
---|
| 899 | group_coupled = self.group_execution.findChild(QtGui.QGroupBox,"group_coupled") |
---|
| 900 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").setEnabled(True) |
---|
| 901 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").setEnabled(True) |
---|
| 902 | group_coupled.findChild(QtGui.QLabel,"label_coupled1").setEnabled(True) |
---|
| 903 | group_coupled.findChild(QtGui.QLabel,"label_coupled2").setEnabled(True) |
---|
| 904 | group_coupled.findChild(QtGui.QLabel,"label_coupled3").setEnabled(True) |
---|
| 905 | group_coupled.findChild(QtGui.QLabel,"label_coupling").setEnabled(True) |
---|
| 906 | |
---|
| 907 | if (optionssplit.count() == 2): |
---|
| 908 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").setEnabled(optionssplit[0]) |
---|
| 909 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").setEnabled(optionssplit[1]) |
---|
| 910 | |
---|
| 911 | else: |
---|
| 912 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_atmos").setText("") |
---|
| 913 | group_coupled.findChild(QtGui.QLineEdit,"line_PE_ocean").setText("") |
---|
| 914 | |
---|
| 915 | |
---|
| 916 | coupled_run = True |
---|
| 917 | |
---|
| 918 | elif ( parameter == "y"): |
---|
| 919 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(3) |
---|
| 920 | |
---|
| 921 | |
---|
| 922 | # Determine settings for the run control list |
---|
| 923 | elif ( parameter == "a"): |
---|
| 924 | |
---|
| 925 | optionssplit = options.split(" ") |
---|
| 926 | |
---|
| 927 | options_2 = None |
---|
| 928 | options_all = None |
---|
| 929 | |
---|
| 930 | j = 0 |
---|
| 931 | while j < len(optionssplit): |
---|
| 932 | |
---|
| 933 | options_all = optionssplit[j] |
---|
| 934 | options_2 = optionssplit[j][:2] |
---|
[2825] | 935 | |
---|
[2477] | 936 | if (options_2 == "d3"): |
---|
| 937 | if (options_all[:3][-1] == "#"): |
---|
[2413] | 938 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(0) |
---|
[2477] | 939 | elif (options_all[:3][-1] == "r"): |
---|
[2413] | 940 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(1) |
---|
| 941 | |
---|
[2477] | 942 | elif (options_all[:3][-1] == "o"): |
---|
[2413] | 943 | ocean_run = True |
---|
| 944 | |
---|
| 945 | if (options_all == "restart"): |
---|
| 946 | self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").setChecked(True) |
---|
| 947 | # Check if _pdf file is available, otherwise notice user |
---|
| 948 | jobname = str(self.group_job.findChild(QtGui.QLineEdit,"line_jobname").text())[len(version_path)+len("/JOBS/"):] |
---|
| 949 | |
---|
[2477] | 950 | restartfile = "%sJOBS/%s/INPUT/%s_p3dr" % (version_path,jobname,jobname) |
---|
[2413] | 951 | if (os.path.exists(restartfile) == True): |
---|
| 952 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") |
---|
| 953 | |
---|
| 954 | else: |
---|
[2477] | 955 | self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file \found!</font>") |
---|
[2413] | 956 | j = j+1 |
---|
| 957 | |
---|
| 958 | # All unknown parameters are set as extra user parameters |
---|
| 959 | else: |
---|
| 960 | print parameter |
---|
| 961 | user = "%s-%s \"%s\" " % (user,parameter,options) |
---|
| 962 | splitline.removeAt(i) |
---|
| 963 | |
---|
| 964 | i = i-1 |
---|
| 965 | # Change drop box state in case of ocean precursor or coupled restart runs |
---|
| 966 | if ( ocean_run == True ): |
---|
| 967 | if ( coupled_run == True ): |
---|
| 968 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(4) |
---|
| 969 | |
---|
| 970 | else: |
---|
| 971 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setCurrentIndex(3) |
---|
| 972 | |
---|
| 973 | if ( user != ""): |
---|
| 974 | self.group_advanced.findChild(QtGui.QLineEdit,"line_user").setText(user) |
---|
| 975 | |
---|
| 976 | # Join palmrunline and post it to mainwindow |
---|
| 977 | palmrunline = " -".join(splitline) |
---|
| 978 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) |
---|
| 979 | |
---|
| 980 | # Disable mainwindow if no job was found, otherwise enable |
---|
| 981 | if ( nojob == True ): |
---|
| 982 | self.group_execution.setEnabled(False) |
---|
| 983 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(False) |
---|
| 984 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(False) |
---|
| 985 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setEnabled(False) |
---|
| 986 | self.group_advanced.setEnabled(False) |
---|
| 987 | self.check_advanced.setEnabled(False) |
---|
| 988 | |
---|
| 989 | else: |
---|
| 990 | self.group_execution.setEnabled(True) |
---|
| 991 | self.groupBox.findChild(QtGui.QPushButton,"button_start").setEnabled(True) |
---|
| 992 | self.menuBar.findChild(QtGui.QMenu,"menuStart").actions()[3].setEnabled(True) |
---|
| 993 | self.group_job.findChild(QtGui.QComboBox, "drop_job").setEnabled(True) |
---|
| 994 | self.group_advanced.setEnabled(True) |
---|
| 995 | |
---|
| 996 | self.tabWidget.setCurrentIndex(0) |
---|
| 997 | |
---|
| 998 | # open saved commandline |
---|
| 999 | ################################## |
---|
| 1000 | def open_from_file(self): |
---|
| 1001 | |
---|
| 1002 | # Select filename and open it |
---|
| 1003 | filename = QtGui.QFileDialog.getOpenFileName(self, "Open File","Save files (*.sav)") |
---|
| 1004 | |
---|
| 1005 | if ( filename != ""): |
---|
| 1006 | file = open(filename, "r") |
---|
| 1007 | |
---|
| 1008 | if ( file is not None ): |
---|
| 1009 | # File opened successfully |
---|
| 1010 | palmrunline = file.read() |
---|
| 1011 | file.close() |
---|
| 1012 | |
---|
| 1013 | # In case a palmrunline was found, load it to mainwindow |
---|
| 1014 | if ( palmrunline != ""): |
---|
| 1015 | palmrunline = palmrunline[17:] |
---|
| 1016 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) |
---|
| 1017 | self.setup_gui(palmrunline) |
---|
| 1018 | |
---|
| 1019 | # open saved commandline |
---|
| 1020 | ################################## |
---|
| 1021 | def open_last(self): |
---|
| 1022 | # Select filename and open it |
---|
| 1023 | filename = "%s/.palm.history" % (version_path) |
---|
| 1024 | |
---|
| 1025 | if os.path.exists(filename): |
---|
| 1026 | pass |
---|
| 1027 | else: |
---|
| 1028 | return |
---|
| 1029 | |
---|
| 1030 | file = open(filename, "r") |
---|
| 1031 | if ( file is not None ): |
---|
| 1032 | # File opened successfully |
---|
| 1033 | lines = file.readlines() |
---|
| 1034 | palmrunline = lines[len(lines)-1] |
---|
| 1035 | palmrunline = palmrunline[:len(palmrunline)-1] |
---|
| 1036 | file.close() |
---|
| 1037 | |
---|
| 1038 | # In case a palmrunline was found, load it to mainwindow |
---|
| 1039 | if ( palmrunline != ""): |
---|
| 1040 | palmrunline = palmrunline[17:len(palmrunline)] |
---|
| 1041 | self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) |
---|
| 1042 | self.setup_gui(palmrunline) |
---|
| 1043 | |
---|
| 1044 | |
---|
| 1045 | if __name__ == "__main__": |
---|
| 1046 | app = QtGui.QApplication(sys.argv) |
---|
| 1047 | window = Mainwindow() |
---|
| 1048 | window.show() |
---|
[2825] | 1049 | sys.exit(app.exec_()) |
---|