Updated client functs with state
This commit is contained in:
parent
06b1058ed9
commit
a27348567f
|
@ -6,16 +6,23 @@ import requests
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
#session file - username
|
#session file - username
|
||||||
def activateSubject(args):
|
def activateSubject(args):
|
||||||
parser = argparse.ArgumentParser()
|
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('session', nargs='?', default=None)
|
parser.add_argument('session', nargs='?', default=None)
|
||||||
parser.add_argument('username', nargs='?',default=None)
|
parser.add_argument('username', nargs='?',default=None)
|
||||||
|
|
||||||
|
|
|
@ -6,18 +6,25 @@ import requests
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from cryptLib import encryptionFuncts
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
|
from lib import encryption_functs
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
# session file - document name - file
|
# session file - document name - file
|
||||||
def addDoc(args):
|
def addDoc(args):
|
||||||
parser = argparse.ArgumentParser()
|
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('session', nargs='?', default=None)
|
parser.add_argument('session', nargs='?', default=None)
|
||||||
parser.add_argument('name', nargs='?', default=None)
|
parser.add_argument('name', nargs='?', default=None)
|
||||||
parser.add_argument('file', nargs='?', default=None)
|
parser.add_argument('file', nargs='?', default=None)
|
||||||
|
@ -41,7 +48,7 @@ def addDoc(args):
|
||||||
with open(args.file, 'rb') as f:
|
with open(args.file, 'rb') as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
||||||
content = encryptionFuncts.encryptFile(state['REP_PUB_KEY'], content)
|
content = encryption_functs.encrypt_file(state['REP_PUB_KEY'], content)
|
||||||
|
|
||||||
doc = {'name' : args.name, 'content' : content}
|
doc = {'name' : args.name, 'content' : content}
|
||||||
|
|
||||||
|
|
|
@ -6,18 +6,25 @@ import requests
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from cryptLib import encryptionFuncts
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
|
from lib import encryption_functs
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
# session file - username - name - email - credentials file
|
# session file - username - name - email - credentials file
|
||||||
def addSubject(args):
|
def addSubject(args):
|
||||||
parser = argparse.ArgumentParser()
|
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('session', nargs='?', default=None)
|
parser.add_argument('session', nargs='?', default=None)
|
||||||
parser.add_argument('username', nargs='?', default=None)
|
parser.add_argument('username', nargs='?', default=None)
|
||||||
parser.add_argument('name', nargs='?', default=None)
|
parser.add_argument('name', nargs='?', default=None)
|
||||||
|
|
|
@ -7,7 +7,10 @@ import json
|
||||||
import re
|
import re
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from cryptLib import encryptionFuncts
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
|
from lib import encryption_functs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +18,7 @@ logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
# Create organization
|
# Create organization
|
||||||
# organization - username - name - email - public key file
|
# organization - username - name - email - public key file
|
||||||
|
@ -23,6 +26,10 @@ def createOrganization(args):
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
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('org', nargs='?', default=None)
|
parser.add_argument('org', nargs='?', default=None)
|
||||||
parser.add_argument('username', nargs='?', default=None)
|
parser.add_argument('username', nargs='?', default=None)
|
||||||
parser.add_argument('name', nargs='?', default=None)
|
parser.add_argument('name', nargs='?', default=None)
|
||||||
|
@ -47,7 +54,7 @@ def createOrganization(args):
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# load public key from file
|
# load public key from file
|
||||||
pubKey = encryptionFuncts.load_public_key(args.key)
|
pubKey = encryption_functs.load_public_key(args.key)
|
||||||
|
|
||||||
input = {'name' : args.org, 'username' : args.username, 'full_name' : args.name, 'email' : args.email, 'public_key' : pubKey}
|
input = {'name' : args.org, 'username' : args.username, 'full_name' : args.name, 'email' : args.email, 'public_key' : pubKey}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,9 @@ import argparse
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
import re
|
|
||||||
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
# Identity attributes
|
# Identity attributes
|
||||||
# {'username' : '', 'full_name' : '', 'email' : '', public_key : '' }
|
# {'username' : '', 'full_name' : '', 'email' : '', public_key : '' }
|
||||||
|
@ -14,13 +16,17 @@ logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
# org - username - password - credentials file - session file
|
# org - username - password - credentials file - session file
|
||||||
def createSession(args):
|
def createSession(args):
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
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('org', nargs='?', default=None)
|
parser.add_argument('org', nargs='?', default=None)
|
||||||
parser.add_argument('username', nargs='?', default=None)
|
parser.add_argument('username', nargs='?', default=None)
|
||||||
parser.add_argument('password', nargs='?', default=None)
|
parser.add_argument('password', nargs='?', default=None)
|
||||||
|
|
|
@ -6,16 +6,23 @@ import requests
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
# session file - document name
|
# session file - document name
|
||||||
def delDoc(args):
|
def delDoc(args):
|
||||||
parser = argparse.ArgumentParser()
|
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('session', nargs='?', default=None)
|
parser.add_argument('session', nargs='?', default=None)
|
||||||
parser.add_argument('name', nargs='?', default=None)
|
parser.add_argument('name', nargs='?', default=None)
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,23 @@ import requests
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
# session file - document name - output file(optional)
|
# session file - document name - output file(optional)
|
||||||
def getDoc(args):
|
def getDoc(args):
|
||||||
parser = argparse.ArgumentParser()
|
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('session', nargs='?', default=None)
|
parser.add_argument('session', nargs='?', default=None)
|
||||||
parser.add_argument('name', nargs='?', default=None)
|
parser.add_argument('name', nargs='?', default=None)
|
||||||
parser.add_argument('output', nargs='?', default=None)
|
parser.add_argument('output', nargs='?', default=None)
|
||||||
|
|
|
@ -6,16 +6,26 @@ import requests
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
|
print(state)
|
||||||
|
|
||||||
# session file - document name
|
# session file - document name
|
||||||
def getDocMetadata(args):
|
def getDocMetadata(args):
|
||||||
parser = argparse.ArgumentParser()
|
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('session', nargs='?', default=None)
|
parser.add_argument('session', nargs='?', default=None)
|
||||||
parser.add_argument('name', nargs='?', default=None)
|
parser.add_argument('name', nargs='?', default=None)
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ import json
|
||||||
import requests
|
import requests
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
# Identity attributes
|
# Identity attributes
|
||||||
# {'username' : '', 'full_name' : '', 'email' : '', public_key : '' }
|
# {'username' : '', 'full_name' : '', 'email' : '', public_key : '' }
|
||||||
|
|
||||||
|
@ -13,13 +16,17 @@ logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
#get file
|
#get file
|
||||||
#file handle - file(optonal)
|
#file handle - file(optonal)
|
||||||
def getFile(args):
|
def getFile(args):
|
||||||
parser = argparse.ArgumentParser()
|
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('filehandle', nargs='?', default=None)
|
parser.add_argument('filehandle', nargs='?', default=None)
|
||||||
parser.add_argument('file', nargs='?', default=None)
|
parser.add_argument('file', nargs='?', default=None)
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,14 @@ import json
|
||||||
import argparse
|
import argparse
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
def validDate(date):
|
def validDate(date):
|
||||||
try:
|
try:
|
||||||
|
@ -24,6 +27,10 @@ def validDate(date):
|
||||||
def list_docs(args):
|
def list_docs(args):
|
||||||
parser = argparse.ArgumentParser()
|
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('session', nargs='?', default=None)
|
parser.add_argument('session', nargs='?', default=None)
|
||||||
parser.add_argument("-s", '--username', nargs=1, help="Username")
|
parser.add_argument("-s", '--username', nargs=1, help="Username")
|
||||||
parser.add_argument("-dnt", '--newerThan', help="Date new than")
|
parser.add_argument("-dnt", '--newerThan', help="Date new than")
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
#!/bin/python3
|
#!/bin/python3
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
# Identity attributes
|
# Identity attributes
|
||||||
# {'username' : '', 'full_name' : '', 'email' : '', public_key : '' }
|
# {'username' : '', 'full_name' : '', 'email' : '', public_key : '' }
|
||||||
|
|
||||||
|
@ -11,7 +15,7 @@ logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
def listOrganizations():
|
def listOrganizations():
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -6,17 +6,24 @@ import requests
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
# session file - username(optional)
|
# session file - username(optional)
|
||||||
def list_subjects(args):
|
def list_subjects(args):
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
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('session', nargs='?', default=None)
|
parser.add_argument('session', nargs='?', default=None)
|
||||||
parser.add_argument('username', nargs='?', default=None)
|
parser.add_argument('username', nargs='?', default=None)
|
||||||
|
|
||||||
|
|
|
@ -3,39 +3,34 @@ import sys
|
||||||
import logging
|
import logging
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from cryptLib import keyPair
|
from lib import key_pair
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
# Generate a key pair for a subject
|
# Generate a key pair for a subject
|
||||||
# password - file for keys
|
# password - file for public key, file for private key
|
||||||
def generateKeyPair(args):
|
def generateKeyPair(args):
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
parser.add_argument('password', nargs='?', default=None)
|
parser.add_argument('password', nargs='?', default=None)
|
||||||
parser.add_argument('file', nargs='?', default=None)
|
parser.add_argument('pubfile', nargs='?', default=None)
|
||||||
|
parser.add_argument('privfile', nargs='?', default=None)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if len(args) != 2:
|
if len(args) != 3:
|
||||||
logger.error("Need password and file to store keys")
|
logger.error("Need password and file to store keys")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
|
||||||
#Generate the key pair
|
#Generate the key pair
|
||||||
keys = keyPair.generate_key_pair(args.password)
|
key_pair.generate_key_pair(args.pubfile, args.privfile, 2048, args.password)
|
||||||
|
|
||||||
#Get the 2 different keys
|
|
||||||
pubKey = ''
|
|
||||||
privateKey = ''
|
|
||||||
|
|
||||||
with open(args.file, "wb") as f:
|
|
||||||
f.write(pubKey.encode() + b"\n\n" + privateKey.encode())
|
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
generateKeyPair(sys.argv)
|
generateKeyPair(sys.argv[1:])
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,23 @@ import requests
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath("../"))
|
||||||
|
from subject import main
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
state = {}
|
state = main(sys.argv)
|
||||||
|
|
||||||
# session file - username
|
# session file - username
|
||||||
def suspendSubject(args):
|
def suspendSubject(args):
|
||||||
parser = argparse.ArgumentParser()
|
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('session', nargs='?', default=None)
|
parser.add_argument('session', nargs='?', default=None)
|
||||||
parser.add_argument('username', nargs='?',default=None)
|
parser.add_argument('username', nargs='?',default=None)
|
||||||
|
|
||||||
|
@ -33,4 +40,4 @@ def suspendSubject(args):
|
||||||
req = requests.post(f'http://{state['REP_ADDRESS']}/subject/', json=json.dumps(subject))
|
req = requests.post(f'http://{state['REP_ADDRESS']}/subject/', json=json.dumps(subject))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
suspendSubject(sys.argv)
|
suspendSubject(sys.argv[1:])
|
|
@ -51,13 +51,13 @@ def parse_args(state):
|
||||||
parser.add_argument("-k", '--key', nargs=1, help="Path to the key file")
|
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("-r", '--repo', nargs=1, help="Address:Port of the repository")
|
||||||
parser.add_argument("-v", '--verbose', help="Increase verbosity", action="store_true")
|
parser.add_argument("-v", '--verbose', help="Increase verbosity", action="store_true")
|
||||||
# parser.add_argument("-c", "--command", help="Command to execute")
|
parser.add_argument("-c", "--command", help="Command to execute")
|
||||||
# parser.add_argument('arg0', nargs='?', default=None)
|
parser.add_argument('arg0', nargs='?', default=None)
|
||||||
# parser.add_argument('arg1', nargs='?', default=None)
|
parser.add_argument('arg1', nargs='?', default=None)
|
||||||
# parser.add_argument('arg2', nargs='?', default=None)
|
parser.add_argument('arg2', nargs='?', default=None)
|
||||||
# parser.add_argument('arg3', nargs='?', default=None)
|
parser.add_argument('arg3', nargs='?', default=None)
|
||||||
# parser.add_argument('arg4', nargs='?', default=None)
|
parser.add_argument('arg4', nargs='?', default=None)
|
||||||
# parser.add_argument('arg5', nargs='?', default=None)
|
parser.add_argument('arg5', nargs='?', default=None)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
|
@ -77,10 +77,10 @@ def parse_args(state):
|
||||||
state['REP_ADDRESS'] = args.repo[0]
|
state['REP_ADDRESS'] = args.repo[0]
|
||||||
logger.info('Overriding REP_ADDRESS from command line')
|
logger.info('Overriding REP_ADDRESS from command line')
|
||||||
|
|
||||||
if args.command:
|
#if args.command:
|
||||||
logger.info("Command: " + args.command)
|
# logger.info("Command: " + args.command)
|
||||||
|
|
||||||
return state, {'command': args.command, 'arg0': args.arg0, 'arg1': args.arg1, 'arg2': args.arg2, 'arg3': args.arg3, 'arg4': args.arg4, 'arg5': args.arg5}
|
return state#, {'command': args.command, 'arg0': args.arg0, 'arg1': args.arg1, 'arg2': args.arg2, 'arg3': args.arg3, 'arg4': args.arg4, 'arg5': args.arg5}
|
||||||
|
|
||||||
def save(state):
|
def save(state):
|
||||||
state_dir = os.path.join(os.path.expanduser('~'), '.sio')
|
state_dir = os.path.join(os.path.expanduser('~'), '.sio')
|
||||||
|
@ -98,11 +98,12 @@ def main(args):
|
||||||
|
|
||||||
state = load_state()
|
state = load_state()
|
||||||
state = parse_env(state)
|
state = parse_env(state)
|
||||||
state, args = parse_args(state)
|
#state, args = parse_args(state)
|
||||||
|
state = parse_args(state)
|
||||||
|
|
||||||
# if 'REP_ADDRESS' not in state:
|
if 'REP_ADDRESS' not in state:
|
||||||
# logger.error("Must define Repository Address")
|
logger.error("Must define Repository Address")
|
||||||
# sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# if 'REP_PUB_KEY' not in state:
|
# if 'REP_PUB_KEY' not in state:
|
||||||
# logger.error("Must set the Repository Public Key")
|
# logger.error("Must set the Repository Public Key")
|
||||||
|
|
Loading…
Reference in New Issue