Changeset 667
- Timestamp:
- 09/14/12 14:45:50 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jobmond/jobmond.py
r666 r667 91 91 return loadConfig( config_filename ) 92 92 93 # Fixme: This doesn't DTRT with commented-out bits of the file. E.g.94 # it picked up a commented-out `mcast_join' and tried to use a95 # multicast channel when it shouldn't have done.96 93 class GangliaConfigParser: 97 94 … … 140 137 def getVal( self, section, valname ): 141 138 139 debug_msg( 10, "Parsing: '" + self.config_file + "' - searching for section: " + section + " value: " + valname ) 140 142 141 cfg_fp = open( self.config_file ) 143 142 cfg_lines = cfg_fp.readlines() … … 146 145 section_start = False 147 146 section_found = False 147 include_start = False 148 148 value = None 149 149 comment_start = False 150 150 151 acc_count = 0 152 151 153 for line in cfg_lines: 152 154 153 155 line = line.strip() 156 debug_msg( 10, "line org: " + line ) 154 157 line = self.removeComments( line ) 155 156 if line.find( '/*' ) != -1: 157 158 line = line[:line.find('/*')] 159 comment_start = True 160 161 if line.find( '*/' ) != -1: 162 163 line = line[line.find('*/'):] 158 debug_msg( 10, "line remove comments: " + line ) 159 160 if line.find( '/*' ) != -1 and line.find( 'include', 0, 7 ): 161 162 debug_msg( 10, "line comment start */: " + line ) 163 164 if line.find( '*/' ) != -1: 165 166 begin_line = line[:line.find('/*')] 167 rest_line = line[(line.find('*/')+2):] 168 169 line = begin_line + rest_line 170 171 debug_msg( 10, "line comment end */: " + line ) 172 173 else: 174 175 line = line[:line.find('/*')] 176 comment_start = True 177 178 debug_msg( 10, "line find /*: " + line ) 179 180 debug_msg( 10, "line find /*: " + line ) 181 182 if line.find( '*/' ) != -1 and comment_start: 183 184 line = line[(line.find('*/')+2):] 164 185 comment_start = False 186 debug_msg( 10, "line comment end*/: " + line ) 165 187 166 188 if comment_start: 167 189 190 debug_msg( 10, "line ignoring comment: " + line ) 168 191 continue 169 192 170 193 if line.find( 'include' ) != -1: 171 194 172 line = line.removeHaakjes() 173 174 include_line = line.strip(' ')[1:] 195 debug_msg( 10, "line include: " + line ) 196 line = self.removeHaakjes( line ) 197 line = self.removeQuotes( line ) 198 debug_msg( 10, "line removeHaakjes: " + line ) 199 200 include_line = line.split(' ')[1] 201 202 debug_msg( 10, "line includes: " + str( include_line ) ) 175 203 176 204 for include_file in glob( include_line ): 205 206 debug_msg( 10, "include file found: '" + include_file + "'" ) 177 207 178 208 include_parser = GangliaConfigParser( include_file ) … … 184 214 #break ? FIXME value can be overriden by other includes: perhaps users problem 185 215 216 debug_msg( 10, "VALUE found: '" + value + "'" ) 217 186 218 del include_parser 187 219 … … 190 222 section_found = True 191 223 224 debug_msg( 10, "section start: '" + section + "'" ) 225 192 226 if line.find( '{' ) != -1 and section_found: 193 227 194 228 section_start = True 229 acc_count = acc_count + 1 195 230 196 231 if line.find( '}' ) != -1 and section_found: 197 232 198 section_start = False 199 section_found = False 233 acc_count = acc_count - 1 234 235 if acc_count == 0: 236 237 debug_msg( 10, "section closed: '" + section + "'" ) 238 section_start = False 239 section_found = False 200 240 201 241 if line.find( valname ) != -1 and section_start: 202 242 203 243 value = string.join( line.split( '=' )[1:], '' ).strip() 244 245 debug_msg( 10, "Parsing done: '" + self.config_file + "' " ) 204 246 205 247 return value
Note: See TracChangeset
for help on using the changeset viewer.