MueLu
Version of the Day
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
escapeXMLfile.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
#import os.path
4
import
os
5
import
sys
6
import
math
7
8
def
getstatusoutput
(cmd):
9
"""Return (status, output) of executing cmd in a shell."""
10
pipe = os.popen(cmd +
' 2>&1'
,
'
r')
11
text = pipe.read()
12
sts = pipe.close()
13
if
sts
is
None
: sts = 0
14
if
text[-1:] ==
'\n'
: text = text[:-1]
15
return
sts, text
16
17
18
def
deleteDir
(path):
19
"""deletes the path entirely"""
20
cmd =
"rm -rf "
+path
21
result =
getstatusoutput
(cmd)
22
if(result[0]!=0):
23
raise
RuntimeError(result[1])
24
25
def
createDir
(path):
26
"""deletes the path entirely"""
27
cmd =
"mkdir "
+path
28
result =
getstatusoutput
(cmd)
29
if(result[0]!=0):
30
raise
RuntimeError(result[1])
31
32
def
runCommand
(cmd):
33
"""deletes the path entirely"""
34
result =
getstatusoutput
(cmd)
35
#if(result[0]!=0):
36
# raise RuntimeError(result[1])
37
return
result[1]
38
39
###########
40
# MAIN routine
41
def
main
(argv=None):
42
43
filename_input =
"ic-test.xml"
44
filename_output =
"ic-test.out"
45
46
47
48
# generate XML file for pre_exodus
49
if
os.path.isfile(filename_output):
50
os.remove(filename_output)
51
o = open(filename_output,
"a"
)
52
for
line
in
open(filename_input):
53
line = line.replace(
"\""
,
"\\\""
)
54
line = line.replace(
"<"
,
"\"<"
)
55
line = line.replace(
">"
,
">\""
)
56
o.write(line)
57
o.close()
58
59
if
__name__ ==
"__main__"
:
60
sys.exit(
main
())
61
escapeXMLfile.runCommand
def runCommand
Definition:
escapeXMLfile.py:32
escapeXMLfile.deleteDir
def deleteDir
Definition:
escapeXMLfile.py:18
escapeXMLfile.getstatusoutput
def getstatusoutput
Definition:
escapeXMLfile.py:8
escapeXMLfile.main
def main
MAIN routine.
Definition:
escapeXMLfile.py:41
escapeXMLfile.createDir
def createDir
Definition:
escapeXMLfile.py:25
src
Interface
FacadeClasses
escapeXMLfile.py
Generated on Thu Nov 21 2024 09:31:30 for MueLu by
1.8.5