Remove unusable code

Since the Request class catches/re-raises every errors (including
http non-200 status codes) some lines could never be reached. Some
of these lines were already removed in the previous commit.
This commit is contained in:
Max Ziermann
2020-03-04 12:28:04 +01:00
parent 5d4a38f9a2
commit 7512ce40ea
2 changed files with 4 additions and 14 deletions

View File

@@ -122,14 +122,8 @@ class APIHandler:
}}}]
param = {"token": self.token}
response = Request.post(self.url, data=body, params=param)
if response is not None:
if response.status_code == 200:
print("Successfully Set Network Ports")
return True
else:
print("Something went wront\nStatus Code:", response.status_code)
return False
return False
except Exception as e:
print("Setting Network Port Error\n", e)
raise
@@ -159,10 +153,7 @@ class APIHandler:
{"cmd": "GetP2p", "action": 0, "param": {}}]
param = {"token": self.token}
response = Request.post(self.url, data=body, params=param)
if response.status_code == 200:
return json.loads(response.text)
print("Could not get network ports data. Status:", response.status_code)
return None
except Exception as e:
print("Get Network Ports", e)
@@ -447,7 +438,6 @@ class APIHandler:
:return: Image or None
"""
try:
randomstr = ''.join(random.choices(string.ascii_uppercase + string.digits, k=10))
snap = self.url + "?cmd=Snap&channel=0&rs=" \
+ randomstr \

View File

@@ -28,7 +28,7 @@ class Request:
if r.status_code == 200:
return r
else:
raise ValueError("Status: ", r.status_code)
raise ValueError(f"Http Request had non-200 Status: {r.status_code}", r.status_code)
except Exception as e:
print("Post Error\n", e)
raise