ATLAS Offline Software
Loading...
Searching...
No Matches
dq_defect_populate_virtual_defects.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3if __name__ == '__main__':
4 import optparse, sys, re, yaml
5 parser = optparse.OptionParser()
6 parser.usage = 'Usage: %prog [options] inputfile(s)'
7 parser.add_option('--db', default='test_defects.db/COMP200',
8 help='Change database virtual defects will be added to')
9 parser.add_option('--create', default=False, action='store_true',
10 help='Will create database if set')
11 parser.add_option('--tag', default='HEAD',
12 help='Choose tag to store virtual defects in')
13
15
16
17 opts, args = parser.parse_args()
18
19 if len(args) < 1:
20 parser.print_help()
21 sys.exit(1)
22
23 indict = {}
24 for f in args:
25 try:
26 tmp_indict = yaml.safe_load(open(f, 'r'))
27 except yaml.scanner.ScannerError as e:
28 print('ERROR: Problem parsing file', f)
29 print(str(e))
30 sys.exit(1)
31 if not tmp_indict:
32 print('NOTICE: No definitions in file', f)
33 continue
34 interset = set(tmp_indict) & set(indict)
35 if len(interset) > 0:
36 for k in interset:
37 print('WARNING: Redefinition of defect', k, 'in file', f)
38 if not opts.ignore_redef:
39 sys.exit(1)
40 indict.update(tmp_indict)
41
42 #print '\n'.join(map(str,tocreate))
43 from DQDefects import DefectsDB
44 from DQDefects.exceptions import DefectUnknownError
45 ddb = DefectsDB(opts.db, create=opts.create, read_only=False,
46 tag=opts.tag)
47
48 print('Now updating defects on', opts.db)
49 with ddb.storage_buffer:
50 for defect, clause in indict.items():
51 print(defect, clause)
52 try:
53 ddb.update_virtual_defect(defect, ' '.join(clause))
54 except DefectUnknownError:
55 ddb.new_virtual_defect(defect, '', ' '.join(clause))
56 #print 'ERROR: defect', defect, 'not present in DB, unable to update'
57 #sys.exit(1)
void print(char *figname, TCanvas *c1)
STL class.