Commit c5525fec authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

job status is now reset to 'pending'.

 misc.database_tools:
 - get_postgreSQL_value(): now replaces all " ' " with "" due to compatibility issues to postgreSQL syntax
 - update_records_in_postgreSQLdb(): now uses execute_pgSQL_query for better error reporting
 - GMS_JOB.reset_job_progress(): now resets status to 'pending'

 config.Job:
 - status is now set to 'pending'

- updated __version__
parent 811477d3
......@@ -15,7 +15,7 @@ from . import config
from .processing.process_controller import process_controller
__version__ = '20170328.01'
__version__ = '20170329.01'
__author__ = 'Daniel Scheffler'
__all__ = ['algorithms',
'io',
......
......@@ -756,16 +756,16 @@ class L1B_object(L1A_object):
self.logger.info("Resampling attribute '%s' to target grid..." % attrname)
# correct shifts
DS = DESHIFTER(geoArr, self.coreg_info,
target_xyGrid = [CFG.usecase.spatial_ref_gridx, CFG.usecase.spatial_ref_gridy],
cliptoextent = cliptoextent,
clipextent = mapBounds,
align_grids = True,
resamp_alg = 'nearest' if attrname=='masks' else 'cubic',
CPUs = None if CFG.job.allow_subMultiprocessing else 1,
progress = True if v else False,
q = True,
v = v)
DS = DESHIFTER(geoArr, self.coreg_info,
target_xyGrid = [CFG.usecase.spatial_ref_gridx, CFG.usecase.spatial_ref_gridy],
cliptoextent = cliptoextent,
clipextent = mapBounds,
align_grids = True,
resamp_alg = 'nearest' if attrname=='masks' else 'cubic',
CPUs = None if CFG.job.allow_subMultiprocessing else 1,
progress = True if v else False,
q = True,
v = v)
DS.correct_shifts()
# update coreg_info
......
......@@ -68,7 +68,7 @@ class Job:
assert exec_mode in ['Flink','Python']
assert isinstance(db_host, str), "'db_host must be a string! Got %s." %type(db_host)
self.status = 'initialized' # possible values: 'initialized', 'running', 'canceled', 'failed', 'finished_with_warnings', 'finished_with_errors', 'finished'
self.status = 'pending' # possible values: 'pending', 'running', 'canceled', 'failed', 'finished_with_warnings', 'finished_with_errors', 'finished'
self.start_time = datetime.datetime.now()
self.end_time = None
self.computation_time = None
......
......@@ -105,7 +105,7 @@ def get_postgreSQL_value(value):
elif isinstance(value,float): pgV = value
elif isinstance(value,bool): pgV = value
elif value is None: pgV = 'NULL'
elif isinstance(value,str): pgV = "'%s'" %value
elif isinstance(value,str): pgV = "'%s'" %value.replace("'","")
elif isinstance(value,Polygon): pgV = "'%s'" %value.wkb_hex
elif isinstance(value,datetime): pgV = "TIMESTAMP '%s'" %str(value)
else: #list or tuple in value
......@@ -191,11 +191,12 @@ def update_records_in_postgreSQLdb(conn_params, tablename, vals2update_dict, con
if cond_dict else ""
update_cond = "SET " + ', '.join(['%s=%s' % (k, get_postgreSQL_value(vals2update_dict[k]))
for k in vals2update_dict.keys()])
cursor.execute("SELECT EXISTS(SELECT 1 FROM scenes %s);" %condition)
execute_pgSQL_query(cursor,"SELECT EXISTS(SELECT 1 FROM scenes %s);" %condition)
if cursor.fetchone()[0] == 0:
warnings.warn("No record found fulfilling this condition: \n'%s'." %condition)
else:
cursor.execute("UPDATE "+tablename+" "+update_cond+" "+condition)
execute_pgSQL_query(cursor, "UPDATE "+tablename+" "+update_cond+" "+condition)
if 'connection' in locals(): connection.commit()
if 'connection' in locals(): connection.close()
......@@ -875,7 +876,7 @@ class GMS_JOB(object):
self.finishtime = None
self.failed_sceneids = []
self.progress = None
self.status = None
self.status = 'pending'
self.statistics = [len(self.sceneids)] + [0] * 8
self.update_db_entry()
......
......@@ -350,7 +350,7 @@ class process_controller(object):
self.logger.info('Execution of entire GeoMultiSens pre-processing chain started...')
self.job.status = 'running'
self.update_DB_job_record() # TODO implement that into job.status.setter
self.DB_job_record.reset_job_progress()
self.DB_job_record.reset_job_progress() # updates attributs of DB_job_record and related DB entry
self.failed_objects = []
......
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