Commit af58fdf3 authored by jkvis's avatar jkvis

Getting ready for Cerana hooks

parent 182a85c8
......@@ -75,7 +75,6 @@ class Transfer(db.Model):
:arg string tid: An identifying hash key.
:arg string title: A symbolic title.
:arg User user: The associated user.
:arg string meta_json: Metadata text.
"""
self.tid = tid
self.title = title
......
......@@ -458,20 +458,32 @@ def upload(user, transfer_id):
# Client notification (action).
if user.action is not None:
success = True
# Now we need the user provided metadata again.
meta_primary = os.path.join(primary_path, '.metadata.json')
try:
result = requests.post(user.action,
cert=CERT,
verify=False)
if result.status_code < 200 or result.status_code > 299:
logging.error(user.action + ' for ' + transfer.tid +
' failed: ' + result.text)
success = False
except requests.exceptions.RequestException as excp:
logging.error('Could not notify ' + user.action +
' for ' + transfer.tid +
' Exception: ' + str(excp))
with open(meta_primary, 'r') as infile:
meta_data = json.load(infile)
except (OSError, IOError) as excp:
logging.error(excp.strerror)
success = False
if success:
try:
result = requests.post(user.action,
json=meta_data,
cert=CERT,
verify=False)
if result.status_code < 200 or result.status_code > 299:
logging.error(user.action + ' for ' + transfer.tid +
' failed: ' + result.text)
success = False
except requests.exceptions.RequestException as excp:
logging.error('Could not notify ' + user.action +
' for ' + transfer.tid +
' Exception: ' + str(excp))
success = False
# E-mail notification (fail silently).
if user.email is not None:
title = 'Transfer ' + transfer.tid + ' completed'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment