Socorro add code: Difference between revisions
Jump to navigation
Jump to search
Created page with "def json_PlaneShift_transform_predicate(*args, **kwargs): return True def json_PlaneShift_transform_action(raw_crash, processor): """a TransformRule action function tha..." |
No edit summary |
||
Line 1: | Line 1: | ||
<nowiki> | |||
def json_PlaneShift_transform_predicate(*args, **kwargs): | def json_PlaneShift_transform_predicate(*args, **kwargs): | ||
return True | |||
def json_PlaneShift_transform_action(raw_crash, processor): | def json_PlaneShift_transform_action(raw_crash, processor): | ||
Line 51: | Line 52: | ||
) | ) | ||
return True | return True | ||
</nowiki> |
Latest revision as of 20:58, 22 November 2013
def json_PlaneShift_transform_predicate(*args, **kwargs): return True def json_PlaneShift_transform_action(raw_crash, processor): """a TransformRule action function that will change the buildid of a product. parameters: json_doc - the destination mapping for the rewrite processor - a source for a logger, caching and a database connection""" if not hasattr(processor, 'builddate_cache'): # not very thread safe... processor.builddate_cache = {} try: build_date = processor.builddate_cache[( raw_crash['ProductName'], raw_crash['Version'] )] except KeyError: try: processor.config.logger.debug('DEBUG: product %s version %s',raw_crash['ProductName'], raw_crash['Version']) sql = ( "select build_id " "from product_version_builds b, product_versions v " "where b.product_version_id=v.product_version_id and " "product_name = %s and version_string = %s" ) product_version_tuple = ( raw_crash['ProductName'], raw_crash['Version'] ) build_date = processor.transaction( single_value_sql, sql, (raw_crash['ProductName'],raw_crash['Version']) ) processor.builddate_cache[product_version_tuple] = build_date except Exception: processor.config.logger.error( 'cannot fetch build_date for %s %s', raw_crash['ProductName'], raw_crash['Version'], ) return False raw_crash['BuildID'] = str(build_date) processor.config.logger.debug( 'BuildID changed to %s', build_date, ) return True