update-metadatas.py: fix local metadata system

This commit is contained in:
Thomas NOËL 2014-10-29 12:14:50 +01:00
parent 714be795b9
commit 5db56e351e
1 changed files with 4 additions and 4 deletions

View File

@ -37,10 +37,10 @@ def metadata_filename(codename, suffix=None):
else:
return os.path.join(METADATAS_DIR, codename, 'metadata.xml.%s' % suffix)
def store_metadata(codename, fp):
def store_metadata(codename, metadata):
tempfilename = '/var/tmp/%s-metadata.xml-%s' % (codename, os.getpid())
f = open(tempfilename, 'wb')
f.write(fp.read())
f.write(metadata)
f.close()
if not os.path.exists(METADATAS_DIR):
os.mkdir(METADATAS_DIR, 0770)
@ -57,11 +57,11 @@ def store_metadata(codename, fp):
pass
def verify_metadata(codename, signcert):
metadata = metadata_filename(codename, 'downloaded')
if not signcert:
print 'warn: do not verify %s metadata (no certificate provided)' % codename
ret = True
else:
metadata = metadata_filename(codename, 'downloaded')
signcert_pem = metadata_filename(codename, 'signcert.pem')
dir = os.path.join(METADATAS_DIR, codename)
f = open(signcert_pem, 'wb')
@ -107,7 +107,7 @@ class Command(BaseCommand):
# get metadata from url
try:
print 'download federation %s metadata from url: %s' % (str(codename), str(url))
metadata = urllib2.urlopen(url)
metadata = urllib2.urlopen(url).read()
except urllib2.HTTPError as e:
metadata = None
print 'Error loading metadata (%s)' % str(e)