Skip to content
Snippets Groups Projects
Commit 5ca4d216 authored by Vermaat's avatar Vermaat
Browse files

Fix sync of local cache with remote cache

parent 55ca04e1
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......
......@@ -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']:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment