Skip to content

Commit

Permalink
Add some handling in the case of an empty or otherwise invalid
Browse files Browse the repository at this point in the history
response from a truenas when fetching SMB share list
  • Loading branch information
kmoore134 committed Aug 9, 2024
1 parent d5370a1 commit 9e80dfd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion share_sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,14 @@ def api_call(host, apikey, command, args, wssmode):
print("WARNING: Failed to connect to: " + host)
if e.error:
print(e.error, file=sys.stderr)
return ""

except (FileNotFoundError, ConnectionRefusedError):
if wssprefix == "ws://":
return api_call(host, apikey, command, args, True)
else:
print("WARNING: Failed to connect to: " + host)
return ""


def get_smb_shares(host, apikey):
Expand All @@ -298,7 +300,12 @@ def get_smb_shares(host, apikey):

print("Fetching SMB share list from TrueNAS: " + host)

return api_call(host, apikey, command, list(), False)
api_response = api_call(host, apikey, command, list(), False)
if api_response != "":
return api_response
else:
print("Invalid sharing.smb.query response from " + host)
return ""


def main():
Expand Down

0 comments on commit 9e80dfd

Please sign in to comment.