Ignore:
Timestamp:
Mar 24, 2020 6:52:19 AM (4 years ago)
Author:
maronga
Message:

funtionality improvements in palmrungui

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/palmrungui

    r4428 r4470  
    2525# -----------------
    2626# $Id$
     27# Added file size output, more I/O functionalities, new/removed buttons
     28#
     29# 4428 2020-02-27 11:43:53Z maronga
    2730# Bugfix for update button
    2831#
     
    9699import shutil
    97100
    98 
     101global update_frequency
     102update_frequency = 5*60000
    99103
    100104# Determine PALM directories
     
    103107   palm_dir = os.getcwd()
    104108   palm_bin = palm_dir + '/trunk/SCRIPTS'
     109   palm_source = palm_dir + '/trunk/SOURCE'
    105110   job_dir = palm_dir + '/JOBS'
    106111   user_dir = palm_dir + '/USER_CODE'
     
    113118
    114119
     120# returns the human readable file size of filename
     121def file_size(filename, suffix='B'):
     122   size_raw = os.stat(filename).st_size
     123   for unit in [' ',' K',' M',' G',' T']:
     124      if abs(size_raw) < 1024.0:
     125         return "%i%s%s" % (size_raw, unit, suffix)
     126      size_raw /= 1024.0
     127   return "%.1f%s%s" % (num, 'Y', suffix)
     128
     129
     130
    115131palmrunline = ""
    116132set_list = []
     
    135151        self.setupUi(self)
    136152   
    137         self.palm_logo.setPixmap(QtGui.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png"))       
     153        self.palm_logo.setPixmap(QtGui.QPixmap(palm_bin + "/palmrungui_files/logo.png"))       
     154       
     155        with open(palm_bin + "/palmrungui") as search:
     156           for line in search:
     157              line = line.rstrip()
     158              if "$Id" in line:
     159                 version = "Version: r" + line.split(" ")[3] + " (" + line.split(" ")[4] + ")"
     160                 self.groupBox.findChild(QtGui.QLabel,"label_version").setText(version)
     161                 break
    138162       
    139163        self.recent_jobs(50)
     
    176200
    177201
    178 
    179    
    180202        QtGui.QApplication.processEvents()
    181203
    182204
    183        
     205        # Start refresh timer. On timeout perform update
     206        self.timer = QtCore.QTimer(self)
     207        self.timer.timeout.connect(self.update_all)
     208        self.timer.setSingleShot(False)
     209        self.timer.start(update_frequency)
     210
     211        # The timetimer counts the time since last update
     212        self.timetimer= QtCore.QElapsedTimer()
     213        self.timetimer.start()
     214
     215        # The labeltimer induces the update of the remaining time in the UI
     216        self.labeltimer = QtCore.QTimer(self)
     217        self.labeltimer.timeout.connect(self.UpdatePush)
     218        self.labeltimer.setSingleShot(False)
     219
     220        # Update in the UI will be performed at each 1/10 of the update interval
     221        self.labeltimer.start(update_frequency/10)
     222        self.push_update.setText("Update (" + str(int(update_frequency/1000/60)) + " min)")
     223
    184224    # starts xterm with palmrun commandline
    185225    #######################################
     
    200240        self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("wait...")     
    201241        self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText("Executing palmrun in xterm...")       
    202        
     242
    203243        # Wait until all commands have been executed (ugly) ?
    204244        #for i in range(0,21):
    205245        #    qApp->processEvents()       
    206        
     246
    207247        # Start xterm as QProcess
    208248        palmrun = QProcess()
    209249        palmrun.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels
    210250        palmrun.setWorkingDirectory(palm_dir)
    211    
     251
    212252        geomet = self.frameGeometry()
    213        
     253
    214254        posx = geomet.x()+geomet.width()
    215255        posy = geomet.y()
    216      
    217         s = " -title \"Executing palmrun...\" -fa \"Monospace\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy)
    218         palmrunline = "%s%s;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmrunline.replace("\"","\'"))
    219        
     256
     257        if ( os.path.isfile("palmrungui.log") ):
     258           os.remove("palmrungui.log")
     259
     260        s = " -title \"Executing palmrun...\" -fa \"Monospace\" -l -lf \"palmrungui.log\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy)
     261        palmrunline = "%s%s ;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmrunline.replace("\"","\'"))
     262
    220263        mString = "xterm %s" % (palmrunline)
    221264        palmrun.start(mString)
    222    
     265
    223266        if( palmrun.waitForStarted() is False ):
    224267            return
    225        
     268
    226269        # Wait until palmrun has finished or wait for 200 minutes
    227270        palmrun.waitForFinished(3600000)       
    228        
     271
    229272        # Jobs has been submitted or aborted. Continuing...
    230273        # Save the palmrun command to history file
     
    249292       
    250293       
    251        
     294       
     295    # Update the label
     296    def UpdatePush(self):
     297        remaining_time = (update_frequency - self.timetimer.elapsed()) / 1000 / 60
     298        self.push_update.setText("Update (" + str(remaining_time) + " min)")
     299
     300
    252301    # starts xterm with palmbuild commandline
    253302    #######################################
    254303    def startpalmbuild(self):
    255304        palmbuildline = 'palmbuild -c ' + str(self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").currentText())
    256        
     305
     306        full_build = self.group_execution.findChild(QtGui.QCheckBox,"check_rebuild").checkState()
     307
     308        if ( full_build == 2 ):
     309           for filename in os.listdir(palm_source):
     310              os.utime(palm_source + "/" + filename, None)
     311
    257312        palmrunline_save = str(self.groupBox.findChild(QtGui.QLineEdit,"commandline").text())
    258        
     313
    259314        # Disable the main window
    260315        palmbuildline_save = palmbuildline
     
    312367        else:
    313368            return
    314        
     369
    315370        file = open(fileDir,"r")
    316371        history = file.readlines()
     
    330385            listitem = history[i][17:len(history[i])-1]
    331386            tagitem = listitem
     387            configitem = listitem
    332388            matchitems = list_jobname.findItems(listitem, QtCore.Qt.MatchExactly)
    333389
    334390            if ( len(matchitems) == 0 ):
    335391                listitem = filter(None,listitem.split(" -r"))[1]
    336                 listitem = filter(None,listitem.split(" -"))[0]
    337                 listitem = listitem.replace(" ","")
     392                listitem = listitem.strip()
     393                listitem = filter(None,listitem.split(" "))[0]
     394                listitem = listitem.replace("\"","")
    338395                list_jobname.addItem(listitem)
    339                 s = "%s: %s" % (timestamp,listitem)
     396               
     397                configitem = filter(None,configitem.split(" -c"))[1]
     398                configitem = configitem.strip()
     399                configitem = filter(None,configitem.split(" "))[0]
     400                configitem = configitem.replace("\"","")
     401
     402                s = "%s: %s (%s)" % (timestamp,listitem,configitem)
    340403                tmphistory.append(s)
    341404               
     
    384447        list_jobname = self.group_history.findChild(QtGui.QListWidget,"list_jobname")
    385448        filename = str(list_jobname.currentItem().text())
    386            
     449
    387450        timestamp = filename[:16]
    388         jobname = filename[18:]
    389                
     451        jobname = filename[18:].split(" ")[0]
     452
    390453        itemint = list_jobname.currentRow()
    391454
     
    415478            listitem = history[i-1][17:len(history[i-1])-1]
    416479            listitem = filter(None,listitem.split(" -r"))[1]
    417             listitem = filter(None,listitem.split(" -"))[0]
    418             listitem = listitem.replace(" ","") 
     480            listitem = listitem.strip()
     481            listitem = filter(None,listitem.split(" "))[0]
     482            listitem = listitem.replace("\"","")
    419483
    420484            # Select command line with correct timestamp and jobname
     
    509573            else:
    510574
    511                 # Check if _p3dr file is available, otherwise notice user
    512                 drop_job = self.group_execution.findChild(QtGui.QComboBox,"drop_job").currentText()
    513                 if ( self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").checkState() == 2 or
    514                      drop_job == "Restart run" or drop_job == "Restart run (coupled atmosphere ocean)"     ):
    515 
    516                     jobname = self.group_execution.findChild(QtGui.QLineEdit, "line_jobname").text()
    517                     restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname)
    518 
    519                     if (os.path.exists(restartfile) == True):                 
    520                         self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("")
    521                
    522 
    523                         if ( drop_job == "Restart run (coupled atmosphere ocean)" ):
    524                             restartfileo = "%s/JOBS/%s/INPUT/%s_p3dor" % (palm_dir,jobname,jobname)
    525                             if (os.path.exists(restartfileo) == True):                 
    526                                 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("hooo")
    527                  
    528                             else:       
    529                                 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dor file found!</font>")   
    530                
    531                     else:       
    532                         self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>")
    533          
    534                
    535                        
    536575                self.group_execution.setEnabled(True)
    537576                self.drop_job.setEnabled(True)
     
    577616            if (status_restarts == 2):
    578617                param[0]="%s restart" % (param[0])
    579    
    580                 # Check if _p3dr file is available, otherwise notice user
    581                 if (status_restarts == 2):
    582                     jobname = str(self.group_execution.findChild(QtGui.QLineEdit, "line_jobname").text())
    583                     restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname)
    584                     if (os.path.exists(restartfile) == True):                   
    585                         self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("")
    586                    
    587                     else:                   
    588                         self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>")
    589 
    590             else: 
    591                 self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("")
     618
    592619
    593620            status_cycfill = self.group_execution.findChild(QtGui.QCheckBox,"check_cycfill").checkState()
     
    831858        self.load_jobs()
    832859       
    833     # Safes current commandline and user Parameters to .sav file
    834     #################################################################################
    835     def save_to_file(self):
    836         user_string = self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text()
    837         cmd_string = self.groupBox.findChild(QtGui.QLineEdit,"commandline").text()
    838        
    839         string_to_file = cmd_string
    840         if (user_string != ""):
    841             string_to_file = "%s%s" % (string_to_file,user_string)
    842            
    843         #filename = QtGui.QInputDialog.getText(self, "Save File naming Dialog", "Insert filename", QtGui.QLineEdit.Normal)
    844         filename = str(QtGui.QFileDialog.getSaveFileName(self, "Save File","filename.sav"))
    845         extension = ".sav"
    846         filename = "%s%s" % (filename, "")
    847         tmstamp = strftime("%Y/%m/%d %H:%M")
    848        
    849         file = open(filename,"w")
    850         s = "%s %s" % (tmstamp, string_to_file)
    851         file.write(s)
    852         file.close()
    853        
     860
    854861    # Safes current commandline and user parameters to default file
    855862    ################################################################################
     
    932939               
    933940            elif ( parameter == "c"):
    934                 tmpindex = self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").findText(options,QtCore.Qt.MatchExactly)
     941                tmpindex = self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").findText(options.strip(),QtCore.Qt.MatchExactly)
    935942                if tmpindex != -1:
    936943                   self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").setCurrentIndex(tmpindex)
     
    10501057                    if (options_all == "restart"):
    10511058                        self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").setChecked(True)
    1052                         # Check if _pdf file is available, otherwise notice user
    1053                         jobname = str(self.group_execution.findChild(QtGui.QLineEdit,"line_jobname").text())
    1054                        
    1055                         restartfile = "%sJOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname)
    1056                         if (os.path.exists(restartfile) == True):   
    1057                             self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("")
    1058                        
    1059                         else:
    1060                             self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file \found!</font>")
     1059
    10611060                    j = j+1
    10621061
     
    11001099            self.group_advanced.setEnabled(True)
    11011100            self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
    1102          
     1101
     1102
    11031103        self.tabWidget.setCurrentIndex(0)
    1104          
    1105     # open saved commandline
    1106     ##################################
     1104
     1105
     1106    ## Open from history
     1107    ###################################
    11071108    def open_from_file(self):
    1108        
    1109         # Select filename and open it
    1110         filename = QtGui.QFileDialog.getOpenFileName(self, "Open File","Save files (*.sav)")
    1111        
    1112         if ( filename != ""):
    1113             file = open(filename, "r")
    1114          
    1115             if ( file is not None ):
    1116                 # File opened successfully
    1117                 palmrunline = file.read()
    1118                 file.close()
    1119    
    1120             # In case a palmrunline was found, load it to mainwindow
    1121             if ( palmrunline != ""):
    1122                 palmrunline = palmrunline[17:]
    1123                 self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline)
    1124                 self.setup_gui(palmrunline)
    1125          
    1126     # open saved commandline   
    1127     ##################################
    1128     def open_last(self):
    1129         # Select filename and open it
    1130         filename = "%s/.palmrungui.history" % (palm_dir)
    1131        
    1132         if os.path.exists(filename):
    1133             pass
    1134         else:
    1135             return
    1136        
    1137         file = open(filename, "r") 
    1138         if ( file is not None ):
    1139             # File opened successfully
    1140             lines = file.readlines()
    1141             palmrunline = lines[len(lines)-1]
    1142             palmrunline = palmrunline[:len(palmrunline)-1]
    1143             file.close()
    1144 
    1145         # In case a palmrunline was found, load it to mainwindow
    1146         if ( palmrunline != ""):
    1147             palmrunline = palmrunline[17:len(palmrunline)]
    1148             self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline)
    1149             self.setup_gui(palmrunline)       
    1150 
     1109
     1110#      Show History
     1111       opt = OpenHistoryBox()
     1112       opt.exec_()
     1113
     1114       palmrunline = str(history_entry)
     1115       palmrunline = palmrunline[17:]
     1116       palmrunline = palmrunline[:len(palmrunline)-1]
     1117       palmrunline = filter(None,palmrunline.split("("))[0]
     1118       self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline)
     1119
     1120#      Set selected item to jobname in "available jobs" list
     1121       jobname = str(history_entry[17:])
     1122       jobname = filter(None,jobname.split(" -r"))[1]
     1123       jobname = jobname.strip()
     1124       jobname = filter(None,jobname.split(" "))[0]
     1125       jobname = jobname.replace("\"","")
     1126       item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive)
     1127
     1128       if ( item2int != [] ):
     1129          self.list_jobs.setCurrentItem(item2int[0])
     1130          self.update_input()
     1131
     1132#      Add tooltip tag
     1133       tag = str(history_entry).split('\n')[0]
     1134       tag = filter(None,tag.split("("))[1]
     1135       tag = tag.replace(")","")
     1136       self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setText(tag)
    11511137 
    1152    
     1138#      Process palmrungui to set up gui controls
     1139       self.setup_gui(palmrunline)
     1140
     1141
    11531142    def update_all(self):
    11541143 
     
    11621151       self.update_input()
    11631152
     1153
    11641154    # Load jobs into list
    11651155    def load_jobs(self):
     
    11731163
    11741164       self.list_jobs.clear()
    1175        self.push_copy.setEnabled(False)
    1176        self.push_create_set.setEnabled(False)     
    1177      
    11781165       self.line_path.setText(job_dir + "/")
    11791166       
     
    11971184    # Update input and user code lists
    11981185    def update_input(self):
     1186
     1187       self.labeltimer.stop()
     1188
    11991189     
    12001190       self.list_input.clear()
     
    12021192       self.list_monitoring.clear()
    12031193       self.list_output.clear()
    1204        self.push_copy.setEnabled(True)
    1205        self.push_create_set.setEnabled(True)
    12061194       
    12071195       jobitem = self.list_jobs.currentItem()
     
    12191207             
    12201208                if ( os.path.isfile(tmp_file) ):
    1221                    self.list_input.addItem(str(list_of_files[i]))
     1209                   self.list_input.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")")
    12221210 
    12231211          job_to_show = job_dir + "/" + jobitem.text() + "/USER_CODE"
     
    12431231
    12441232                if ( os.path.isfile(tmp_file) ):
    1245                    self.list_monitoring.addItem(str(list_of_files[i]))
     1233                   self.list_monitoring.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")")
    12461234
    12471235          job_to_show = job_dir + "/" + jobitem.text() + "/OUTPUT"
    12481236
    12491237          if ( os.path.isdir(job_to_show) ):
    1250          
     1238
    12511239             list_of_files = os.listdir(job_to_show)
    1252          
     1240
    12531241             for i in range(0,len(list_of_files)):
    12541242                tmp_file = job_to_show + "/" + list_of_files[i]
    12551243
    12561244                if ( os.path.isfile(tmp_file) ):
    1257                    self.list_output.addItem(str(list_of_files[i]))
     1245                   self.list_output.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")")
    12581246 
    12591247          self.group_execution.findChild(QtGui.QLineEdit,"line_jobname").setText(jobitem.text())
    12601248       self.group_history.findChild(QtGui.QListWidget,"list_jobname").clearSelection()
    12611249
     1250       self.timetimer.start()
     1251       self.timer.start(update_frequency)
     1252       self.labeltimer.start(update_frequency/10)
     1253       self.push_update.setText("Update (" + str(int(update_frequency/1000/60)) + " min)")
     1254       QtGui.QApplication.processEvents()
     1255
    12621256       # Change palmrunline accordingly
    12631257       self.change_commandline("r","")
    1264        self.change_commandline("a","")
    1265  
    1266  
     1258       self.change_commandline("a","") 
     1259
    12671260    # Make a copy of a job
    12681261    def copy_job(self):
     
    14121405       self.setEnabled(True)
    14131406       set_list = []
    1414    
     1407
     1408
     1409 # Add a custom context menu for the job selection list
     1410    def openmenujob(self, position):
     1411
     1412        menu = QtGui.QMenu()
     1413
     1414        selection = self.list_jobs.selectedItems()
     1415
     1416        if ( len(selection) != 0 ):
     1417
     1418           copyAction = QtGui.QAction('Copy job', self)
     1419           copyAction.triggered.connect(self.copy_job)
     1420           createAction = QtGui.QAction('Create set from job', self)
     1421           createAction.triggered.connect(self.create_set)
     1422           delAction = QtGui.QAction('Delete job', self)
     1423           delAction.triggered.connect(self.DeleteJob)
     1424
     1425           menu.addAction(copyAction)
     1426           menu.addAction(createAction)
     1427           menu.addAction(delAction)
     1428
     1429           action = menu.exec_(self.list_jobs.mapToGlobal(position))
     1430       
     1431       
    14151432 # Add a custom context menu
    14161433    def openmenuinput(self, position):
     
    14221439        if ( len(selection) != 0 ):
    14231440
    1424            openAction = menu.addAction('Open selected files')     
     1441
     1442           openAction = QtGui.QAction('Open file(s)', self)
    14251443           openAction.setStatusTip('Open file(s) in your favorite editor')
    14261444           openAction.triggered.connect(self.OpenFilesInput)
     1445
     1446
     1447           delAction = QtGui.QAction('Delete file(s)', self)
     1448           delAction.triggered.connect(self.DeleteFilesInput)
     1449
     1450           menu.addAction(openAction)
     1451           menu.addAction(delAction)
     1452
    14271453           action = menu.exec_(self.list_input.mapToGlobal(position))
    14281454
     
    14361462        if ( len(selection) != 0 ):
    14371463
    1438            openAction = menu.addAction('Open selected files')     
     1464           openAction = QtGui.QAction('Open file(s)', self)
    14391465           openAction.setStatusTip('Open file(s) in your favorite editor')
    14401466           openAction.triggered.connect(self.OpenFilesUser)
     1467
     1468
     1469           delAction = QtGui.QAction('Delete file(s)', self)
     1470           delAction.triggered.connect(self.DeleteFilesUser)
     1471
     1472           menu.addAction(openAction)
     1473           menu.addAction(delAction)
    14411474           action = menu.exec_(self.list_user.mapToGlobal(position))
    14421475
     
    14501483        if ( len(selection) != 0 ):
    14511484
    1452            openAction = menu.addAction('Open selected files')     
     1485           openAction = QtGui.QAction('Open file(s)', self)
    14531486           openAction.setStatusTip('Open file(s) in your favorite editor')
    14541487           openAction.triggered.connect(self.OpenFilesOutput)
     1488
     1489
     1490           delAction = QtGui.QAction('Delete file(s)', self)
     1491           delAction.triggered.connect(self.DeleteFilesOutput)
     1492
     1493           menu.addAction(openAction)
     1494           menu.addAction(delAction)
    14551495           action = menu.exec_(self.list_output.mapToGlobal(position))
    14561496
     
    14641504        if ( len(selection) != 0 ):
    14651505
    1466            openAction = menu.addAction('Open selected files')     
     1506           openAction = QtGui.QAction('Open file(s)', self)
    14671507           openAction.setStatusTip('Open file(s) in your favorite editor')
    14681508           openAction.triggered.connect(self.OpenFilesMonitoring)
     1509
     1510
     1511           delAction = QtGui.QAction('Delete file(s)', self)
     1512           delAction.triggered.connect(self.DeleteFilesMonitoring)
     1513
     1514           menu.addAction(openAction)
     1515           menu.addAction(delAction)
    14691516           action = menu.exec_(self.list_monitoring.mapToGlobal(position))
     1517
     1518    def OpenConfig(self):
     1519
     1520       config = str(self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").currentText())
     1521       if ( config != "" ):
     1522          filename = ".palm.config." + config
     1523          open_file = "xdg-open " + filename
     1524          os.system(str(open_file))
    14701525
    14711526    def OpenFilesInput(self):
     
    14781533       open_files = ""
    14791534       for i in range(0,len(sel_files)):
    1480           open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text() + "; "
     1535          open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text().split("(")[0] + "; "
    14811536
    14821537       os.system(str(open_files))
     
    15051560       open_files = ""
    15061561       for i in range(0,len(sel_files)):
    1507           open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text() + "; "
     1562          open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text().split("(")[0] + "; "
    15081563
    15091564       os.system(str(open_files))
     
    15191574       open_files = ""
    15201575       for i in range(0,len(sel_files)):
    1521           open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text() + "; "
     1576          open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text().split("(")[0] + "; "
    15221577
    15231578       os.system(str(open_files))
    15241579       selection = self.list_jobs.selectedItems()
    1525  
     1580
     1581    def DeleteFilesInput(self):
     1582
     1583       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
     1584
     1585       if status == QtGui.QMessageBox.Yes:
     1586
     1587          sel_job = self.list_jobs.currentItem().text()
     1588          sel_files = self.list_input.selectedItems()
     1589
     1590          input_dir = job_dir + "/" + sel_job + "/INPUT/"
     1591
     1592          for i in range(0,len(sel_files)):
     1593             filename = input_dir +  sel_files[i].text().split("(")[0].trimmed()
     1594             os.remove(filename)
     1595
     1596          self.update_all()
     1597
     1598
     1599    def DeleteFilesUser(self):
     1600
     1601       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
     1602
     1603       if status == QtGui.QMessageBox.Yes:
     1604
     1605          sel_job = self.list_jobs.currentItem().text()
     1606          sel_files = self.list_user.selectedItems()
     1607
     1608          input_dir = job_dir + "/" + sel_job + "/USER/"
     1609
     1610          for i in range(0,len(sel_files)):
     1611             filename = input_dir +  sel_files[i].text().split("(")[0].trimmed()
     1612             os.remove(filename)
     1613
     1614          self.update_all()
     1615
     1616
     1617    def DeleteFilesMonitoring(self):
     1618
     1619       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
     1620
     1621       if status == QtGui.QMessageBox.Yes:
     1622
     1623          sel_job = self.list_jobs.currentItem().text()
     1624          sel_files = self.list_monitoring.selectedItems()
     1625
     1626          input_dir = job_dir + "/" + sel_job + "/MONITORING/"
     1627
     1628          for i in range(0,len(sel_files)):
     1629             filename = input_dir +  sel_files[i].text().split("(")[0].trimmed()
     1630             os.remove(filename)
     1631
     1632          self.update_all()
     1633
     1634
     1635    def DeleteFilesOutput(self):
     1636
     1637       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
     1638
     1639       if status == QtGui.QMessageBox.Yes:
     1640
     1641          sel_job = self.list_jobs.currentItem().text()
     1642          sel_files = self.list_output.selectedItems()
     1643
     1644          input_dir = job_dir + "/" + sel_job + "/OUTPUT/"
     1645
     1646          for i in range(0,len(sel_files)):
     1647             filename = input_dir +  sel_files[i].text().split("(")[0].trimmed()
     1648             os.remove(filename)
     1649
     1650          self.update_all()
     1651
     1652    def DeleteJob(self):
     1653
     1654       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete this job?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
     1655
     1656       if status == QtGui.QMessageBox.Yes:
     1657
     1658          sel_job = self.list_jobs.currentItem().text()
     1659
     1660          input_dir = job_dir + "/" + sel_job
     1661          shutil.rmtree(str(input_dir))
     1662
     1663          self.update_all()
     1664
    15261665# Message box for showing RUN_CONTROL output
    15271666class CreateSetBox(QtGui.QDialog):
    15281667    def __init__(self):
    1529      
     1668
    15301669        super(CreateSetBox, self).__init__()
    1531        
     1670
    15321671        uic.loadUi(palm_bin + '/palmrungui_files/create_set.ui', self)
    1533        
     1672
    15341673        self.show()
    1535        
     1674
    15361675        return
    15371676
    15381677#   Cancel button
    15391678    def rejected(self):
    1540      
     1679
    15411680       self.close()
    1542      
     1681
    15431682       return
    1544  
    15451683
    15461684#   OK button
    15471685    def accept(self):
    1548      
     1686
    15491687       global set_list
    1550        
     1688
    15511689       text = self.list.toPlainText()
    15521690       set_list = text.split('\n')
    15531691       self.close()
    1554      
     1692
    15551693       return
    15561694
    1557 
    1558        
     1695# Message box for showing RUN_CONTROL output
     1696class OpenHistoryBox(QtGui.QDialog):
     1697    def __init__(self):
     1698
     1699        super(OpenHistoryBox, self).__init__()
     1700
     1701        uic.loadUi(palm_bin + '/palmrungui_files/history.ui', self)
     1702
     1703        if os.path.exists(palm_dir + "/.palmrungui.history"):
     1704            pass
     1705        else:
     1706            return
     1707
     1708        filename = open(palm_dir + "/.palmrungui.history","r")
     1709        history = filename.readlines()
     1710        filename.close()
     1711
     1712
     1713        list_jobname = self.findChild(QtGui.QListWidget,"list_history")
     1714
     1715        # Read history entries and append to recent job list
     1716        len_history=len(history)-1
     1717        i = 0
     1718        while i<=len_history:
     1719            list_jobname.addItem(history[i])
     1720            i = i + 1
     1721
     1722        self.show()
     1723
     1724        return
     1725
     1726#   Select item / activate Load button
     1727    def ItemSelected(self):
     1728
     1729       self.push_open.setEnabled(True)
     1730
     1731       return
     1732
     1733
     1734#   Load job from history
     1735    def OpenFromHistory(self):
     1736
     1737       global history_entry
     1738       history_entry = self.list_history.selectedItems()[0].text()
     1739
     1740       self.close()
     1741
     1742       return
     1743
     1744#   Close history window
     1745    def DiscardHistory(self):
     1746
     1747
     1748       self.close()
     1749
     1750       return
     1751
     1752#   Clear history
     1753    def ClearHistory(self):
     1754
     1755       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete your history?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
     1756
     1757       if status == QtGui.QMessageBox.Yes:
     1758
     1759          if os.path.exists(palm_dir + "/.palmrungui.history"):
     1760             os.remove(palm_dir + "/.palmrungui.history")
     1761
     1762
     1763       return
    15591764
    15601765if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.