Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply necessary changes to work with python3 #31166

Merged
merged 1 commit into from Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 11 additions & 10 deletions CondTools/SiPixel/test/SiPixelGenErrorDBObjectUploader_cfg.py
@@ -1,6 +1,7 @@
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as opts
import csv
from io import open

options = opts.VarParsing ('standard')

Expand Down Expand Up @@ -62,37 +63,37 @@
options.parseArguments()

MagFieldValue = 10.*options.MagField #code needs it in deciTesla
print '\nMagField = %f deciTesla \n'%(MagFieldValue)
print('\nMagField = %f deciTesla \n'%(MagFieldValue))
version = options.Version
print'\nVersion = %s \n'%(version)
print('\nVersion = %s \n'%(version))
magfieldstrsplit = str(options.MagField).split('.')
MagFieldString = magfieldstrsplit[0]
if len(magfieldstrsplit)>1 :
MagFieldString+=magfieldstrsplit[1]

#open the map file
mapfile = open(options.Map,'rUb')
mapfile = open(options.Map,'rU', newline='')
#read the csv file into a reader
mapfilereader = csv.reader(mapfile,delimiter=options.Delimiter,quotechar=options.Quotechar)
#separate into the different sections
barrel_rule_lines = []; endcap_rule_lines = []
barrel_exception_lines = []; endcap_exception_lines = []
sections = [barrel_rule_lines, endcap_rule_lines, barrel_exception_lines, endcap_exception_lines]
i=0; line = mapfilereader.next()
i=0; line = next(mapfilereader)
for i in range(len(sections)) :
while line[0].find('TEMPLATE ID')==-1 : #skip to just before the section of info
line=mapfilereader.next()
line=next(mapfilereader)
try :
line=mapfilereader.next()
line=next(mapfilereader)
except StopIteration :
print 'Done reading input file'
print('Done reading input file')
break
while line[1]!='' : #add the lines that are the barrel rules
sections[i].append(line)
try :
line=mapfilereader.next()
line=next(mapfilereader)
except StopIteration :
print 'Done reading input file'
print('Done reading input file')
break
#print 'barrel rules = %s\nendcap rules = %s\nbarrel exceptions = %s\nendcap exceptions = %s'%(barrel_rule_lines,endcap_rule_lines,barrel_exception_lines,endcap_exception_lines) #DEBUG
#Make the lists of location strings and template IDs
Expand Down Expand Up @@ -187,7 +188,7 @@
#output SQLite filename
sqlitefilename = 'sqlite_file:'+generror_base+'.db'

print '\nUploading %s with record SiPixelGenErrorDBObjectRcd in file %s\n' % (generror_base,sqlitefilename)
print( '\nUploading %s with record SiPixelGenErrorDBObjectRcd in file %s\n' % (generror_base,sqlitefilename))

process.source = cms.Source("EmptyIOVSource",
timetype = cms.string('runnumber'),
Expand Down
23 changes: 12 additions & 11 deletions CondTools/SiPixel/test/SiPixelTemplateDBObjectUploader_cfg.py
@@ -1,6 +1,7 @@
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as opts
import csv
from io import open

options = opts.VarParsing ('standard')

Expand Down Expand Up @@ -62,37 +63,37 @@
options.parseArguments()

MagFieldValue = 10.*options.MagField #code needs it in deciTesla
print '\nMagField = %f deciTesla \n'%(MagFieldValue)
print('\nMagField = %f deciTesla \n'%(MagFieldValue))
version = options.Version
print'\nVersion = %s \n'%(version)
print('\nVersion = %s \n'%(version))
magfieldstrsplit = str(options.MagField).split('.')
MagFieldString = magfieldstrsplit[0]
if len(magfieldstrsplit)>1 :
MagFieldString+=magfieldstrsplit[1]

#open the map file
mapfile = open(options.Map,'rUb')
mapfile = open(options.Map,'rU', newline='')
#read the csv file into a reader
mapfilereader = csv.reader(mapfile,delimiter=options.Delimiter,quotechar=options.Quotechar)
#separate into the different sections
barrel_rule_lines = []; endcap_rule_lines = []
barrel_exception_lines = []; endcap_exception_lines = []
sections = [barrel_rule_lines, endcap_rule_lines, barrel_exception_lines, endcap_exception_lines]
i=0; line = mapfilereader.next()
i=0; line = next(mapfilereader)
for i in range(len(sections)) :
while line[0].find('TEMPLATE ID')==-1 : #skip to just before the section of info
line=mapfilereader.next()
line=next(mapfilereader)
try :
line=mapfilereader.next()
line=next(mapfilereader)
except StopIteration :
print 'Done reading input file'
print('Done reading input file')
break
while line[1]!='' : #add the lines that are the barrel rules
sections[i].append(line)
try :
line=mapfilereader.next()
line=next(mapfilereader)
except StopIteration :
print 'Done reading input file'
print('Done reading input file')
break
#print 'barrel rules = %s\nendcap rules = %s\nbarrel exceptions = %s\nendcap exceptions = %s'%(barrel_rule_lines,endcap_rule_lines,barrel_exception_lines,endcap_exception_lines) #DEBUG
#Make the lists of location strings and template IDs
Expand Down Expand Up @@ -187,7 +188,7 @@
#output SQLite filename
sqlitefilename = 'sqlite_file:'+template_base+'.db'

print '\nUploading %s with record SiPixelTemplateDBObjectRcd in file %s\n' % (template_base,sqlitefilename)
print('\nUploading %s with record SiPixelTemplateDBObjectRcd in file %s\n' % (template_base,sqlitefilename))

process.source = cms.Source("EmptyIOVSource",
timetype = cms.string('runnumber'),
Expand Down Expand Up @@ -225,4 +226,4 @@
process.p = cms.Path(process.uploader)
process.CondDB.connect = sqlitefilename
process.CondDB.DBParameters.messageLevel = 0
process.CondDB.DBParameters.authenticationPath = './'
process.CondDB.DBParameters.authenticationPath = './'