def __init__(self, obj): ''' Private constructor, called by L{Symptom.fromJSONObject}. Do not use directly. ''' Symptom.__init__(self, obj) self.functionNames = [] rawFunctionNames = JSONHelper.getArrayChecked(obj, "functionNames", True) for fn in rawFunctionNames: self.functionNames.append(StringMatch(fn))
def __init__(self, obj): ''' Private constructor, called by L{Symptom.fromJSONObject}. Do not use directly. ''' Symptom.__init__(self, obj) self.functionNames = [] rawFunctionNames = JSONHelper.getArrayChecked(obj, "functionNames", True) for fn in rawFunctionNames: self.functionNames.append(StringMatch(fn))
def __init__(self, obj): ''' Private constructor, called by L{Symptom.fromJSONObject}. Do not use directly. ''' Symptom.__init__(self, obj) self.registerNames = JSONHelper.getArrayChecked(obj, "registerNames") self.instructionName = JSONHelper.getObjectOrStringChecked(obj, "instructionName") if self.instructionName != None: self.instructionName = StringMatch(self.instructionName) elif self.registerNames == None or len(self.registerNames) == 0: raise RuntimeError("Must provide at least instruction name or register names")
def __init__(self, obj): ''' Private constructor, called by L{Symptom.fromJSONObject}. Do not use directly. ''' Symptom.__init__(self, obj) self.registerNames = JSONHelper.getArrayChecked(obj, "registerNames") self.instructionName = JSONHelper.getObjectOrStringChecked(obj, "instructionName") if self.instructionName != None: self.instructionName = StringMatch(self.instructionName) elif self.registerNames == None or len(self.registerNames) == 0: raise RuntimeError("Must provide at least instruction name or register names")
class CrashSignature(): def __init__(self, rawSignature): ''' Constructor @type rawSignature: string @param rawSignature: A JSON-formatted string representing the crash signature ''' # For now, we store the original raw signature and hand it out for # conversion to String. This is fine as long as our Signature object # is immutable. Later, we should implement a method that actually # serializes this object back to JSON as it is. # self.rawSignature = rawSignature self.symptoms = [] try: obj = json.loads(rawSignature, object_pairs_hook=OrderedDict) except ValueError, e: raise RuntimeError("Invalid JSON: %s" % e) # Get the symptoms objects (mandatory) if "symptoms" in obj: symptoms = JSONHelper.getArrayChecked(obj, "symptoms", True) if len(symptoms) == 0: raise RuntimeError("Signature must have at least one symptom.") for rawSymptomsObj in symptoms: self.symptoms.append(Symptom.fromJSONObject(rawSymptomsObj)) else: raise RuntimeError('Missing mandatory top-level key "symptoms".') # Get some optional lists self.platforms = JSONHelper.getArrayChecked(obj, "platforms") self.operatingSystems = JSONHelper.getArrayChecked( obj, "operatingSystems") self.products = JSONHelper.getArrayChecked(obj, "products")
def __init__(self, rawSignature): ''' Constructor @type rawSignature: string @param rawSignature: A JSON-formatted string representing the crash signature ''' # For now, we store the original raw signature and hand it out for # conversion to String. This is fine as long as our Signature object # is immutable. Later, we should implement a method that actually # serializes this object back to JSON as it is. # self.rawSignature = rawSignature self.symptoms = [] try: obj = json.loads(rawSignature, object_pairs_hook=OrderedDict) except ValueError as e: raise RuntimeError("Invalid JSON: %s" % e) # Get the symptoms objects (mandatory) if "symptoms" in obj: symptoms = JSONHelper.getArrayChecked(obj, "symptoms", True) if len(symptoms) == 0: raise RuntimeError("Signature must have at least one symptom.") for rawSymptomsObj in symptoms: self.symptoms.append(Symptom.fromJSONObject(rawSymptomsObj)) else: raise RuntimeError('Missing mandatory top-level key "symptoms".') # Get some optional lists self.platforms = JSONHelper.getArrayChecked(obj, "platforms") self.operatingSystems = JSONHelper.getArrayChecked(obj, "operatingSystems") self.products = JSONHelper.getArrayChecked(obj, "products")