Skip to content

Commit 2aa4145

Browse files
authored
Fixed parser.py to look like apelparser
1 parent f6edd31 commit 2aa4145

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

bin/parser.py

+28-17
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# - BLAH
1919
# - PBS
2020
# - SGE
21-
# - LSF
21+
# - LSF (5.x to 9.x)
2222

2323
'''
2424
@author: Konrad Jopek, Will Rogers
@@ -44,7 +44,7 @@
4444
from apel.parsers.pbs import PBSParser
4545
from apel.parsers.slurm import SlurmParser
4646
from apel.parsers.htcondor import HTCondorParser
47-
47+
from apel.parsers.htcondorce import HTCondorCEParser
4848

4949
LOGGER_ID = 'parser'
5050
# How many records should be put/fetched to/from database
@@ -57,10 +57,10 @@
5757
'SGE': SGEParser,
5858
'SLURM': SlurmParser,
5959
'blah' : BlahParser,
60-
'HTCondor': HTCondorParser,
60+
'htcondorce' : HTCondorCEParser,
61+
'HTCONDOR' : HTCondorParser
6162
}
6263

63-
6464
class ParserConfigException(Exception):
6565
'''
6666
Exception raised when parser is misconfigured.
@@ -154,14 +154,20 @@ def scan_dir(parser, dirpath, reparse, expr, apel_db, processed):
154154
'''
155155
log = logging.getLogger(LOGGER_ID)
156156
updated = []
157+
158+
parserName = parser.__class__.__name__
157159
try:
158160
log.info('Scanning directory: %s', dirpath)
159161

160-
for item in sorted(os.listdir(dirpath)):
162+
for item in os.listdir(dirpath):
161163
abs_file = os.path.join(dirpath, item)
162164
if os.path.isfile(abs_file) and expr.match(item):
163165
# first, calculate the hash of the file:
164-
file_hash = calculate_hash(abs_file)
166+
if parserName == "HTCondorCEParser":
167+
file_hash = "htce_" + calculate_hash(abs_file)
168+
else:
169+
file_hash = calculate_hash(abs_file)
170+
165171
found = False
166172
unparsed = False
167173
# next, try to find corresponding entry
@@ -238,6 +244,8 @@ def handle_parsing(log_type, apel_db, cp):
238244
log.info('Setting up parser for %s files', log_type)
239245
if log_type == 'blah':
240246
section = 'blah'
247+
if log_type == 'htcondorce':
248+
section = 'htcondorce'
241249
else:
242250
section = 'batch'
243251

@@ -277,21 +285,13 @@ def handle_parsing(log_type, apel_db, cp):
277285
raise ParserConfigException(e)
278286
except KeyError, e:
279287
raise ParserConfigException("Not a valid parser type: %s" % e)
280-
281-
# Set parser specific options
288+
282289
if log_type == 'LSF':
283290
try:
284291
parser.set_scaling(cp.getboolean('batch', 'scale_host_factor'))
285292
except ConfigParser.NoOptionError:
286-
log.warning("Option 'scale_host_factor' not found in section 'batch"
287-
"'. Will default to 'false'.")
288-
elif log_type == 'SGE':
289-
try:
290-
parser.set_ms_timestamps(cp.getboolean('batch', 'ge_ms_timestamps'))
291-
except ConfigParser.NoOptionError:
292-
log.warning("Option 'ge_ms_timestamps' not found in section 'batch'"
293-
" . Will default to 'false'.")
294-
293+
pass
294+
295295
# regular expressions for blah log files and for batch log files
296296
try:
297297
prefix = cp.get(section, 'filename_prefix')
@@ -390,6 +390,17 @@ def main():
390390
log.info(LOG_BREAK)
391391
sys.exit(1)
392392

393+
log.info(LOG_BREAK)
394+
# htcondorce parsing
395+
try:
396+
if cp.getboolean('htcondorce', 'enabled'):
397+
handle_parsing('htcondorce', apel_db, cp)
398+
except (ParserConfigException, ConfigParser.NoOptionError), e:
399+
log.fatal('Parser misconfigured: %s', e)
400+
log.fatal('Parser will exit.')
401+
log.info(LOG_BREAK)
402+
sys.exit(1)
403+
393404
log.info(LOG_BREAK)
394405
# batch parsing
395406
try:

0 commit comments

Comments
 (0)