Skip to content

Commit

Permalink
Update the route and reponse handling of the upload compliance module
Browse files Browse the repository at this point in the history
  • Loading branch information
aaTarek authored and hezanathos committed Jul 27, 2023
1 parent 41e61e7 commit 05e1e7a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions cli/bin/airgap/upload_compliance_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,20 @@ def upload_result_file(result_file, verify_ssl=False):
# Sending result
apiResponse = Cyberwatch_Pyhelper().request(
method="POST",
endpoint="/api/v2/cbw_scans/scripts",
endpoint="/api/v2/compliances/scripts",
body_params={
"output" : file_content
},
verify_ssl=verify_ssl
)
result = next(apiResponse).json()
# If the operation is successful, the apiResponse is empty and the status code is 204
# Else, an error is reported with a status code != 204
result = next(apiResponse)

# Printing the upload result
if 'error' in result:
print("ERROR : " + result["error"]["message"])
elif 'server_id' in result:
print("[+] Upload successful ! Server ID : " + str(result["server_id"]))
if result.status_code == 204:
print("Upload is successful.")
else:
print("Upload is done.")

return next(apiResponse).json()
print("ERROR : " + str(result.content))

def manager(arguments, verify_ssl=False):

Expand Down

0 comments on commit 05e1e7a

Please sign in to comment.