Check for HTTP error to print it

This commit is contained in:
JoaoBastos023 2024-12-18 19:30:23 +00:00
parent b0e3a21be5
commit 44f40f2b55
26 changed files with 161 additions and 7 deletions

View File

@ -70,6 +70,9 @@ def aclDoc(args):
json=json.dumps(payload), json=json.dumps(payload),
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -44,6 +44,11 @@ def activateSubject(args):
try: try:
req = requests.post(f'http://{state['REP_ADDRESS']}/user/' + args.username + '/activate', headers={'Authorization': args.session['token']}) req = requests.post(f'http://{state['REP_ADDRESS']}/user/' + args.username + '/activate', headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -61,6 +61,10 @@ def addDoc(args):
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)
@ -74,6 +78,10 @@ def addDoc(args):
headers={'Authorization': args.session['token'], 'File-Checksum' : digest.get_hash(content)}) headers={'Authorization': args.session['token'], 'File-Checksum' : digest.get_hash(content)})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
os.remove(BASE_DIR + 'encryptedText') os.remove(BASE_DIR + 'encryptedText')

View File

@ -66,6 +66,11 @@ def addPermission(args):
req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/perm/add/' + args.value, req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/perm/add/' + args.value,
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)
@ -77,6 +82,11 @@ def addPermission(args):
req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/user/add/' + args.value, req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/user/add/' + args.value,
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -49,11 +49,16 @@ def addRole(args):
json=json.dumps({'role' : args.role}), json=json.dumps({'role' : args.role}),
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)
logger.info("Role added.") logger.info("Role %s added.", args.role)
sys.exit(0) sys.exit(0)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -59,12 +59,16 @@ def addSubject(args):
req = requests.post(f'http://{state['REP_ADDRESS']}/user/create', json=json.dumps(subject), headers={'Authorization': args.session['token']}) req = requests.post(f'http://{state['REP_ADDRESS']}/user/create', json=json.dumps(subject), headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)
if req.status_code == 201: if req.status_code == 201:
logger.info('Subject added.') logger.info('Subject %s added.', args.username)
sys.exit(0) sys.exit(0)
logger.error('Failed to add subject.') logger.error('Failed to add subject.')
sys.exit(-1) sys.exit(-1)

View File

