Ignore:
Timestamp:
Feb 4, 2020 9:24:48 PM (5 years ago)
Author:
maronga
Message:

removed PALM_BIN dependencies in GUI tools

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/palmrungui

    r3487 r4393  
    2525# -----------------
    2626# $Id$
     27# Removed PALM_BIN dependency and os calls
     28#
     29# 3487 2018-11-05 07:18:02Z maronga
    2730# Renamed options -d and -h to -r and -c.
    2831#
     
    7578# Determine PALM directories
    7679try:
    77    devnull = open(os.devnull, 'w')
    78    out = subprocess.check_output("echo $PALM_BIN", shell=True, stderr=subprocess.STDOUT)
    79    palm_bin = out.rstrip()
    80    palm_dir = out.split("palm")[0] + "palm/" + out.split("palm")[1].split("/")[1]
    81    out = None
     80   devnull = open(os.devnull, 'w')     
     81   palm_dir = os.getcwd()
     82   palm_bin = palm_dir + '/trunk/SCRIPTS'
     83   job_dir = palm_dir + '/JOBS'
     84   user_dir = palm_dir + '/USER_CODE'
     85   with open(palm_bin + '/palmrungui', 'r') as fh:
     86      # file found
     87      out = None
    8288except:   
    83    print "Error. $PALM_BIN is not set."
     89   print "Error. palmrungui probably called in wrong directory."
    8490   raise SystemExit
    8591
    8692
    8793palmrunline = ""
    88 name_of_file = os.path.basename(__file__)
    89 
    90 palmrungui_path = os.path.realpath(__file__)
    91 version_path = palmrungui_path[:len(palmrungui_path)-14-len(name_of_file)-1]
    9294
    9395Ui_MainWindow = uic.loadUiType("%s/palmrungui_files/mainwindow.ui" % (palm_bin))[0]
     
    119121       
    120122       
    121         filename = "%s/.palmrun.gui.default" % (version_path
     123        filename = "%s/.palmrun.gui.default" % (palm_dir
    122124        if os.path.exists(filename):
    123125            pass
     
    165167        palmrun = QProcess()
    166168        palmrun.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels
    167         palmrun.setWorkingDirectory(version_path)
     169        palmrun.setWorkingDirectory(palm_dir)
    168170   
    169171        geomet = self.frameGeometry()
     
    186188        # Jobs has been submitted or aborted. Continuing...
    187189        # Save the palmrun command to history file
    188         filename = "%s/.palm.history" % (version_path)
     190        filename = "%s/.palm.history" % (palm_dir)
    189191        tmstamp = strftime("%Y/%m/%d %H:%M")
    190192   
     
    207209    ######################################
    208210    def recent_jobs(self, number):
    209         fileDir = "%s/.palm.history" % (version_path)
     211        fileDir = "%s/.palm.history" % (palm_dir)
    210212        if os.path.exists(fileDir):
    211213            pass
     
    268270    ################################
    269271    def choosejob(self):
    270         jobDir = "%s/JOBS" % (version_path)       
     272        jobDir = "%s/JOBS" % (palm_dir)       
    271273
    272274        # Pick a job from dialog
     
    305307        jobname = filename[:len(filename) - 19];
    306308   
    307         fileDir = "%s/.palm.history" % (version_path)
     309        fileDir = "%s/.palm.history" % (palm_dir)
    308310        file = open(fileDir,"r")
    309311        history = file.readlines()
     
    400402            else:
    401403                # Check if user code is available
    402                 usercode = "%s/JOBS/%s/USER_CODE" % (version_path,param[0])
     404                usercode = "%s/JOBS/%s/USER_CODE" % (palm_dir,param[0])
    403405                               
    404406                if (os.path.exists(usercode) is True):
     
    415417
    416418                    jobname = self.group_job.findChild(QtGui.QLineEdit, "line_jobname").text()
    417                     restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (version_path,jobname,jobname)
     419                    restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname)
    418420
    419421                    if (os.path.exists(restartfile) == True):                 
     
    422424
    423425                        if ( drop_job == "Restart run (coupled atmosphere ocean)" ):
    424                             restartfileo = "%s/JOBS/%s/INPUT/%s_p3dor" % (version_path,jobname,jobname)
     426                            restartfileo = "%s/JOBS/%s/INPUT/%s_p3dor" % (palm_dir,jobname,jobname)
    425427                            if (os.path.exists(restartfileo) == True):                 
    426428                                self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("hooo")
     
    480482                # Check if _p3dr file is available, otherwise notice user
    481483                if (status_restarts == 2):
    482                     jobname = str(self.group_job.findChild(QtGui.QLineEdit, "line_jobname").text())[len(version_path)+len("/JOBS/"):]
    483                     restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (version_path,jobname,jobname)
     484                    jobname = str(self.group_job.findChild(QtGui.QLineEdit, "line_jobname").text())[len(palm_dir)+len("/JOBS/"):]
     485                    restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname)
    484486                   
    485487                    if (os.path.exists(restartfile) == True):                   
     
    759761            string_to_file = "%s%s" % (string_to_file,user_string)
    760762       
    761         filename ="%s/.palmgui.default" % (version_path)
     763        filename ="%s/.palmgui.default" % (palm_dir)
    762764        tmstamp = strftime("%Y/%m/%d %H:%M")
    763765       
     
    949951                        self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").setChecked(True)
    950952                        # Check if _pdf file is available, otherwise notice user
    951                         jobname = str(self.group_job.findChild(QtGui.QLineEdit,"line_jobname").text())[len(version_path)+len("/JOBS/"):]
     953                        jobname = str(self.group_job.findChild(QtGui.QLineEdit,"line_jobname").text())[len(palm_dir)+len("/JOBS/"):]
    952954                       
    953                         restartfile = "%sJOBS/%s/INPUT/%s_p3dr" % (version_path,jobname,jobname)
     955                        restartfile = "%sJOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname)
    954956                        if (os.path.exists(restartfile) == True):   
    955957                            self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("")
     
    10241026    def open_last(self):
    10251027        # Select filename and open it
    1026         filename = "%s/.palm.history" % (version_path)
     1028        filename = "%s/.palm.history" % (palm_dir)
    10271029       
    10281030        if os.path.exists(filename):
Note: See TracChangeset for help on using the changeset viewer.