-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcatReplace.py
More file actions
executable file
·37 lines (26 loc) · 988 Bytes
/
catReplace.py
File metadata and controls
executable file
·37 lines (26 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!./python
import sys
import os
if "LIB_PY_MISC" not in os.environ:
sys.path.insert (0, '/usr/local/mgi/live/lib/python/')
else:
sys.path.insert (0, os.environ["LIB_PY_MISC"])
import Configuration
config = Configuration.get_Configuration ("webshare.config")
config.merge(Configuration.get_Configuration (config['GLOBAL_CONFIG']))
config.merge(Configuration.get_Configuration (config['COMMON_CONFIG']))
shellContents = ''
for arg in sys.argv[1:]:
# if the file exists, read it in
if os.path.exists(arg):
fileObject = open(arg, mode='r')
for line in fileObject:
shellContents = shellContents + line
fileObject.close()
#for each config parameter, update the shell files
for key in list(config.keys()):
searchKey = "${" + key + "}"
replaceValue = config[key]
shellContents = shellContents.replace(searchKey, replaceValue)
#return translated string representation of file
print(shellContents)