SAAS-596: Store file size and hash in database

Fixed exception handling in pypo
This commit is contained in:
drigato 2015-02-24 12:32:46 -05:00
parent be7a6854f0
commit 86ba5c547e
1 changed files with 8 additions and 4 deletions

View File

@ -114,14 +114,18 @@ class PypoFile(Thread):
self.logger.error(e)
# Make PUT request to Airtime to update the file size and hash
put_url = "http://%s/rest/media/%s" % (host_name, file_id)
payload = json.dumps({'filesize': file_size, 'md5': md5_hash})
error_msg = "Could not update media file %s with file size and md5 hash" % file_id
try:
put_url = "http://%s/rest/media/%s" % (host_name, file_id)
payload = json.dumps({'filesize': file_size, 'md5': md5_hash})
response = requests.put(put_url, data=payload, auth=requests.auth.HTTPBasicAuth(api_key, ''))
if not response.ok:
self.logger.error("Could not update media file %s with file size and md5 hash" % file_id)
self.logger.error(error_msg)
except (ConnectionError, Timeout):
self.logger.error("Could not update media file %s with file size and md5 hash" % file_id)
self.logger.error(error_msg)
except Exception as e:
self.logger.error(error_msg)
self.logger.error(e)
return file_size