@ -46,6 +46,11 @@ def assumeRole(args):
try: try:
req = requests.post(f'http://{state['REP_ADDRESS']}/role/session/assume/' + args.role, headers={'Authorization': args.session['token']}) req = requests.post(f'http://{state['REP_ADDRESS']}/role/session/assume/' + args.role, headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -61,6 +61,11 @@ def createOrganization(args):
try: try:
req = requests.post(f'http://{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() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -50,6 +50,10 @@ def delDoc(args):
req = requests.post(f'http://{state['REP_ADDRESS']}/file/delete/' + doc_name, headers={'Authorization': args.session['token']}) req = requests.post(f'http://{state['REP_ADDRESS']}/file/delete/' + doc_name, headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -46,6 +46,11 @@ def dropRole(args):
try: try:
req = requests.post(f'http://{state['REP_ADDRESS']}/role/session/drop/' + args.role, headers={'Authorization': args.session['token']}) req = requests.post(f'http://{state['REP_ADDRESS']}/role/session/drop/' + args.role, headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -54,6 +54,10 @@ def getDoc(args):
metadata = requests.get(f'http://{state['REP_ADDRESS']}/file/get/' + doc_name + '/metadata', headers={'Authorization': args.session['token']}) metadata = requests.get(f'http://{state['REP_ADDRESS']}/file/get/' + doc_name + '/metadata', headers={'Authorization': args.session['token']})
metadata.raise_for_status() metadata.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", metadata.status_code, metadata.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(1) sys.exit(1)
@ -65,6 +69,11 @@ def getDoc(args):
try: try:
file = requests.get(f'http://{state['REP_ADDRESS']}/file/get/' + metadata['file_handle'] + '/content') file = requests.get(f'http://{state['REP_ADDRESS']}/file/get/' + metadata['file_handle'] + '/content')
file.raise_for_status() file.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", file.status_code, file.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -50,6 +50,11 @@ def getDocMetadata(args):
try: try:
metadata = requests.get(f'http://{state['REP_ADDRESS']}/file/get/' + doc_name + '/metadata', headers={'Authorization': args.session['token']}) metadata = requests.get(f'http://{state['REP_ADDRESS']}/file/get/' + doc_name + '/metadata', headers={'Authorization': args.session['token']})
metadata.raise_for_status() metadata.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", metadata.status_code, metadata.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -41,6 +41,11 @@ def getFile(args):
try: try:
file = requests.get(f'http://{state['REP_ADDRESS']}/file/get/' + args.filehandle + '/content') file = requests.get(f'http://{state['REP_ADDRESS']}/file/get/' + args.filehandle + '/content')
file.raise_for_status() file.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", file.status_code, file.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -66,6 +66,10 @@ def list_docs(args):
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
subjects.raise_for_status() subjects.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", subjects.status_code, subjects.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)
@ -84,6 +88,11 @@ def list_docs(args):
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
subjects.raise_for_status() subjects.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", subjects.status_code, subjects
.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)
@ -102,6 +111,10 @@ def list_docs(args):
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
subjects.raise_for_status() subjects.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", subjects.status_code, subjects.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)
@ -113,6 +126,10 @@ def list_docs(args):
subjects = requests.get(f'http://{state['REP_ADDRESS']}/file/list', json=json.dumps({}), headers={'Authorization': args.session['token']}) subjects = requests.get(f'http://{state['REP_ADDRESS']}/file/list', json=json.dumps({}), headers={'Authorization': args.session['token']})
subjects.raise_for_status() subjects.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", subjects.status_code, subjects.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -21,6 +21,10 @@ def listOrganizations():
orgs = requests.get(f'http://{state['REP_ADDRESS']}/org/list') orgs = requests.get(f'http://{state['REP_ADDRESS']}/org/list')
orgs.raise_for_status() orgs.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", orgs.status_code, orgs.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -47,6 +47,11 @@ def listPermissionRoles(args):
try: try:
req = requests.get(f'http://{state['REP_ADDRESS']}/role/perm/' + args.permission + '/roles', headers={'Authorization': args.session['token']}) req = requests.get(f'http://{state['REP_ADDRESS']}/role/perm/' + args.permission + '/roles', headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -47,6 +47,11 @@ def listRolePermissions(args):
try: try:
req = requests.get(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/list/perms', headers={'Authorization': args.session['token']}) req = requests.get(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/list/perms', headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -47,6 +47,11 @@ def listRoleSubjects(args):
try: try:
req = requests.get(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/list/users', headers={'Authorization': args.session['token']}) req = requests.get(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/list/users', headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -47,6 +47,11 @@ def listRoles(args):
try: try:
req = requests.get(f'http://{state['REP_ADDRESS']}/role/session/list', headers={'Authorization': args.session['token']}) req = requests.get(f'http://{state['REP_ADDRESS']}/role/session/list', headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -47,6 +47,11 @@ def listSubjectRoles(args):
try: try:
req = requests.get(f'http://{state['REP_ADDRESS']}/user/' + args.username + '/roles', headers={'Authorization': args.session['token']}) req = requests.get(f'http://{state['REP_ADDRESS']}/user/' + args.username + '/roles', headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -50,6 +50,10 @@ def list_subjects(args):
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
subjects.raise_for_status() subjects.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", subjects.status_code, subjects.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)
@ -61,6 +65,10 @@ def list_subjects(args):
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
subjects.raise_for_status() subjects.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", subjects.status_code, subjects.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -48,6 +48,11 @@ def reactivateRole(args):
try: try:
req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/activate', headers={'Authorization': args.session['token']}) req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/activate', headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -44,7 +44,7 @@ def removePermission(args):
with open(BASE_DIR + args.session, 'r') as f: with open(BASE_DIR + args.session, 'r') as f:
args.session = json.load(f) args.session = json.load(f)
isPerm = False; isUsername = False isPerm = False
# query for permission # query for permission
if args.value in [ if args.value in [
@ -65,26 +65,33 @@ def removePermission(args):
req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/perm/remove/' + args.value, req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/perm/remove/' + args.value,
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)
logger.info("Permission removed from role successfully.") logger.info("Permission removed from role successfully.")
sys.exit(0) sys.exit(0)
elif isUsername: else:
try: try:
req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/user/remove/' + args.value, req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/user/remove/' + args.value,
headers={'Authorization': args.session['token']}) headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)
logger.info("Subject removed from role successfully.") logger.info("Subject removed from role successfully.")
sys.exit(0) sys.exit(0)
else:
logger.error("Invalid permission or username.")
sys.exit(1)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -48,6 +48,11 @@ def suspendRole(args):
try: try:
req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/suspend', headers={'Authorization': args.session['token']}) req = requests.post(f'http://{state['REP_ADDRESS']}/role/' + args.role + '/suspend', headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -45,6 +45,11 @@ def suspendSubject(args):
try: try:
req = requests.post(f'http://{state['REP_ADDRESS']}/user/' + args.username + '/suspend', headers={'Authorization': args.session['token']}) req = requests.post(f'http://{state['REP_ADDRESS']}/user/' + args.username + '/suspend', headers={'Authorization': args.session['token']})
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)

View File

@ -34,6 +34,11 @@ def reset(args):
try: try:
req = requests.post(f'http://{state['REP_ADDRESS']}/reset',json=json.dumps({'password' : args.password})) req = requests.post(f'http://{state['REP_ADDRESS']}/reset',json=json.dumps({'password' : args.password}))
req.raise_for_status() req.raise_for_status()
except requests.exceptions.HTTPError:
logger.error("%d: %s", req.status_code, req.json()['error'])
sys.exit(-1)
except requests.exceptions.RequestException as errex: except requests.exceptions.RequestException as errex:
logger.error("Failed to obtain response from server.") logger.error("Failed to obtain response from server.")
sys.exit(-1) sys.exit(-1)