Skip to content

Commit e9a6254

Browse files
committed
Fix formatting
1 parent a4dad08 commit e9a6254

File tree

5 files changed

+33
-25
lines changed

5 files changed

+33
-25
lines changed

demos/all_on/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run(self):
2828
# Create generator here
2929
for column in range(0, self.screen.x_width):
3030
for row in range(0, self.screen.y_height):
31-
self.screen.draw_pixel(column, row, 0xf, combine=True)
31+
self.screen.draw_pixel(column, row, 0xF, combine=True)
3232

3333
self.screen.push()
3434
while True:
@@ -37,4 +37,3 @@ def run(self):
3737
def stop(self):
3838
"""Reset the state of the demo if needed, else leave blank"""
3939
pass
40-

demos/prusa/main.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import yaml
33
import requests
44

5+
56
class Prusa:
67
"""
78
This is not a game, but a demo that shows the status of a Prusa printer
@@ -35,11 +36,11 @@ def __init__(self, input_queue, output_queue, screen):
3536
self.screen = screen
3637

3738
# init demo/game specific variables here
38-
config_path = os.path.join(os.path.dirname(__file__), 'config.yaml')
39-
with open(config_path, 'r') as f:
39+
config_path = os.path.join(os.path.dirname(__file__), "config.yaml")
40+
with open(config_path, "r") as f:
4041
config = yaml.safe_load(f)
41-
self.prusalink_ip = config.get('prusalink_ip')
42-
self.api_key = config.get('api_key')
42+
self.prusalink_ip = config.get("prusalink_ip")
43+
self.api_key = config.get("api_key")
4344
self.URL = f"http://{self.prusalink_ip}/api/v1/job"
4445
self.HEADERS = {
4546
"X-Api-Key": self.api_key,
@@ -58,7 +59,6 @@ def __init__(self, input_queue, output_queue, screen):
5859
self.display_time_left = "0"
5960
self.display_progress = 0
6061

61-
6262
def get_stats(self):
6363
"""
6464
Returns static information.
@@ -73,8 +73,8 @@ def get_stats(self):
7373
return self._get_default_stats()
7474

7575
# Check content type
76-
content_type = self.response.headers.get('content-type', '')
77-
if 'application/json' not in content_type:
76+
content_type = self.response.headers.get("content-type", "")
77+
if "application/json" not in content_type:
7878
print(f"Unexpected content type: {content_type}")
7979
print(f"Response body: {self.response.text[:200]}") # First 200 chars
8080
return self._get_default_stats()
@@ -86,7 +86,9 @@ def get_stats(self):
8686
self.progress = self.data.get("progress", 0)
8787
self.time_elapsed = self.data.get("time_printing", "N/A")
8888
self.time_left = self.data.get("time_remaining", "N/A")
89-
self.minutes_left = self.time_left // 60 if isinstance(self.time_left, int) else "N/A"
89+
self.minutes_left = (
90+
self.time_left // 60 if isinstance(self.time_left, int) else "N/A"
91+
)
9092

9193
except requests.RequestException as e:
9294
# print(f"Request failed: {e}")
@@ -123,34 +125,36 @@ def run(self):
123125
# Create generator here
124126
while True:
125127
self.stats = self.get_stats()
126-
128+
127129
# print("=== Printer Status ===")
128130
# print(f"time left: {self.stats['time_left']}")
129131
# print(f"Stats: {self.stats}")
130132
# draw the filename
131-
self.display_status = self.stats['state']
133+
self.display_status = self.stats["state"]
132134
# print(f"Status: {self.display_status}")
133-
if self.stats['state'] == "IDLE" and int(self.display_time_elapsed[0:8].strip()) > 0:
135+
if (
136+
self.stats["state"] == "IDLE"
137+
and int(self.display_time_elapsed[0:8].strip()) > 0
138+
):
134139
self.display_progress = 0
135140
self.display_time_elapsed = "0"
136141
self.display_time_left = "0"
137142
self.display_filename = "N/A"
138143
self.screen.clear()
139144
print("hit")
140-
141145

142146
self.screen.draw_text(
143147
self.screen.x_width // 2 - 8,
144148
self.screen.y_height // 2 - 6,
145149
self.display_status,
146150
push=True,
147151
)
148-
149-
if self.stats['state'] == "IDLE":
152+
153+
if self.stats["state"] == "IDLE":
150154
yield
151155
continue
152156

153-
self.display_filename = self.stats['filename'][:16].upper()
157+
self.display_filename = self.stats["filename"][:16].upper()
154158
# print(f"Filename: {self.display_filename}")
155159
self.screen.draw_text(
156160
self.screen.x_width // 2 - 8,
@@ -159,9 +163,10 @@ def run(self):
159163
push=True,
160164
)
161165

162-
163166
# print(f"Time left: {self.stats['minutes_left']} minutes")
164-
self.display_time_elapsed = f"{str(self.stats['time_elapsed']):>5} ELAPSED"
167+
self.display_time_elapsed = (
168+
f"{str(self.stats['time_elapsed']):>5} ELAPSED"
169+
)
165170
self.screen.draw_text(
166171
self.screen.x_width // 2 - 8,
167172
self.screen.y_height // 2 - 2,
@@ -179,7 +184,7 @@ def run(self):
179184
)
180185

181186
# Map progress (0-100) to a value between 0 and 16
182-
percentage_complete = int((self.stats['progress'] / 100) * 16)
187+
percentage_complete = int((self.stats["progress"] / 100) * 16)
183188
percentage_complete = max(0, min(percentage_complete, 16))
184189
# print(f"Progress: {self.stats['progress']}%, (mapped to {percentage_complete})")
185190
self.display_progress = f"{int(self.stats['progress']):>5} PROGRESS"

display/physical_screen_v2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ def _create_display(self):
3535
# need to have an array of ip addresses if more panels
3636
panel_array = [
3737
[
38-
SevenSegment(ip_address=self.addresses[i * self.num_segs_across + j],
39-
brightness=self.brightness)
38+
SevenSegment(
39+
ip_address=self.addresses[i * self.num_segs_across + j],
40+
brightness=self.brightness,
41+
)
4042
for j in range(self.num_segs_across)
4143
]
4244
for i in range(self.num_segs_down)

main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ def run_simulator():
8080
)
8181
def run_kiosk(simulate, new_hardware, testing, presentation):
8282
"""CLI command to run kiosk."""
83-
kiosk.run(simulate, testing=testing, new_hardware=new_hardware, presentation=presentation)
83+
kiosk.run(
84+
simulate, testing=testing, new_hardware=new_hardware, presentation=presentation
85+
)
8486

8587

8688
@cli.command("demo")

runners/kiosk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def get_random_demo(demos):
2727
for demo in demos:
2828
yield demo
2929

30+
3031
def get_presentation_demo(demos):
3132
"""
3233
Generator that gets a random demo. It makes sure all demos have been
@@ -46,7 +47,7 @@ def get_presentation_demo(demos):
4647
demos["cube"],
4748
demos["breakout_ai"],
4849
demos["snake_ai"],
49-
demos["video"]
50+
demos["video"],
5051
]
5152

5253
# Set shorter demo times
@@ -62,7 +63,6 @@ def get_presentation_demo(demos):
6263
yield demo
6364

6465

65-
6666
def get_demo_from_user(system_queue, demos):
6767
"""Receives input from user and returns the selected demo.
6868

0 commit comments

Comments
 (0)