diff --git a/workers/metadata_processor.py b/workers/metadata_processor.py index 32ce67ce3e5d16103b4e4767e4f1a6c69a8ad983..839dd2242d8de1ba848c6919a590f48e338055fd 100644 --- a/workers/metadata_processor.py +++ b/workers/metadata_processor.py @@ -65,16 +65,19 @@ def list_to_dictlist( the_input, the_context=None ): out_item = {} for k, line in enumerate(in_item_split): - if line != "": - if the_context != None: - out_item[ dictionary[the_context][k] ] = line + if the_context and k in dictionary[the_context].keys(): + if line != "": + if the_context and dictionary[the_context].get(k): + out_item[ dictionary[the_context][k] ] = line + else: + out_item[ k ] = line else: - out_item[ k ] = line - else: - out_item[ dictionary[the_context][k] ] = 'null' + if dictionary[the_context].get(k): + out_item[ dictionary[the_context][k] ] = 'null' - logging.debug(the_context) - logging.debug(out_item) + logging.debug("context : %s", the_context) + logging.debug("input: %s", in_item) + logging.debug("result : %s", out_item) # appending a hash value of the item can be useful at client-side, # as it allows one to identify entities that are common to multiple datasets... @@ -420,6 +423,6 @@ if __name__ == '__main__': logging.info('Waiting for RabbitMQ to be reachable...') time.sleep(5) except Exception as e: - logging.error(e) + logging.exception("General error (Aborting): %s", e) time.sleep(5) exit(1)