Commit e1dd6f06 authored by Ivan Tyagov's avatar Ivan Tyagov

Handling any exception to log is bad as you already have error_log.

parent 98f0da9d
...@@ -14,54 +14,50 @@ reference_separator = portal.getIngestionReferenceDictionary()["reference_separa ...@@ -14,54 +14,50 @@ reference_separator = portal.getIngestionReferenceDictionary()["reference_separa
reference_end_single = portal.getIngestionReferenceDictionary()["single_end_suffix"] reference_end_single = portal.getIngestionReferenceDictionary()["single_end_suffix"]
reference_end_split = portal.getIngestionReferenceDictionary()["split_end_suffix"] reference_end_split = portal.getIngestionReferenceDictionary()["split_end_suffix"]
try: # remove supplier and eof from reference
# remove supplier and eof from reference data_ingestion_reference = reference_separator.join(reference.split(reference_separator)[1:-3])
data_ingestion_reference = reference_separator.join(reference.split(reference_separator)[1:-3]) EOF = reference.split(reference_separator)[-3]
EOF = reference.split(reference_separator)[-3] size = reference.split(reference_separator)[-2]
size = reference.split(reference_separator)[-2]
if data_ingestion_reference is "":
if data_ingestion_reference is "": context.logEntry("[ERROR] Data Ingestion reference parameter for ingestionReferenceExists script is not well formated")
context.logEntry("[ERROR] Data Ingestion reference parameter for ingestionReferenceExists script is not well formated") raise ValueError("Data Ingestion reference is not well formated")
raise ValueError("Data Ingestion reference is not well formated")
# check if there are started ingestions for this reference
# check if there are started ingestions for this reference data_ingestion = portal_catalog.getResultValue(
data_ingestion = portal_catalog.getResultValue( portal_type = 'Data Ingestion',
portal_type = 'Data Ingestion', simulation_state = "started",
simulation_state = "started", reference = data_ingestion_reference)
reference = data_ingestion_reference) if data_ingestion != None:
if data_ingestion != None: try:
try: # check if user tries to restart the previous split ingestion
# check if user tries to restart the previous split ingestion if (EOF == "" or EOF == reference_end_single) or (EOF != reference_end_split and int(EOF) == 1):
if (EOF == "" or EOF == reference_end_single) or (EOF != reference_end_split and int(EOF) == 1): # check if existing split ingestion is still being processed or if it is interrumped
# check if existing split ingestion is still being processed or if it is interrumped data_ingestion_eof = portal_catalog.getResultValue(
data_ingestion_eof = portal_catalog.getResultValue( portal_type = 'Data Ingestion',
portal_type = 'Data Ingestion', reference = data_ingestion_reference,
reference = data_ingestion_reference, id = "%" + reference_end_split)
id = "%" + reference_end_split) if data_ingestion_eof:
if data_ingestion_eof: # reference exists: previous split ingestion is still being processed
# reference exists: previous split ingestion is still being processed return TRUE
return TRUE else:
else: # previous ingestion was interrumped
# previous ingestion was interrumped log(''.join(["[WARNING] User has restarted an interrumpted ingestion for reference ", data_ingestion.getReference(), ". Previous split ingestions will be discarted and full ingestion restarted."]))
log(''.join(["[WARNING] User has restarted an interrumpted ingestion for reference ", data_ingestion.getReference(), ". Previous split ingestions will be discarted and full ingestion restarted."])) portal.ERP5Site_invalidateSplitIngestions(data_ingestion.getReference(), success=False)
portal.ERP5Site_invalidateSplitIngestions(data_ingestion.getReference(), success=False) except:
except: pass
pass # the ingestion attemp corresponds to a split ingestion in course, accept
# the ingestion attemp corresponds to a split ingestion in course, accept return FALSE
return FALSE
data_ingestion = portal_catalog.getResultValue(
data_ingestion = portal_catalog.getResultValue( portal_type = 'Data Ingestion',
portal_type = 'Data Ingestion', reference = data_ingestion_reference)
reference = data_ingestion_reference)
if data_ingestion is None:
if data_ingestion is None: return FALSE
return FALSE
# TODO: fix this (contemplate scenarios of partial ingestion overwrites)
# TODO: fix this (contemplate scenarios of partial ingestion overwrites) if size != "" and size != None:
if size != "" and size != None: # this is a modified file
# this is a modified file return FALSE
return FALSE return TRUE
return TRUE
except Exception as e:
context.logEntry(''.join(["[ERROR] At script ingestionReferenceExists: ", str(e)]))
raise e
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment