mach_dist_gui.py

Go to the documentation of this file.
00001 import os,sys,string,math,shutil,glob,subprocess,tempfile
00002 from time import sleep
00003 from os.path import join
00004 
00005 ##GUI related stuff
00006 from PyQt4 import QtCore, QtGui
00007 from User_Interface_Mach_Dist import Ui_dialog
00008 ##------------------------------------------------
00009 
00010 #from read_generalINFOS  import  read_generalINFOS
00011 #from determine_ElementType  import  determine_ElementType
00012 #from mesh_bdf2inp  import mesh_bdf2inp
00013 from ApplyingBC_IC  import ApplyingBC_IC
00014 from calculix_postprocess import calculix_postprocess
00015 
00016 import FreeCAD,Fem,Part
00017 
00018 
00019 class MyForm(QtGui.QDialog,Ui_dialog):
00020     def __init__(self, parent=None):
00021         QtGui.QDialog.__init__(self, parent)
00022         self.setupUi(self)
00023         os.chdir("c:/")
00024         #Define some global variables
00025         self.filename = QtCore.QString("")
00026         self.dirname = QtCore.QString("")
00027         self.params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Machining_Distortion")
00028         #Connect Signals and Slots
00029         QtCore.QObject.connect(self.button_select_file, QtCore.SIGNAL("clicked()"), self.select_file)
00030         QtCore.QObject.connect(self.button_select_output, QtCore.SIGNAL("clicked()"), self.select_output)
00031         QtCore.QObject.connect(self.button_dialog, QtCore.SIGNAL("accepted()"), self.onAbbrechen)
00032         QtCore.QObject.connect(self.button_dialog, QtCore.SIGNAL("rejected()"), self.onAbbrechen)
00033         QtCore.QObject.connect(self.button_start_calculation, QtCore.SIGNAL("clicked()"), self.start_calculation)
00034         QtCore.QObject.connect(self.button_add_to_table, QtCore.SIGNAL("clicked()"), self.add_to_table)
00035         QtCore.QObject.connect(self.select_L_file, QtCore.SIGNAL("clicked()"), self.add_L_data)
00036         QtCore.QObject.connect(self.select_LT_file, QtCore.SIGNAL("clicked()"), self.add_LT_data)
00037 
00038 
00039         #Define the table headers as we are not able to use the QT Designer for that
00040         self.JobTable.clear()
00041         self.JobTable.setHorizontalHeaderLabels(
00042         ["Input File","Output Folder","Z-Offset From","Z-Offset To","Z-Intervall","X-Rot From","X-Rot To","X-Rot Intervall",
00043         "Y-Rot From","Y-Rot To","Y-Rot Intervall","Z-Rot From","Z-Rot To","Z-Rot Intervall","Young Modulus","Poisson Ratio",
00044         "LC1","LC2","LC3","LC4","LC5","LC6","LTC1","LTC2","LTC3","LTC4","LTC5","LTC6","Plate Thickness"])
00045 
00046     def add_to_table(self):
00047         self.JobTable.insertRow(0)
00048         item = QtGui.QTableWidgetItem(self.filename)
00049         self.JobTable.setItem(0,0,item)
00050         item = QtGui.QTableWidgetItem(self.dirname)
00051         self.JobTable.setItem(0,1,item)
00052         item = QtGui.QTableWidgetItem()
00053         item.setData(QtCore.Qt.DisplayRole,self.spinBox_z_level_from.value())
00054         self.JobTable.setItem(0,2,item)
00055         item = QtGui.QTableWidgetItem()
00056         item.setData(QtCore.Qt.DisplayRole,self.spinBox_z_level_to.value())
00057         self.JobTable.setItem(0,3,item)
00058         item = QtGui.QTableWidgetItem()
00059         item.setData(QtCore.Qt.DisplayRole,self.spinBox_z_level_intervall.value())
00060         self.JobTable.setItem(0,4,item)
00061         item = QtGui.QTableWidgetItem()
00062         item.setData(QtCore.Qt.DisplayRole,self.spinBox_misalignment_x_from.value())
00063         self.JobTable.setItem(0,5,item)
00064         item = QtGui.QTableWidgetItem()
00065         item.setData(QtCore.Qt.DisplayRole,self.spinBox_misalignment_x_to.value())
00066         self.JobTable.setItem(0,6,item)
00067         item = QtGui.QTableWidgetItem()
00068         item.setData(QtCore.Qt.DisplayRole,self.spinBox_misalignment_x_intervall.value())
00069         self.JobTable.setItem(0,7,item)
00070         item = QtGui.QTableWidgetItem()
00071         item.setData(QtCore.Qt.DisplayRole,self.spinBox_misalignment_y_from.value())
00072         self.JobTable.setItem(0,8,item)
00073         item = QtGui.QTableWidgetItem()
00074         item.setData(QtCore.Qt.DisplayRole,self.spinBox_misalignment_y_to.value())
00075         self.JobTable.setItem(0,9,item)
00076         item = QtGui.QTableWidgetItem()
00077         item.setData(QtCore.Qt.DisplayRole,self.spinBox_misalignment_y_intervall.value())
00078         self.JobTable.setItem(0,10,item)
00079         item = QtGui.QTableWidgetItem()
00080         item.setData(QtCore.Qt.DisplayRole,self.spinBox_misalignment_z_from.value())
00081         self.JobTable.setItem(0,11,item)
00082         item = QtGui.QTableWidgetItem()
00083         item.setData(QtCore.Qt.DisplayRole,self.spinBox_misalignment_z_to.value())
00084         self.JobTable.setItem(0,12,item)
00085         item = QtGui.QTableWidgetItem()
00086         item.setData(QtCore.Qt.DisplayRole,self.spinBox_misalignment_z_intervall.value())
00087         self.JobTable.setItem(0,13,item)
00088         item = QtGui.QTableWidgetItem()
00089         item.setData(QtCore.Qt.DisplayRole,self.spinBox_young_modulus.value())
00090         self.JobTable.setItem(0,14,item)
00091         item = QtGui.QTableWidgetItem()
00092         item.setData(QtCore.Qt.DisplayRole,self.spinBox_poisson_ratio.value())
00093         self.JobTable.setItem(0,15,item)
00094         item = QtGui.QTableWidgetItem()
00095         item.setData(QtCore.Qt.DisplayRole,self.lc1.value())
00096         self.JobTable.setItem(0,16,item)
00097         item = QtGui.QTableWidgetItem()
00098         item.setData(QtCore.Qt.DisplayRole,self.lc2.value())
00099         self.JobTable.setItem(0,17,item)
00100         item = QtGui.QTableWidgetItem()
00101         item.setData(QtCore.Qt.DisplayRole,self.lc3.value())
00102         self.JobTable.setItem(0,18,item)
00103         item = QtGui.QTableWidgetItem()
00104         item.setData(QtCore.Qt.DisplayRole,self.lc4.value())
00105         self.JobTable.setItem(0,19,item)
00106         item = QtGui.QTableWidgetItem()
00107         item.setData(QtCore.Qt.DisplayRole,self.lc5.value())
00108         self.JobTable.setItem(0,20,item)
00109         item = QtGui.QTableWidgetItem()
00110         item.setData(QtCore.Qt.DisplayRole,self.lc6.value())
00111         self.JobTable.setItem(0,21,item)
00112         item = QtGui.QTableWidgetItem()
00113         item.setData(QtCore.Qt.DisplayRole,self.ltc1.value())
00114         self.JobTable.setItem(0,22,item)
00115         item = QtGui.QTableWidgetItem()
00116         item.setData(QtCore.Qt.DisplayRole,self.ltc2.value())
00117         self.JobTable.setItem(0,23,item)
00118         item = QtGui.QTableWidgetItem()
00119         item.setData(QtCore.Qt.DisplayRole,self.ltc3.value())
00120         self.JobTable.setItem(0,24,item)
00121         item = QtGui.QTableWidgetItem()
00122         item.setData(QtCore.Qt.DisplayRole,self.ltc4.value())
00123         self.JobTable.setItem(0,25,item)
00124         item = QtGui.QTableWidgetItem()
00125         item.setData(QtCore.Qt.DisplayRole,self.ltc5.value())
00126         self.JobTable.setItem(0,26,item)
00127         item = QtGui.QTableWidgetItem()
00128         item.setData(QtCore.Qt.DisplayRole,self.ltc6.value())
00129         self.JobTable.setItem(0,27,item)
00130         item = QtGui.QTableWidgetItem()
00131         item.setData(QtCore.Qt.DisplayRole,self.spinBox_Plate_Thickness.value())
00132         self.JobTable.setItem(0,28,item)
00133         # This is how to get the data back test2 = self.JobTable.item(0,1).data(QtCore.Qt.DisplayRole).toInt()
00134         self.button_add_to_table.setEnabled(False)
00135         self.filename.clear()
00136         self.button_start_calculation.setEnabled(True)
00137         
00138 
00139             
00140         
00141     def add_L_data(self):
00142         l_filename = QtGui.QFileDialog.getOpenFileName(None, 'Open file','','R-Script File for L Coefficients (*.txt)')
00143         values = self.parse_R_output(l_filename)
00144         self.lc1.setValue(values[0]),self.lc2.setValue(values[1]),self.lc3.setValue(values[2]),
00145         self.lc4.setValue(values[3]),self.lc5.setValue(values[4]),self.lc6.setValue(values[5])
00146         
00147         
00148     def add_LT_data(self):
00149         lt_filename = QtGui.QFileDialog.getOpenFileName(None, 'Open file','','R-Script File for LT Coefficients (*.txt)')
00150         values = self.parse_R_output(lt_filename)
00151         self.ltc1.setValue(values[0]),self.ltc2.setValue(values[1]),self.ltc3.setValue(values[2]),
00152         self.ltc4.setValue(values[3]),self.ltc5.setValue(values[4]),self.ltc6.setValue(values[5])
00153         
00154 
00155     def parse_R_output(self,filename):
00156         file = open(str(filename))
00157         lines = file.readlines()
00158         found = False
00159         coeff = []
00160         for line in lines:
00161             if line[0:9] == "c0 to c5:":
00162                 found = True
00163                 coeff.append(float(line[15:]))
00164                 continue
00165             if found and line[0:4] == "MSE:":
00166                 found = False
00167             if found:
00168                 coeff.append(float(line[15:]))
00169         
00170         file.close()
00171         return coeff[0],coeff[1],coeff[2],coeff[3],coeff[4],coeff[5]
00172         
00173   
00174     def select_file(self):
00175         self.filename=QtGui.QFileDialog.getOpenFileName(None, 'Open file','','Nastran Files (*.bdf)')
00176         self.button_add_to_table.setEnabled(not self.dirname.isEmpty() and not self.filename.isEmpty())
00177 
00178     def select_output(self):
00179         self.dirname=QtGui.QFileDialog.getExistingDirectory(None, 'Open working directory', '', QtGui.QFileDialog.ShowDirsOnly)
00180         self.button_add_to_table.setEnabled(not self.dirname.isEmpty() and not self.filename.isEmpty())
00181 
00182     def onAbbrechen(self):
00183         self.close()
00184 
00185         
00186     def start_calculation(self):
00187         self.button_add_to_table.setEnabled(False)
00188         self.button_select_file.setEnabled(False)
00189         self.button_select_output.setEnabled(False)
00190         self.button_start_calculation.setEnabled(False)
00191         os.chdir("/")
00192         ##Get values from the GUI
00193         if ( os.path.exists(str(self.dirname)) ):
00194             os.chdir("c:/")
00195             shutil.rmtree(str(self.dirname))
00196         
00197         os.mkdir(str(self.dirname))
00198         batch = open(str(self.dirname + "/" + "lcmt_CALCULIX_Calculation_batch.bat"),'wb')
00199         #Tell calculixs solver spooles how many cpus to use
00200         #batch.write("export CCX_NPROC=" + str(self.params.GetInt("NumberCPUs")) + "\n")
00201         #If we have a tcsh
00202         #batch.write("setenv CCX_NPROC 4\n")
00203 
00204         #Now do the calculation stuff for each row in the  table
00205         for job in range (0,self.JobTable.rowCount()):
00206             #Extract the data from the table
00207             current_file_name = self.JobTable.item(job,0).text()
00208             z_offset_from = self.JobTable.item(job,2).data(QtCore.Qt.DisplayRole).toInt()[0]
00209             z_offset_to = self.JobTable.item(job,3).data(QtCore.Qt.DisplayRole).toInt()[0]
00210             z_offset_intervall = self.JobTable.item(job,4).data(QtCore.Qt.DisplayRole).toInt()[0]
00211             x_rot_from = self.JobTable.item(job,5).data(QtCore.Qt.DisplayRole).toInt()[0]
00212             x_rot_to = self.JobTable.item(job,6).data(QtCore.Qt.DisplayRole).toInt()[0]
00213             x_rot_intervall = self.JobTable.item(job,7).data(QtCore.Qt.DisplayRole).toInt()[0]
00214             y_rot_from = self.JobTable.item(job,8).data(QtCore.Qt.DisplayRole).toInt()[0]
00215             y_rot_to = self.JobTable.item(job,9).data(QtCore.Qt.DisplayRole).toInt()[0]
00216             y_rot_intervall = self.JobTable.item(job,10).data(QtCore.Qt.DisplayRole).toInt()[0]
00217             z_rot_from = self.JobTable.item(job,11).data(QtCore.Qt.DisplayRole).toInt()[0]
00218             z_rot_to = self.JobTable.item(job,12).data(QtCore.Qt.DisplayRole).toInt()[0]
00219             z_rot_intervall = self.JobTable.item(job,13).data(QtCore.Qt.DisplayRole).toInt()[0]
00220             young_modulus = self.JobTable.item(job,14).data(QtCore.Qt.DisplayRole).toDouble()[0]
00221             poisson_ratio = self.JobTable.item(job,15).data(QtCore.Qt.DisplayRole).toDouble()[0]
00222             lc1 = self.JobTable.item(job,16).data(QtCore.Qt.DisplayRole).toDouble()[0]
00223             lc2 = self.JobTable.item(job,17).data(QtCore.Qt.DisplayRole).toDouble()[0]
00224             lc3 = self.JobTable.item(job,18).data(QtCore.Qt.DisplayRole).toDouble()[0]
00225             lc4 = self.JobTable.item(job,19).data(QtCore.Qt.DisplayRole).toDouble()[0]
00226             lc5 = self.JobTable.item(job,20).data(QtCore.Qt.DisplayRole).toDouble()[0]
00227             lc6 = self.JobTable.item(job,21).data(QtCore.Qt.DisplayRole).toDouble()[0]
00228             ltc1 = self.JobTable.item(job,22).data(QtCore.Qt.DisplayRole).toDouble()[0]
00229             ltc2 = self.JobTable.item(job,23).data(QtCore.Qt.DisplayRole).toDouble()[0]
00230             ltc3 = self.JobTable.item(job,24).data(QtCore.Qt.DisplayRole).toDouble()[0]
00231             ltc4 = self.JobTable.item(job,25).data(QtCore.Qt.DisplayRole).toDouble()[0]
00232             ltc5 = self.JobTable.item(job,26).data(QtCore.Qt.DisplayRole).toDouble()[0]
00233             ltc6 = self.JobTable.item(job,27).data(QtCore.Qt.DisplayRole).toDouble()[0]
00234             plate_thickness = self.JobTable.item(job,28).data(QtCore.Qt.DisplayRole).toDouble()[0]
00235             filename_without_suffix = self.JobTable.item(job,0).text().split("/").takeLast().split(".")[0]
00236             meshobject = Fem.read(str(current_file_name))
00237             #Perform PCA
00238             Fem.SMESH_PCA(meshobject)
00239             #Do min routine
00240             Fem.minBoundingBox(meshobject)
00241             #Now get the Node Numbers for the Boundary Conditions
00242             node_numbers = []
00243             node_numbers = Fem.getBoundary_Conditions(meshobject)
00244 
00245             #Now we have set up the initial geometry for the calculations. Lets generate an ABAQUS input file now for each z-level with exactly the same
00246             #boundary conditions
00247 
00248 
00249             #1. Lets translate the geometry to the initial desired z-level
00250 
00251             #2. Generate a Folder for the current calculation z-level and output the ABAQUS Geometry and the boundary_conditions
00252             #Lets first generate a subfolder with the current filename
00253             os.mkdir(str(self.dirname + "/" + filename_without_suffix))
00254             i = z_offset_from
00255             while i <= z_offset_to:
00256                 j = x_rot_from
00257                 while j <= x_rot_to:
00258                     k = y_rot_from
00259                     while k <= y_rot_to:
00260                         l = z_rot_from
00261                         while l <= z_rot_to:
00262                             rotation_around_x = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,0),FreeCAD.Base.Vector(1,0,0),j)
00263                             rotation_around_y = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,0),FreeCAD.Base.Vector(0,1,0),k)
00264                             rotation_around_z = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,0),FreeCAD.Base.Vector(0,0,1),l)
00265                             translate = FreeCAD.Base.Placement(FreeCAD.Base.Vector(0,0,i),FreeCAD.Base.Vector(0,0,0),0.0)
00266                             translation = rotation_around_x.multiply(rotation_around_y).multiply(rotation_around_z).multiply(translate)
00267                             #Now lets check if the part is still in the billet due to the rotation. If not, we directly skip to the next rotation value
00268                             if(Fem.checkBB(meshobject,translation,plate_thickness)):
00269                                 print "Too heavy rotations"
00270                                 l= l + z_rot_intervall
00271                                 continue
00272                             print "it seems that nothing changed"
00273                             #Use the placedment as optional argument for the write() method
00274                             #translated_mesh.setTransform(translation)
00275                             Case_Dir = str(self.dirname) + "/" + filename_without_suffix + "/" + filename_without_suffix +\
00276                             "_"+"x_rot"+ str(int(j))+ \
00277                             "_"+"y_rot"+ str(int(k))+ \
00278                             "_"+"z_rot"+ str(int(l))+ \
00279                             "_"+"z_l"+ str(int(i))
00280                             if ( os.path.exists(str(Case_Dir)) ):
00281                                 os.chdir(str(self.dirname))
00282                                 shutil.rmtree(str(Case_Dir))
00283 
00284                             os.mkdir(str(Case_Dir))
00285 
00286                             os.chdir("c:/")
00287                             #Lets generate a sigini Input Deck for the calculix user subroutine
00288                             sigini_input = open (str(Case_Dir + "/" + "sigini_input.txt"),'wb')
00289                             
00290                             #Write plate thickness to the sigini_file
00291                             sigini_input.write(str(plate_thickness) + "\n")
00292                             #Now write the Interpolation coefficients, first the L and then the LC ones
00293                             sigini_input.write(\
00294                             str(lc1) + "," + \
00295                             str(lc2) + "," + \
00296                             str(lc3) + "," + \
00297                             str(lc4) + "," + \
00298                             str(lc5) + "," + \
00299                             str(lc6) + "\n")
00300                             sigini_input.write(\
00301                             str(ltc1) + "," + \
00302                             str(ltc2) + "," + \
00303                             str(ltc3) + "," + \
00304                             str(ltc4) + "," + \
00305                             str(ltc5) + "," + \
00306                             str(ltc6) + "\n")
00307                             sigini_input.close()
00308                             #Check if the 
00309                             meshobject.writeABAQUS(str(Case_Dir + "/" + "geometry_fe_input.inp"), translation)
00310                             ApplyingBC_IC(Case_Dir, young_modulus,poisson_ratio,node_numbers[0],node_numbers[1],node_numbers[2])
00311                             #Now lets generate a LSF Job-File to be used by the Airbus Clusters
00312                             lsf_input = open (str(Case_Dir + "/" + "job.lsf"),"wb")
00313                             lsf_input.write("#!/bin/bash\n")
00314                             lsf_input.write("export CCX_NPROC=" + str(self.params.GetInt("NumberCPUs")) + "\n")
00315                             lsf_input.write("#BSUB -n "+ str(self.params.GetInt("NumberCPUs")) + "\n")
00316                             lsf_input.write("#BSUB -W 10:00\n")
00317                             lsf_input.write("#BSUB -o %J.out\n")
00318                             lsf_input.write("#BSUB -e %J.err\n")
00319                             lsf_input.write("#BSUB -J calculix\n")
00320                             lsf_input.write("#BSUB -q loc_all_hiio\n")
00321                             lsf_input.write(str("datadir=\"" + self.params.GetString("Linux Home Path") + "/" + self.dirname[str(self.dirname).rfind("/")+1:] + "/" + filename_without_suffix + "/" + filename_without_suffix + 
00322                             "_"+"x_rot"+ str(int(j))+
00323                             "_"+"y_rot"+ str(int(k))+
00324                             "_"+"z_rot"+ str(int(l))+
00325                             "_"+"z_l"+ str(int(i)) + "\"\n"))
00326                             lsf_input.write("cd $datadir\n")
00327                             lsf_input.write(self.params.GetString("Solver Link") + " -i final_fe_input\n")
00328                             lsf_input.close()
00329                             
00330                             batch.write(str("cd \"" + self.params.GetString("Linux Home Path") + "/" + self.dirname[str(self.dirname).rfind("/")+1:] + "/" + filename_without_suffix + "/" + filename_without_suffix + 
00331                             "_"+"x_rot"+ str(int(j))+
00332                             "_"+"y_rot"+ str(int(k))+
00333                             "_"+"z_rot"+ str(int(l))+
00334                             "_"+"z_l"+ str(int(i)) + "\"\n"))
00335                             batch.write("job.lsf\n")
00336                             l= l + z_rot_intervall
00337                         k = k + y_rot_intervall
00338                     j = j + x_rot_intervall
00339                 i = i+ z_offset_intervall
00340         print "Ale Schleifen beendet"
00341         batch.write("cd \"" + self.params.GetString("Linux Home Path") + "\"\n")
00342         batch.write("find \"" + str(self.dirname[str(self.dirname).rfind("/")+1:] + "/") + "\" -name \"sigini_output.txt\" -exec rm -f {} \;\n")
00343         batch.write("find \"" + str(self.dirname[str(self.dirname).rfind("/")+1:] + "/") + "\" -name \"*.out\" -exec rm -f {} \;\n")
00344         batch.write("find \"" + str(self.dirname[str(self.dirname).rfind("/")+1:] + "/") + "\" -name \"*.err\" -exec rm -f {} \;\n")
00345         batch.write("find \"" + str(self.dirname[str(self.dirname).rfind("/")+1:] + "/") + "\" -name \"*.dat\" -exec rm -f {} \;\n")
00346         batch.write("find \"" + str(self.dirname[str(self.dirname).rfind("/")+1:] + "/") + "\" -name \"*.sta\" -exec rm -f {} \;\n")
00347         batch.write("tar cf \"" + str(self.dirname[str(self.dirname).rfind("/")+1:]  + ".tar\" \"" + str(self.dirname[str(self.dirname).rfind("/")+1:] + "/") + "\"\n"))
00348         batch.write("rm -rf \"" + str(self.dirname[str(self.dirname).rfind("/")+1:] + "/") + "\"\n")
00349         batch.close()
00350 
00351         os.chdir("c:/")
00352         fnull = open(os.devnull, 'w')
00353         #Generate the full zip name:
00354         zipname = tempfile.gettempdir() + "/" + str(self.dirname)[str(self.dirname).rfind("/")+1:] + ".zip"
00355         #Check if the zip file already exists. If yes, then we have to remove it
00356         if os.path.exists(zipname):
00357             try:
00358                 os.remove(zipname)
00359             except Exception,e:
00360                 print e
00361         
00362         #Zip the whole directory structure now and save the zip file in the temp folder for further processing
00363         commandline = FreeCAD.getHomePath() + "bin/7z a -tzip -mx=0 " + "\"" + zipname + "\" " + "\"" + str(self.dirname) + "\""
00364         result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00365         #somehow we have to check for a false return code!
00366         if not result:
00367             shutil.rmtree(str(self.dirname))
00368             
00369         #Now send the zip file to the server for calculation
00370         commandline = FreeCAD.getHomePath() + "bin/pscp -r -l "+ self.params.GetString("Linux User Name") + " -pw " + self.params.GetString("Linux Password") + " " + \
00371         "\"" + zipname + "\" " + self.params.GetString("Servername") + ":" + self.params.GetString("Linux Home Path")
00372         result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00373         #Now unzip, change into the directory and start the batch file
00374         commandline = FreeCAD.getHomePath() + "bin/plink -batch -l "+ self.params.GetString("Linux User Name") + " -pw " + self.params.GetString("Linux Password") + " " + \
00375         self.params.GetString("Servername") + " unzip -o \"" + self.params.GetString("Linux Home Path") + "/" + str(self.dirname)[str(self.dirname).rfind("/")+1:] + ".zip\""
00376         print commandline
00377         result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00378         commandline = FreeCAD.getHomePath() + "bin/plink -batch -l "+ self.params.GetString("Linux User Name") + " -pw " + self.params.GetString("Linux Password") + " " + \
00379         self.params.GetString("Servername") + " chmod +x -R \"" + self.params.GetString("Linux Home Path") + "/" + str(self.dirname)[str(self.dirname).rfind("/")+1:] + "\""
00380         print commandline
00381         result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00382         commandline = FreeCAD.getHomePath() + "bin/plink -batch -l "+ self.params.GetString("Linux User Name") + " -pw " + self.params.GetString("Linux Password") + " " + \
00383         self.params.GetString("Servername") + " chmod +x -R \"" + self.params.GetString("Linux Home Path") + "/" + str(self.dirname)[str(self.dirname).rfind("/")+1:] + "\""
00384         print commandline
00385         result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00386         #Now we copy the batch file one level ahead as otherwise we cannot delete the calculation folder 
00387         commandline = FreeCAD.getHomePath() + "bin/plink -batch -l "+ self.params.GetString("Linux User Name") + " -pw " + self.params.GetString("Linux Password") + " " + \
00388         self.params.GetString("Servername") + " mv \"" + self.params.GetString("Linux Home Path") + "/" + str(self.dirname)[str(self.dirname).rfind("/")+1:] + "/lcmt_CALCULIX_Calculation_batch.bat\" " + self.params.GetString("Linux Home Path") 
00389         print commandline
00390         result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00391         #commandline = "plink -batch -l UN -pw PW dynabox \'/home/rmjzettl/" + str(self.dirname[str(self.dirname).rfind("/")+1:] + "/") + "lcmt_CALCULIX_Calculation_batch.bat\'"
00392         #result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00393         #commandline = "pscp -r -l UN -pw PW dynabox:\"/home/rmjzettl/"+ str(self.dirname)[str(self.dirname).rfind("/")+1:] + ".tar\" " + str(self.dirname)[0:3]
00394         #result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00395         #commandline = "plink -batch -l UN -pw PW dynabox rm -f \"/home/rmjzettl/"+ str(self.dirname)[str(self.dirname).rfind("/")+1:] + ".tar\""
00396         #result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00397         #commandline = "plink -batch -l UN -pw PW dynabox rm -f \"/home/rmjzettl/"+ str(self.dirname)[str(self.dirname).rfind("/")+1:] + ".zip\""
00398         #result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00399         #commandline = "7z x \"" + str(self.dirname)[0:3] + str(self.dirname)[str(self.dirname).rfind("/")+1:] + ".tar\" -o\"" + str(self.dirname[0:str(self.dirname).rfind("/")]) + "\""
00400         #result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00401         #commandline = "del /Q \"" + str(self.dirname)[0:3] + str(self.dirname)[str(self.dirname).rfind("/")+1:] + ".tar\""
00402         #result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00403         #commandline = "del /Q \"" + str(self.dirname)[0:3] + str(self.dirname)[str(self.dirname).rfind("/")+1:] + ".zip\""
00404         #result = subprocess.call(commandline, shell = True, stdout = fnull, stderr = fnull)
00405 
00406         fnull.close()
00407         #Reset the GUI
00408         os.chdir("c:/")
00409         #Reset the table to be fully empty
00410         i = self.JobTable.rowCount()
00411         while i > 0:
00412             print i
00413             self.JobTable.removeRow(i-1)
00414             i = i-1
00415 
00416         print "after"
00417         self.JobTable.setHorizontalHeaderLabels(
00418         ["Input File","Output Folder","Z-Offset From","Z-Offset To","Z-Intervall","X-Rot From","X-Rot To","X-Rot Intervall",
00419         "Y-Rot From","Y-Rot To","Y-Rot Intervall","Z-Rot From","Z-Rot To","Z-Rot Intervall","Young Modulus","Poisson Ratio",
00420         "LC1","LC2","LC3","LC4","LC5","LC6","LTC1","LTC2","LTC3","LTC4","LTC5","LTC6","Plate Thickness"])
00421         self.button_select_file.setEnabled(True)
00422         self.button_select_output.setEnabled(True)
00423 
00424 
00425 ##Main function to be used for GUI setup and entering into the main loop
00426 if __name__ == "__main__":
00427     app = QtGui.QApplication(sys.argv)
00428     myapp = MyForm()
00429     myapp.show()
00430     sys.exit(app.exec_())
00431 
00432 
00433 
00434 
00435 
00436 
00437 
00438 
00439 

Generated on Wed Nov 23 19:00:20 2011 for FreeCAD by  doxygen 1.6.1