MueLu Version of the Day
Loading...
Searching...
No Matches
escapeXMLfile.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3#import os.path
4import os
5import sys
6import math
7
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
18def 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
25def 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
32def 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
41def 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("<", "\"&lt;")
55 line = line.replace(">", "&gt;\"")
56 o.write(line)
57 o.close()
58
59if __name__ == "__main__":
60 sys.exit(main())
61
def runCommand(cmd)
def main(argv=None)
MAIN routine.
def createDir(path)
def getstatusoutput(cmd)
Definition: escapeXMLfile.py:8
def deleteDir(path)