Skip to content

Commit

Permalink
🐞 Trustees struggle to respond to director (#93) (#96)
Browse files Browse the repository at this point in the history
Parent issue: sequentech/meta#402
  • Loading branch information
Findeton authored Apr 24, 2024
1 parent 3b469bf commit fcf594b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
21 changes: 16 additions & 5 deletions create_election/director_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from vmn import *

from taskqueue import end_task

@decorators.local_task
@decorators.task(action="create_election", queue="launch_task")
class CreateElectionTask(TaskHandler):
Expand Down Expand Up @@ -141,10 +141,11 @@ def handle_error(self, error):
input_data = self.task.get_data()['input_data']
election_id = input_data['election_id']
election = db.session.query(Election)\
.filter(Election.session_id == election_id).first()
.filter(Election.id == election_id).first()

session = requests.sessions.Session()
callback_url = election.callback_url
print("callback_url, " + callback_url)
fail_data = {
"status": "error",
"reference": {
Expand All @@ -158,9 +159,19 @@ def handle_error(self, error):
ssl_calist_path = app.config.get('SSL_CALIST_PATH', '')
ssl_cert_path = app.config.get('SSL_CERT_PATH', '')
ssl_key_path = app.config.get('SSL_KEY_PATH', '')
print("\ncallback_url " + callback_url)
r = session.request('post', callback_url, data=dumps(fail_data),
verify=ssl_calist_path, cert=(ssl_cert_path, ssl_key_path))
try:
r = session.request(
'post',
callback_url,
data=dumps(fail_data),
headers={'content-type': 'application/json'},
verify=ssl_calist_path,
cert=(ssl_cert_path, ssl_key_path)
)
except Exception as post_error:
print("exception calling to callback_url:")
print(post_error)
raise post_error
finally:
end_task()

Expand Down
24 changes: 15 additions & 9 deletions tally_election/director_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def handle_error(self, error):
input_data = self.task.get_data()['input_data']
election_id = input_data['election_id']
callback_url = input_data['callback_url']
print("callback_url, " + callback_url)
election = db.session.query(Election)\
.filter(Election.id == election_id).first()

Expand All @@ -130,15 +131,20 @@ def handle_error(self, error):
ssl_cert_path = app.config.get('SSL_CERT_PATH', '')
ssl_key_path = app.config.get('SSL_KEY_PATH', '')
print("\nFF callback_url4 " + callback_url)
r = session.request(
'post',
callback_url,
data=dumps(fail_data),
headers={'content-type': 'application/json'},
verify=ssl_calist_path,
cert=(ssl_cert_path, ssl_key_path)
)
print(r.text)
try:
r = session.request(
'post',
callback_url,
data=dumps(fail_data),
headers={'content-type': 'application/json'},
verify=ssl_calist_path,
cert=(ssl_cert_path, ssl_key_path)
)
print(r.text)
except Exception as post_error:
print("exception calling to callback_url:")
print(post_error)
raise post_error
finally:
end_task()

Expand Down

0 comments on commit fcf594b

Please sign in to comment.