diff --git a/mutalyzer/entrypoints/admin.py b/mutalyzer/entrypoints/admin.py index 07ee52e8bb10f440ebf1d84cb7148557fe1582b5..42929e6bb31c974149f11b12a7ba39680eb9c5ae 100644 --- a/mutalyzer/entrypoints/admin.py +++ b/mutalyzer/entrypoints/admin.py @@ -136,7 +136,11 @@ def sync_cache(wsdl_url, url_template, history=7): 55 5 * * * mutalyzer-cache-sync 'http://dom2/?wsdl' 'http://dom2/{file}' -H 7 """ cache_sync = sync.CacheSync(output.Output(__file__)) - cache_sync.sync_with_remote(wsdl_url, url_template, history) + inserted, downloaded = cache_sync.sync_with_remote(wsdl_url, url_template, + history) + + print ('Added %d entries to the local cache and downloaded %d cache files.' + % (inserted, downloaded)) def set_announcement(body, url=None): diff --git a/mutalyzer/sync.py b/mutalyzer/sync.py index 4c278e819d87d0d64f793057444659f25c1c3a3e..e5465e1e35e6f5a1cbc1556b8f5f817520947a2a 100644 --- a/mutalyzer/sync.py +++ b/mutalyzer/sync.py @@ -107,16 +107,21 @@ class CacheSync(object): """ Create a nice dictionary out of the CacheEntry object. """ + cast_orientation = {None: None, + 1: 'forward', + 2: 'reverse'} + entry_dict = {'name': str(entry.name), 'hash': str(entry.hash), 'created': entry.created} for attribute in ('gi', 'chromosomeName', 'url', 'cached'): entry_dict[attribute] = str(entry[attribute]) \ if attribute in entry else None - for attribute in ('chromosomeStart', 'chromosomeStop', - 'chromosomeOrientation'): + for attribute in ('chromosomeStart', 'chromosomeStop'): entry_dict[attribute] = int(entry[attribute]) \ if attribute in entry else None + entry_dict['chromosomeOrientation'] = cast_orientation[entry['chromosomeOrientation']] \ + if 'chromosomeOrientation' in entry else None return entry_dict return map(cache_entry_from_soap, cache.CacheEntry) @@ -195,6 +200,8 @@ class CacheSync(object): slice_stop=entry['chromosomeStop'], slice_orientation=entry['chromosomeOrientation'], download_url=entry['url']) + session.add(reference) + session.commit() inserted += 1 if not entry['chromosomeName'] and not entry['url'] \ and entry['cached']: