diff options
author | Richard Jones <richard@mechanicalcat.net> | 2013-01-14 16:57:02 +1100 |
---|---|---|
committer | Richard Jones <richard@mechanicalcat.net> | 2013-01-14 16:57:02 +1100 |
commit | cd6cee8bd8e4f13961933eb65e259cbf60572e78 (patch) | |
tree | 52c8a0ca72cfbd8091938f9c4a3fea866f7e6ca1 | |
parent | 4cfe1f8a330889da54b9296cc92b4279719dd28f (diff) | |
download | decorator-cd6cee8bd8e4f13961933eb65e259cbf60572e78.tar.gz |
fixes
-rw-r--r-- | rpc.py | 32 | ||||
-rw-r--r-- | store.py | 4 |
2 files changed, 22 insertions, 14 deletions
@@ -1,6 +1,8 @@ import sys import xmlrpclib import traceback +import datetime +import logging import re import time from cStringIO import StringIO @@ -44,6 +46,7 @@ class RequestHandler(SimpleXMLRPCDispatcher): # This should be thread-safe, as the store is really a singleton self.store = webui_obj.store except Exception, e: + logging.exception('reading input') # report as a fault to caller rather than propogating up to generic # exception handler response = xmlrpclib.dumps( @@ -62,7 +65,11 @@ class RequestHandler(SimpleXMLRPCDispatcher): if not method.startswith('system.'): # Add store to all of our own methods params = (self.store,)+tuple(params) - return SimpleXMLRPCDispatcher._dispatch(self, method, params) + try: + return SimpleXMLRPCDispatcher._dispatch(self, method, params) + except Exception, e: + logging.exception('calling %r with %r' % (method, params)) + raise def system_multicall(self, call_list): if len(call_list) > 100: @@ -152,17 +159,18 @@ def updated_releases(store, since): return [(row['name'], row['version']) for row in result] def changelog(store, since, with_ids=False): - result = store.changelog(since) - if with_ids: - return [(row['name'],row['version'], - int(time.mktime(row['submitted_date'].timetuple())), - row['action'], row['id']) - for row in result] - else: - return [(row['name'],row['version'], - int(time.mktime(row['submitted_date'].timetuple())), - row['action']) - for row in result] + result = [] + for row in store.changelog(since): + if isinstance(row['submitted_date'], str): + d = datetime.datetime.strptime(row['submitted_date'], + '%Y-%m-%d %H:%M:%S').timetuple() + else: + d = row['submitted_date'].timetuple() + t = (row['name'],row['version'], d, row['action']) + if with_ids: + t += (row['id'], ) + result.append(t) + return result def changed_packages(store, since): return store.changed_packages(since) @@ -657,7 +657,7 @@ class Store: cursor.execute('select name from packages order by name') return [p[0] for p in cursor.fetchall()] - _Journal = FastResultRow('id action submitted_date! submitted_by submitted_from') + _Journal = FastResultRow('id! action submitted_date! submitted_by submitted_from') def get_journal(self, name, version): ''' Retrieve info about the package from the database. @@ -921,7 +921,7 @@ class Store: return Result(None, self.get_unique(cursor.fetchall()), self._Updated_Releases) - _Changelog = FastResultRow('id name version submitted_date! action') + _Changelog = FastResultRow('id! name version submitted_date! action') def changelog(self, since): '''Fetch (id, name, version, submitted_date, action) since 'since' argument. |