40 lines
1.1 KiB
Python
Executable File
40 lines
1.1 KiB
Python
Executable File
#!/bin/python3
|
|
import os
|
|
import sys
|
|
import logging
|
|
import json
|
|
import requests
|
|
|
|
from lib.symmetric_encryption import decrypt_request_with_iv
|
|
from subject import main
|
|
|
|
# Identity attributes
|
|
# {'username' : '', 'full_name' : '', 'email' : '', public_key : '' }
|
|
|
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
|
logger = logging.getLogger()
|
|
logger.setLevel(logging.INFO)
|
|
|
|
state = main(sys.argv)
|
|
|
|
def listOrganizations():
|
|
try:
|
|
orgs = requests.get(f'http://{state['REP_ADDRESS']}/org/list')
|
|
orgs.raise_for_status()
|
|
|
|
except requests.exceptions.HTTPError:
|
|
# We know this is useless, but we don't give a damn and still put it here
|
|
logger.error("%d: %s", orgs.status_code, orgs.json()['error'])
|
|
sys.exit(-1)
|
|
|
|
except requests.exceptions.RequestException as errex:
|
|
logger.error("Failed to obtain response from server.")
|
|
sys.exit(-1)
|
|
|
|
orgs = json.loads(decrypt_request_with_iv(bytes.fromhex(orgs.text)))
|
|
|
|
logger.info(json.dumps(orgs, indent=4))
|
|
sys.exit(0)
|
|
|
|
if __name__ == '__main__':
|
|
listOrganizations() |