Coverage for bin.src/dagIdInfo.py: 81%
26 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-24 03:05 -0700
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-24 03:05 -0700
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 errno
25import os
26import re
27import sys
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
32 if len(sys.argv) != 3: 32 ↛ 33line 32 didn't jump to line 33, because the condition on line 32 was never true
33 print("usage: %s dagNodeName filename" % os.path.basename(sys.argv[0]))
34 sys.exit(errno.EINVAL)
36 dagNode = sys.argv[1]
37 filename = sys.argv[2]
39 if not os.path.exists(filename): 39 ↛ 40line 39 didn't jump to line 40, because the condition on line 39 was never true
40 print("file %s not found" % filename)
41 sys.exit(errno.ENOENT)
43 ex = r"VARS %s var1=\"(?P<idlist>.+?)\"" % dagNode
44 file = open(filename)
45 for line in file:
46 line = line.rstrip(" \n")
48 # look for the line with the dagnode name in it
49 # and extract everything after "var1", but not the quotes
50 values = re.search(ex, line)
51 if values is None:
52 continue
53 ids = values.groupdict()["idlist"]
54 file.close()
55 print(ids)
56 sys.exit(0)
57 file.close()
58 sys.exit(0)