Feed errors that occur in the back end in the backend_status field
diff --git a/planetstack/observer/error_mapper.py b/planetstack/observer/error_mapper.py
new file mode 100644
index 0000000..a7daa59
--- /dev/null
+++ b/planetstack/observer/error_mapper.py
@@ -0,0 +1,25 @@
+from planetstack.config import Config
+from util.logger import Logger, logging, logger
+
+class ErrorMapper:
+ def __init__(self, error_map_file):
+ self.error_map = {}
+ try:
+ error_map_lines = open(error_map_file).read().splitlines()
+ for l in error_map_lines:
+ if (not l.startswith('#')):
+ splits = l.split('->')
+ k,v = map(lambda i:i.rstrip(),splits)
+ self.error_map[k]=v
+ except:
+ logging.info('Could not read error map')
+
+
+ def map(self, error):
+ return self.error_map[error]
+
+
+
+
+
+
diff --git a/planetstack/observer/syncstep.py b/planetstack/observer/syncstep.py
index c41628a..7e56c5b 100644
--- a/planetstack/observer/syncstep.py
+++ b/planetstack/observer/syncstep.py
@@ -3,6 +3,8 @@
from datetime import datetime
from planetstack.config import Config
from util.logger import Logger, logging
+from observer.steps import *
+from observer.error_mapper import error_mapper
logger = Logger(level=logging.INFO)
@@ -33,6 +35,8 @@
"""
dependencies = []
self.driver = args.get('driver')
+ self.error_map = args.get('error_map')
+
try:
self.soft_deadline = int(self.get_prop('soft_deadline_seconds'))
except:
@@ -60,8 +64,15 @@
self.sync_record(o)
o.enacted = datetime.now() # Is this the same timezone? XXX
o.save(update_fields=['enacted'])
- except:
- logger.log_exc("sync step %s failed!" % self.__name__)
+ except Exception,e:
+ try:
+ o.backend_status = self.error_map.map(str(e))
+ except:
+ o.backend_status = str(e)
+
+ o.save(update_fields=['backend_status'])
+
+ logger.log_exc("sync step failed!")
failed.append(o)
return failed