1 | import os,XDR |
---|
2 | |
---|
3 | from avbp import plugin_avbp |
---|
4 | from avtp import plugin_avtp |
---|
5 | from prissma import plugin_prissma |
---|
6 | |
---|
7 | |
---|
8 | class local_unix(XDR.Plugin): |
---|
9 | |
---|
10 | def __init__(self,typePlugin): |
---|
11 | XDR.Plugin.__init__(self, typePlugin) |
---|
12 | |
---|
13 | |
---|
14 | def sendDirectory(self,directory): |
---|
15 | |
---|
16 | if os.path.exists(directory): |
---|
17 | return 1 |
---|
18 | else: |
---|
19 | raise Exception("Error : "+directory+" doesn't exist") |
---|
20 | |
---|
21 | def executeDistantCommand(self,command,execDirectory,appli,flags=[]): |
---|
22 | ######## |
---|
23 | # INITS |
---|
24 | ######## |
---|
25 | command_exe = command |
---|
26 | supported_applis = [] |
---|
27 | local_directory = os.getcwd() |
---|
28 | project_name = XDR.getValue("name","project","meta") |
---|
29 | |
---|
30 | |
---|
31 | hostname = "KALI" |
---|
32 | pythonexec= "/usr/bin/python" |
---|
33 | hip_cur_version = "/home/rolex/HIP/1.41.0/hip-1.41.0-"+hostname |
---|
34 | |
---|
35 | ################################################################################################################################## |
---|
36 | ################################################################################################################################## |
---|
37 | ################################################################################################################################## |
---|
38 | |
---|
39 | ##################### |
---|
40 | # SECTION DEPENDING ON APPLICATIONS |
---|
41 | #################### |
---|
42 | supported_applis.append("tool_avsp52") |
---|
43 | supported_applis.append("tool_avbp621") |
---|
44 | supported_applis.append("tool_avtp2") |
---|
45 | supported_applis.append("tool_prissma") |
---|
46 | supported_applis.append("tool_icritles") |
---|
47 | supported_applis.append("mps_script") |
---|
48 | supported_applis.append("hip_script") |
---|
49 | supported_applis.append("hip_current") |
---|
50 | supported_applis.append("dummy") |
---|
51 | |
---|
52 | if appli not in supported_applis: |
---|
53 | XDR.error("this application requires the application tag "+ appli+ ", which is not supported by the plugin local_unix.") |
---|
54 | |
---|
55 | ######## |
---|
56 | # AVBP # |
---|
57 | ######## |
---|
58 | if appli == "tool_avbp621": |
---|
59 | avbp_home = "/home/rolex/AVBP_V6.X/AVBP_D6.2.1" |
---|
60 | avbptool = plugin_avbp(avbp_home,hostname,hip_cur_version,pythonexec,execDirectory) |
---|
61 | command_exe = avbptool.switch_avbp_tools(appli,command) |
---|
62 | |
---|
63 | |
---|
64 | ####### |
---|
65 | # HIP # |
---|
66 | ####### |
---|
67 | if appli == "hip_current": |
---|
68 | if command.startswith("-c3sm_auto_hip-"): |
---|
69 | command_exe = command.replace("-c3sm_auto_hip-",hip_cur_version) |
---|
70 | elif command == "-c3s_auto_hip_scripttxt-": |
---|
71 | command_exe= hip_cur_version+" < ./script.txt" |
---|
72 | |
---|
73 | if appli == "hip_script": |
---|
74 | command_exe = hip_cur_version+" < " + command |
---|
75 | |
---|
76 | |
---|
77 | ######## |
---|
78 | # AVSP # |
---|
79 | ######## |
---|
80 | if appli == "tool_avsp52": |
---|
81 | avsp_home = "/home/rolex/QUIET_5.3/AVSP_HOME" |
---|
82 | # Temporary, bug with axisym duplication in HIP v1.41.0 |
---|
83 | hip_cur_version = "/home/rolex/HIP/1.40.1/hip-1.40.1-"+hostname |
---|
84 | avsptool = plugin_avsp(avsp_home,hostname,hip_cur_version,pythonexec,execDirectory) |
---|
85 | command_exe = avsptool.switch_avsp_tools(appli,command) |
---|
86 | |
---|
87 | ######## |
---|
88 | # AVTP # |
---|
89 | ######## |
---|
90 | if appli == "tool_avtp2": |
---|
91 | avtp_home = "/home/rolex/AVTP/AVTP_V2.X" |
---|
92 | avtptool = plugin_avtp(avtp_home,hostname,hip_cur_version,pythonexec,execDirectory) |
---|
93 | command_exe = avtptool.switch_avtp_tools(appli,command) |
---|
94 | |
---|
95 | ############ |
---|
96 | # ICRITLES # |
---|
97 | ############ |
---|
98 | if appli == "tool_icritles": |
---|
99 | if command == "-c3sm_auto_icritles-": |
---|
100 | avbp_home = "/home/rolex/AVBP_V6.X/AVBP_D6.2.1" |
---|
101 | command_exe = avbp_home+"/HOST/"+hostname+"/TOOLEXEC/i_crit_les.e_"+hostname |
---|
102 | |
---|
103 | ########### |
---|
104 | # PRISSMA # |
---|
105 | ########### |
---|
106 | if appli == "tool_prissma": |
---|
107 | avbp_home = "/home/rolex/AVBP_V6.X/AVBP_D6.2.1" |
---|
108 | prissma_home = "/home/avtp_wkdir/PRISSMA/trunk/" |
---|
109 | prissmatool = plugin_prissma(prissma_home,avbp_home,hostname,hip_cur_version,pythonexec,execDirectory) |
---|
110 | command_exe = prissmatool.switch_prissma_tools(appli,command) |
---|
111 | |
---|
112 | ######## |
---|
113 | # MPS # |
---|
114 | ######## |
---|
115 | if appli == "mps_script": |
---|
116 | if command.startswith("-c3sm_auto"): |
---|
117 | if command == "-c3sm_auto_mps-" : |
---|
118 | datafile = os.path.join(local_directory,execDirectory,"aerotherm.xml") |
---|
119 | execDirectory = "/home/rolex/multiphysics_setup" |
---|
120 | command_exe = "mpview -aerotherm_xml "+datafile |
---|
121 | |
---|
122 | ################################################################################################################################## |
---|
123 | ################################################################################################################################## |
---|
124 | ################################################################################################################################## |
---|
125 | |
---|
126 | os.chdir(execDirectory) |
---|
127 | output = XDR.execute(command_exe) |
---|
128 | os.chdir(local_directory) |
---|
129 | return output |
---|
130 | |
---|
131 | def retrieveDirectory(self,directory): |
---|
132 | # Do nothing as we are local |
---|
133 | pass |
---|
134 | |
---|
135 | def removeDirectory(self,directory): |
---|
136 | pass |
---|
137 | |
---|