Skip to content

Commit 242dd7c

Browse files
committed
Linted
1 parent 08d5e4a commit 242dd7c

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

Web_Workflow_Quickstart/boot.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import storage
2+
import microcontroller
3+
4+
if microcontroller.nvm[0] != 1:
5+
storage.disable_usb_drive()

Web_Workflow_Quickstart/env.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1+
import os
12
import storage
23
import microcontroller
3-
import os
44

55
# Get all files in the format of .env.xxxxxxxxxx
66
def enumerate_env_files():
7-
env_files = []
7+
found_files = []
88
all_files = os.listdir("/")
9-
for file in all_files:
10-
if file[:4] == ".env" and len(file) > 4:
11-
env_files.append(file)
12-
return env_files
9+
for current_file in all_files:
10+
if current_file[:4] == ".env" and len(current_file) > 4:
11+
found_files.append(current_file)
12+
return found_files
13+
1314

1415
# Compare .env to enumerated env files
15-
def get_current_env_file(env_files):
16-
with open('.env') as env:
16+
def get_current_env_file(enumerated_files):
17+
with open(".env") as env:
1718
env_lines = env.readlines()
18-
for env_file in env_files:
19+
for env_file in enumerated_files:
1920
with open(env_file) as f:
2021
lines = f.readlines()
2122
if len(env_lines) != len(lines):
@@ -30,12 +31,13 @@ def get_current_env_file(env_files):
3031
return env_file
3132
return None
3233

34+
3335
# Erase .env then write the contents of the new env file
3436
def change_env_file(env_file):
3537
try:
3638
storage.remount("/", False)
37-
open('.env', 'w').close()
38-
with open('.env', 'w') as env, open(env_file) as f:
39+
open(".env", "w").close()
40+
with open(".env", "w") as env, open(env_file) as f:
3941
for line in f.readlines():
4042
env.write(line)
4143
env.close()
@@ -44,6 +46,7 @@ def change_env_file(env_file):
4446
except RuntimeError:
4547
print("You can't change the env file with this script while USB is mounted")
4648

49+
4750
# Return a prettier name than the env file
4851
def pretty_name(env_file):
4952
name = env_file[5:]
@@ -62,16 +65,16 @@ def pretty_name(env_file):
6265
if len(env_files) == 1:
6366
answer = input(f"Change to {pretty_name(env_files[0])}? ")
6467
answer = answer.lower()
65-
if answer == "y" or answer == "yes":
68+
if answer in ("y", "yes"):
6669
change_env_file(env_files[0])
6770
else:
6871
valid_selection = False
6972
while not valid_selection:
7073
print("Select an option:")
7174
for index, file in enumerate(env_files):
7275
print(f"{index + 1}: {pretty_name(file)}")
73-
answer = input(f"Which option would you like? ")
76+
answer = input("Which option would you like? ")
7477
if answer.isdigit() and 0 < int(answer) <= len(env_files):
7578
valid_selection = True
7679
change_env_file(env_files[int(answer) - 1])
77-
print(f"{answer} was an invalid selection.\n")
80+
print(f"{answer} was an invalid selection.\n")

Web_Workflow_Quickstart/usb/check.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import microcontroller
2-
print(f"USB Mass Storage is {'enabled' if microcontroller.nvm[0] == 1 else 'disabled'} on this device")
2+
status = 'enabled' if microcontroller.nvm[0] == 1 else 'disabled'
3+
print(f"USB Mass Storage is {status} on this device")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import microcontroller
22
microcontroller.nvm[0] = 0
3-
microcontroller.reset()
3+
microcontroller.reset()

Web_Workflow_Quickstart/usb/enable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import microcontroller
22
microcontroller.nvm[0] = 1
3-
microcontroller.reset()
3+
microcontroller.reset()

0 commit comments

Comments
 (0)