Skip to content
Snippets Groups Projects
Commit 13998972 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch '6-don-t-stop-if-there-is-only-a-single-connection-error' into 'master'

Resolve "Don't stop if there is only a single connection error"

Closes #6

See merge request !17
parents c679843e fefda706
No related branches found
No related tags found
1 merge request!17Resolve "Don't stop if there is only a single connection error"
Pipeline #20882 passed
......@@ -74,19 +74,24 @@ categories_url = base_url + "/api/categories/"
def print_server():
while True:
# Get auth token
r = requests.post(
login_url,
json={
"username": settings.get("server.username"),
"password": settings.get("server.password"),
},
)
token = r.json()["token"]
headers = {"Authorization": f"Token {token}"}
# Fetch print jobs
jobs = requests.get(jobs_url, headers=headers).json()
try:
# Get auth token
r = requests.post(
login_url,
json={
"username": settings.get("server.username"),
"password": settings.get("server.password"),
},
)
token = r.json()["token"]
headers = {"Authorization": f"Token {token}"}
# Fetch print jobs
jobs = requests.get(jobs_url, headers=headers).json()
except requests.exceptions.ConnectionError:
print("Fetching latest jobs failed due to a connection error.")
time.sleep(3)
continue
# Fetch categories
categories = requests.get(categories_url, headers=headers).json()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment