Skip to content

Commit

Permalink
Ensure sys.exit() is noisy. (#58)
Browse files Browse the repository at this point in the history
Ensure that when Import/Export tool fails, it sets the error code to a non-zero value, otherwise the parent process will assume everything is fine.
  • Loading branch information
MarkJMReynolds-SAG committed Feb 7, 2023
1 parent fb7da9e commit 1790170
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion simulators/extras/ArgumentsAndCredentialsHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def HandleImportArguments():

if not os.path.exists("export_data"):
logging.info("No export_data folder found")
sys.exit()
sys.exit(1)
INPUT_FILE_LIST = args.ifiles
if not INPUT_FILE_LIST:
INPUT_FILE_LIST = []
Expand Down
8 changes: 4 additions & 4 deletions simulators/extras/ExportProfileData.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
else:
consoleLogger.error(tenantConnectionResponse.json())
consoleLogger.error(f"Connect to tenant {c8y.tenant_id} failed")
sys.exit()
sys.exit(1)
######################################################


Expand Down Expand Up @@ -86,13 +86,13 @@ def FindDeviceNameById(deviceId, baseUrl):
headers=C8Y_HEADERS)
if not response.ok:
consoleLogger.error(response.json())
sys.exit()
sys.exit(1)
else:
try:
deviceName = response.json()['name']
except:
consoleLogger.error(f"Device #{deviceId} does not have name")
sys.exit()
sys.exit(1)

return deviceName

Expand Down Expand Up @@ -135,7 +135,7 @@ def GetExternalIdReponse(deviceId, baseUrl):
headers=C8Y_HEADERS)
if not externalIdResponse.ok:
consoleLogger.error(externalIdResponse.json())
sys.exit()
sys.exit(1)
else:
return externalIdResponse

Expand Down
2 changes: 1 addition & 1 deletion simulators/extras/ImportData.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
else:
consoleLogger.error(tenantConnectionResponse.json())
consoleLogger.error(f"Connection to tenant \"{c8y.tenant_id}\" failed with user {c8y.username} on {c8y.base_url}")
sys.exit()
sys.exit(1)
######################################################


Expand Down

0 comments on commit 1790170

Please sign in to comment.