Changeset 268
- Timestamp:
- 09/14/2010 08:22:39 PM (13 years ago)
- Location:
- SHX/trunk/src/SeismicHandler
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
SHX/trunk/src/SeismicHandler
- Property svn:ignore
-
old new 3 3 .pydevproject 4 4 .shx.cfg.swp 5 .shx.conf.swp
-
- Property svn:ignore
-
SHX/trunk/src/SeismicHandler/modules/runtime.py
r258 r268 21 21 E.g. Echo Channel, Cap Conversion, ... 22 22 """ 23 import os.path24 23 25 24 import sys 26 25 import os 26 import ConfigParser 27 27 from SeismicHandler.basics import Property, Singleton, AttribDict 28 28 … … 90 90 """ 91 91 92 dirs = [ 93 "/etc", 94 # some weird fall-back if $HOME does not exists 95 os.getenv("HOME", "/etc"), 96 os.path.join(os.path.split(__file__)[0], ".."), 97 ] 98 99 for d in dirs: 100 if not os.path.exists(os.path.join(d, "shx.conf")): 101 continue 102 103 print "found in", d 104 92 dirs = { 93 "SHX": os.path.abspath(__file__).rsplit(os.path.sep, 2)[0], 94 "ETC": "/etc/SeismicHandler", 95 } 96 97 dir_home = os.getenv("HOME", None) 98 99 if dir_home: 100 dirs["PRIVATE"] = os.path.join(dir_home, ".shx") 101 102 for d in dirs.values(): 103 src = os.path.join(d, "shx.conf") 104 if os.path.exists(src): 105 break 106 107 config = ConfigParser.SafeConfigParser() 108 if not config.read(src): 109 raise Exception("configuration file not found!") 110 111 conf = AttribDict() 112 for s in config.sections(): 113 conf[s] = AttribDict() 114 for i in config.items(s): 115 conf[s][i[0]] = self.__handlePlaceholders(map(str.strip, \ 116 i[1].split(",")), dirs) 117 118 # check for include statement 119 if "include" in conf[s]: 120 121 # include sub configfile if requested 122 extra = ConfigParser.SafeConfigParser() 123 for e in conf[s]["include"]: 124 extra.read(e) 125 126 # only include current section 127 if not extra.has_section(s): 128 break 129 130 for ie in extra.items(s): 131 conf[s][ie[0]] = self.__handlePlaceholders(ie[1].split(","), dirs) 132 133 print conf 134 135 def __handlePlaceholders(self, values, dirs): 136 """ 137 Replace placeholders in config file. 138 """ 139 140 ret = [] 141 for v in values: 142 if v.startswith("["): 143 # replacement requested 144 for d in dirs.keys(): 145 if v.startswith("[%s]" % d): 146 # do replacement 147 ret.append(v.replace("[%s]" % d, dirs[d])) 148 149 else: 150 ret.append(v) 151 152 return ret 105 153 106 154 def __getattr__(self, name): -
SHX/trunk/src/SeismicHandler/modules/traces.py
r258 r268 26 26 class Traces(object): 27 27 """ 28 Supply access for two stream of traces. One is used for plotting, the other28 Supply access for two streams of traces. One is used for plotting, the other 29 29 holds hidden traces. This will be enhanced later, but for compatibility 30 30 reasons to existing command procedures it's done that ways first. -
SHX/trunk/src/SeismicHandler/shx.conf
r258 r268 2 2 # Main configuration file for Seismic Handler 3 3 # 4 # The string [SHX] is replaced by installation directory, 5 # [PRIVATE] is replaced by $HOME/.shx/ 4 # Following replacements are performed: 5 # 6 # [SHX] is replaced by installation directory, 7 # [PRIVATE] is replaced by $HOME/.shx, 8 # [ETC] is replaced by /etc/SeismicHandler 6 9 # 7 10 … … 9 12 scripts = [SHX]/scripts/,[PRIVATE]/scripts/ 10 13 filters = [SHX]/filters/,[PRIVATE]/filters/ 11 stations = [SHX]/stations/,[PRIVATE]/stations/ 14 stations = [SHX]/stations/,[PRIVATE]/stations/,/mnt/stations/ 12 15 13 16 [miniseed] … … 15 18 16 19 [graphics] 17 include = [PRIVATE]/graphics.cfg 20 height = 768 21 width = 1024 22 23 # It is possible to include another configuration file. It has to 24 # contain the section name to which information should be attached. 25 # Any include statement will be treated last regardless of it's position 26 # in the section! 27 include = [PRIVATE]/graphics.cfg, [PRIVATE]/graphics2.cfg 28 # If the included configuration file is not found, the error will be 29 # passed silently.
Note: See TracChangeset
for help on using the changeset viewer.