minor + reset db function

This commit is contained in:
JoaoBastos023 2024-11-20 22:03:50 +00:00
parent ae9ae8b510
commit 7bef5b468c
17 changed files with 60 additions and 18 deletions

View File

@ -59,7 +59,7 @@ def createOrganization(args):
input = {'name' : args.org, 'username' : args.username, 'full_name' : args.name, 'email' : args.email, 'public_key' : pubKey}
try:
req = requests.post(f'https://{state['REP_ADDRESS']}/org/create', json=json.dumps(input))
req = requests.post(f'http://{state['REP_ADDRESS']}/org/create', json=json.dumps(input))
req.raise_for_status()
except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.")

View File

@ -49,7 +49,7 @@ def createSession(args):
#print( type(json.dumps(session)))
try:
req = requests.post(f'https://{state['REP_ADDRESS']}/user/login', json=json.dumps(session))
req = requests.post(f'http://{state['REP_ADDRESS']}/user/login', json=json.dumps(session))
req.raise_for_status()
except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server")

View File

@ -18,7 +18,7 @@ state = main(sys.argv)
def listOrganizations():
try:
orgs = requests.get(f'https://{state['REP_ADDRESS']}/org/list')
orgs = requests.get(f'http://{state['REP_ADDRESS']}/org/list')
orgs.raise_for_status()
except requests.exceptions.RequestException as errex:

View File

@ -56,7 +56,7 @@ def list_subjects(args):
else:
try:
subjects = requests.get(f'https://{state['REP_ADDRESS']}/user/list',
subjects = requests.get(f'http://{state['REP_ADDRESS']}/user/list',
json=json.dumps({}),
headers={'Authorization': args.session['token']})
subjects.raise_for_status()

View File

@ -0,0 +1,42 @@
#!/bin/python3
import os
import sys
import logging
import requests
import json
import argparse
sys.path.append(os.path.abspath("../"))
from subject import main
logging.basicConfig(format='%(levelname)s\t- %(message)s')
logger = logging.getLogger()
logger.setLevel(logging.INFO)
state = main(sys.argv)
def reset(args):
parser = argparse.ArgumentParser()
parser.add_argument("-k", '--key', nargs=1, help="Path to the key file")
parser.add_argument("-r", '--repo', nargs=1, help="Address:Port of the repository")
parser.add_argument("-v", '--verbose', help="Increase verbosity", action="store_true")
parser.add_argument('password', nargs='?', default=None)
args = parser.parse_args()
if not args.password:
logger.error("Need password")
sys.exit(1)
try:
req = requests.post(f'http://{state['REP_ADDRESS']}/reset',json=json.dumps({'password' : args.password}))
req.raise_for_status()
except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.")
sys.exit(-1)
if __name__ == '__main__':
reset(sys.argv[1:])

0
delivery1/client/bin/subject.py Normal file → Executable file
View File