Coverage for bin.src/dagIdInfo.py : 81%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python
2#
3# LSST Data Management System
4# Copyright 2008-2016 LSST Corporation.
5#
6# This product includes software developed by the
7# LSST Project (http://www.lsst.org/).
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the LSST License Statement and
20# the GNU General Public License along with this program. If not,
21# see <http://www.lsstcorp.org/LegalNotices/>.
22#
24import sys
25import os
26import re
27import errno
29# extracts a line from a DAG file to show which ids were processed for a
30# particular dag node
31if __name__ == "__main__": 31 ↛ exitline 31 didn't exit the module, because the condition on line 31 was never false
33 if len(sys.argv) != 3: 33 ↛ 34line 33 didn't jump to line 34, because the condition on line 33 was never true
34 print("usage: %s dagNodeName filename" % os.path.basename(sys.argv[0]))
35 sys.exit(errno.EINVAL)
37 dagNode = sys.argv[1]
38 filename = sys.argv[2]
40 if not os.path.exists(filename): 40 ↛ 41line 40 didn't jump to line 41, because the condition on line 40 was never true
41 print("file %s not found" % filename)
42 sys.exit(errno.ENOENT)
44 ex = r'VARS %s var1=\"(?P<idlist>.+?)\"' % dagNode
45 file = open(filename)
46 for line in file:
47 line = line.rstrip(' \n')
49 # look for the line with the dagnode name in it
50 # and extract everything after "var1", but not the quotes
51 values = re.search(ex, line)
52 if values is None:
53 continue
54 ids = values.groupdict()['idlist']
55 file.close()
56 print(ids)
57 sys.exit(0)
58 file.close()
59 sys.exit(0)