Skip to content

Commit

Permalink
Merge pull request #11997 from ericvaandering/fix_standarderror
Browse files Browse the repository at this point in the history
StandardError is now Exception
  • Loading branch information
davidlange6 committed Oct 22, 2015
2 parents 5a2c839 + fa69e3f commit 9487b63
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
Expand Up @@ -57,7 +57,7 @@ def queryStatusXML(filename):

try:
report = loadIMProvFile(filename)
except StandardError, ex:
except Exception, ex:
msg = "Error reading CRAB Status Report: %s\n" % filename
msg += str(ex)
raise RuntimeError, msg
Expand Down
8 changes: 4 additions & 4 deletions Geometry/TrackerCommonData/data/Materials/insertMaterial.py
Expand Up @@ -36,7 +36,7 @@ def readFractions(fileName, materialMap):
for fraction in result[material][1]:
sum+= result[material][1][fraction]
if math.fabs(sum - 1.0) > maxDist:
raise StandardError, "Material Fractions do not add up to 100%: "+ material+" "+str(sum)
raise Exception, "Material Fractions do not add up to 100%: "+ material+" "+str(sum)
return result

#get a source:material from the [material] only
Expand Down Expand Up @@ -68,7 +68,7 @@ def getSection(rootNode, name):
if node.nodeName == name:
result = node
if result == None:
raise StandardError, "Could not find: \""+name+"\" in childnodes of the rootNode!"
raise Exception, "Could not find: \""+name+"\" in childnodes of the rootNode!"
return result

#returns a map of [name] nodes by their names. stating from rootNode
Expand Down Expand Up @@ -172,9 +172,9 @@ def main():
(options, args) = optParser.parse_args()

if options.titlesFile == None:
raise StandardError, "no .titles File given!"
raise Exception, "no .titles File given!"
if options.xmlFile == None:
raise StandardError, "no .xml File given!"
raise Exception, "no .xml File given!"
if options.output == None:
options.output = "materialOutput.xml"
if options.materialMap == None:
Expand Down
12 changes: 6 additions & 6 deletions Geometry/TrackerCommonData/data/Materials/twikiExport.py
Expand Up @@ -6,7 +6,7 @@
class Constituent:
def __init__(self, line, predefinedMaterials):
if len(line.split('"')) < 5 or len(line.split('"')[4].split()) < 3:
raise StandardError , "not a well formed Constituent: "+constString
raise Exception , "not a well formed Constituent: "+constString
self.theDescription = line.split('"')[1]
self.theName = line.split('"')[3]
self.theCount = float(line.split('"')[4].split()[1])
Expand All @@ -23,11 +23,11 @@ def __str__(self):
class Material:
def __init__(self, matString, comment):
if matString == "" or not matString[0] == "#":
raise StandardError , "not a valid material Definition: "+matString
raise Exception , "not a valid material Definition: "+matString
line = matString[1:]

if len( line.split('"') ) < 5 or len( line.split('"')[4].split() ) < 2:
raise StandardError , "not a well formed Material Definition: "+matString
raise Exception , "not a well formed Material Definition: "+matString
self.theDescription = line.split('"')[1]
self.theName = line.split('"')[3]
self.theMcVolume = float(line.split('"')[4].split()[0])
Expand Down Expand Up @@ -72,13 +72,13 @@ def getMass(self):

def addConstituent(self, constString, predefinedMaterials):
if constString == "" or not constString[0] == "*":
raise StandardError , "not a valid Constituent: "+constString
raise Exception , "not a valid Constituent: "+constString
line = constString[1:]
self.theConstituents.append( Constituent(line, predefinedMaterials) )

number = int( line.split('"')[0].split()[0] )
if not len(self.theConstituents) == number:
raise StandardError, "Constituent Number mismatch for "+str(len(self.theConstituents))+" in: "+line
raise Exception, "Constituent Number mismatch for "+str(len(self.theConstituents))+" in: "+line

def __str__(self):
result = "[ "+self.theName+" Description: "+self.theDescription+" MC-Volume:"+str(self.theMcVolume)+"\n"
Expand Down Expand Up @@ -191,7 +191,7 @@ def main():
(options, args) = optParser.parse_args()

if options.inFile == None:
raise StandardError, "no .in File given!"
raise Exception, "no .in File given!"
if options.output == None:
options.output = options.inFile.replace(".in",".twiki")
if options.config == None:
Expand Down
2 changes: 1 addition & 1 deletion PhysicsTools/PatAlgos/python/tools/helpers.py
Expand Up @@ -224,7 +224,7 @@ def _newLabel(self, label):
if label[-len(self._removePostfix):] == self._removePostfix:
label = label[0:-len(self._removePostfix)]
else:
raise StandardError("Tried to remove postfix %s from label %s, but it wasn't there" % (self._removePostfix, label))
raise Exception("Tried to remove postfix %s from label %s, but it wasn't there" % (self._removePostfix, label))
return label + self._postfix

def __appendToTopSequence(self, visitee):
Expand Down
Expand Up @@ -733,7 +733,7 @@ def removePostfix(self, name, postfix):
if baseName[-len(postfix):] == postfix:
baseName = baseName[0:-len(postfix)]
else:
raise StandardError("Tried to remove postfix %s from %s, but it wasn't there" % (postfix, baseName))
raise Exception("Tried to remove postfix %s from %s, but it wasn't there" % (postfix, baseName))

return baseName

Expand Down
2 changes: 1 addition & 1 deletion PhysicsTools/PythonAnalysis/python/cmstools.py
Expand Up @@ -170,7 +170,7 @@ def __call__(self):
return self._buffer


class cmserror(exceptions.StandardError):
class cmserror(exceptions.Exception):
def __init__(self, message):
length = len(message)+7 #7=len("ERROR: ")
print "="*length
Expand Down
6 changes: 3 additions & 3 deletions RecoHI/HiEgammaAlgos/python/HiHelperTools.py
Expand Up @@ -158,12 +158,12 @@ def leave(self,visitee):
if self._waitForSequenceToClose == visitee.label():
self._waitForSequenceToClose = None
if not isinstance(self._sequenceStack[-1], cms.Sequence):
raise StandardError, "empty Sequence encountered during cloneing. sequnece stack: %s"%self._sequenceStack
raise Exception, "empty Sequence encountered during cloneing. sequnece stack: %s"%self._sequenceStack
self.__appendToTopSequence( self._sequenceStack.pop() )

def clonedSequence(self):
if not len(self._sequenceStack) == 1:
raise StandardError, "someting went wrong, the sequence stack looks like: %s"%self._sequenceStack
raise Exception, "someting went wrong, the sequence stack looks like: %s"%self._sequenceStack
for label in self._moduleLabels:
massSearchReplaceAnyInputTag(self._sequenceStack[-1], label, label+self._postfix, moduleLabelOnly=True, verbose=False)
self._moduleLabels = [] #prevent the InputTag replacement next time this is called.
Expand All @@ -175,7 +175,7 @@ def __appendToTopSequence(self, visitee):#this is darn ugly because empty cms.Se
newSequenceLabel = oldSequenceLabel + self._postfix
self._sequenceStack.append(cms.Sequence(visitee))
if hasattr(self._process, newSequenceLabel):
raise StandardError("Cloning the sequence "+self._sequenceStack[-1].label()+" would overwrite existing object." )
raise Exception("Cloning the sequence "+self._sequenceStack[-1].label()+" would overwrite existing object." )
setattr(self._process, newSequenceLabel, self._sequenceStack[-1])
self._sequenceLabels.append(oldSequenceLabel)
else:
Expand Down

0 comments on commit 9487b63

Please sign in to comment.