minor + reset db function
This commit is contained in:
parent
ae9ae8b510
commit
7bef5b468c
|
@ -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.")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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:])
|
Loading…
Reference in New Issue