Skip to content

Commit ff09ea1

Browse files
committed
πŸ§‘β€πŸ’» Use spaces indent for Python
1 parent d93c41a commit ff09ea1

28 files changed

+2222
-2218
lines changed

β€Ž.editorconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ end_of_line = lf
1414
indent_style = space
1515
indent_size = 2
1616

17-
[{*.py,*.conf,*.sublime-project}]
17+
[{*.py}]
18+
indent_style = space
19+
indent_size = 4
20+
21+
[{*.conf,*.sublime-project}]
1822
indent_style = tab
1923
indent_size = 4

β€ŽMarlin/src/HAL/LPC1768/upload_extra_script.py

Lines changed: 112 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -9,127 +9,127 @@
99
import pioutil
1010
if pioutil.is_pio_build():
1111

12-
target_filename = "FIRMWARE.CUR"
13-
target_drive = "REARM"
12+
target_filename = "FIRMWARE.CUR"
13+
target_drive = "REARM"
1414

15-
import platform
15+
import platform
1616

17-
current_OS = platform.system()
18-
Import("env")
17+
current_OS = platform.system()
18+
Import("env")
1919

20-
def print_error(e):
21-
print('\nUnable to find destination disk (%s)\n' \
22-
'Please select it in platformio.ini using the upload_port keyword ' \
23-
'(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \
24-
'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \
25-
%(e, env.get('PIOENV')))
20+
def print_error(e):
21+
print('\nUnable to find destination disk (%s)\n' \
22+
'Please select it in platformio.ini using the upload_port keyword ' \
23+
'(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \
24+
'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \
25+
%(e, env.get('PIOENV')))
2626

27-
def before_upload(source, target, env):
28-
try:
29-
from pathlib import Path
30-
#
31-
# Find a disk for upload
32-
#
33-
upload_disk = 'Disk not found'
34-
target_file_found = False
35-
target_drive_found = False
36-
if current_OS == 'Windows':
37-
#
38-
# platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:'
39-
# Windows - doesn't care about the disk's name, only cares about the drive letter
40-
import subprocess,string
41-
from ctypes import windll
42-
from pathlib import PureWindowsPath
27+
def before_upload(source, target, env):
28+
try:
29+
from pathlib import Path
30+
#
31+
# Find a disk for upload
32+
#
33+
upload_disk = 'Disk not found'
34+
target_file_found = False
35+
target_drive_found = False
36+
if current_OS == 'Windows':
37+
#
38+
# platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:'
39+
# Windows - doesn't care about the disk's name, only cares about the drive letter
40+
import subprocess,string
41+
from ctypes import windll
42+
from pathlib import PureWindowsPath
4343

44-
# getting list of drives
45-
# https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
46-
drives = []
47-
bitmask = windll.kernel32.GetLogicalDrives()
48-
for letter in string.ascii_uppercase:
49-
if bitmask & 1:
50-
drives.append(letter)
51-
bitmask >>= 1
44+
# getting list of drives
45+
# https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
46+
drives = []
47+
bitmask = windll.kernel32.GetLogicalDrives()
48+
for letter in string.ascii_uppercase:
49+
if bitmask & 1:
50+
drives.append(letter)
51+
bitmask >>= 1
5252

53-
for drive in drives:
54-
final_drive_name = drive + ':'
55-
# print ('disc check: {}'.format(final_drive_name))
56-
try:
57-
volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT))
58-
except Exception as e:
59-
print ('error:{}'.format(e))
60-
continue
61-
else:
62-
if target_drive in volume_info and not target_file_found: # set upload if not found target file yet
63-
target_drive_found = True
64-
upload_disk = PureWindowsPath(final_drive_name)
65-
if target_filename in volume_info:
66-
if not target_file_found:
67-
upload_disk = PureWindowsPath(final_drive_name)
68-
target_file_found = True
53+
for drive in drives:
54+
final_drive_name = drive + ':'
55+
# print ('disc check: {}'.format(final_drive_name))
56+
try:
57+
volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT))
58+
except Exception as e:
59+
print ('error:{}'.format(e))
60+
continue
61+
else:
62+
if target_drive in volume_info and not target_file_found: # set upload if not found target file yet
63+
target_drive_found = True
64+
upload_disk = PureWindowsPath(final_drive_name)
65+
if target_filename in volume_info:
66+
if not target_file_found:
67+
upload_disk = PureWindowsPath(final_drive_name)
68+
target_file_found = True
6969

70-
elif current_OS == 'Linux':
71-
#
72-
# platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
73-
#
74-
import getpass
75-
user = getpass.getuser()
76-
mpath = Path('media', user)
77-
drives = [ x for x in mpath.iterdir() if x.is_dir() ]
78-
if target_drive in drives: # If target drive is found, use it.
79-
target_drive_found = True
80-
upload_disk = mpath / target_drive
81-
else:
82-
for drive in drives:
83-
try:
84-
fpath = mpath / drive
85-
filenames = [ x.name for x in fpath.iterdir() if x.is_file() ]
86-
except:
87-
continue
88-
else:
89-
if target_filename in filenames:
90-
upload_disk = mpath / drive
91-
target_file_found = True
92-
break
93-
#
94-
# set upload_port to drive if found
95-
#
70+
elif current_OS == 'Linux':
71+
#
72+
# platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
73+
#
74+
import getpass
75+
user = getpass.getuser()
76+
mpath = Path('media', user)
77+
drives = [ x for x in mpath.iterdir() if x.is_dir() ]
78+
if target_drive in drives: # If target drive is found, use it.
79+
target_drive_found = True
80+
upload_disk = mpath / target_drive
81+
else:
82+
for drive in drives:
83+
try:
84+
fpath = mpath / drive
85+
filenames = [ x.name for x in fpath.iterdir() if x.is_file() ]
86+
except:
87+
continue
88+
else:
89+
if target_filename in filenames:
90+
upload_disk = mpath / drive
91+
target_file_found = True
92+
break
93+
#
94+
# set upload_port to drive if found
95+
#
9696

97-
if target_file_found or target_drive_found:
98-
env.Replace(
99-
UPLOAD_FLAGS="-P$UPLOAD_PORT"
100-
)
97+
if target_file_found or target_drive_found:
98+
env.Replace(
99+
UPLOAD_FLAGS="-P$UPLOAD_PORT"
100+
)
101101

102-
elif current_OS == 'Darwin': # MAC
103-
#
104-
# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
105-
#
106-
dpath = Path('/Volumes') # human readable names
107-
drives = [ x for x in dpath.iterdir() if x.is_dir() ]
108-
if target_drive in drives and not target_file_found: # set upload if not found target file yet
109-
target_drive_found = True
110-
upload_disk = dpath / target_drive
111-
for drive in drives:
112-
try:
113-
fpath = dpath / drive # will get an error if the drive is protected
114-
filenames = [ x.name for x in fpath.iterdir() if x.is_file() ]
115-
except:
116-
continue
117-
else:
118-
if target_filename in filenames:
119-
upload_disk = dpath / drive
120-
target_file_found = True
121-
break
102+
elif current_OS == 'Darwin': # MAC
103+
#
104+
# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
105+
#
106+
dpath = Path('/Volumes') # human readable names
107+
drives = [ x for x in dpath.iterdir() if x.is_dir() ]
108+
if target_drive in drives and not target_file_found: # set upload if not found target file yet
109+
target_drive_found = True
110+
upload_disk = dpath / target_drive
111+
for drive in drives:
112+
try:
113+
fpath = dpath / drive # will get an error if the drive is protected
114+
filenames = [ x.name for x in fpath.iterdir() if x.is_file() ]
115+
except:
116+
continue
117+
else:
118+
if target_filename in filenames:
119+
upload_disk = dpath / drive
120+
target_file_found = True
121+
break
122122

123-
#
124-
# Set upload_port to drive if found
125-
#
126-
if target_file_found or target_drive_found:
127-
env.Replace(UPLOAD_PORT=str(upload_disk))
128-
print('\nUpload disk: ', upload_disk, '\n')
129-
else:
130-
print_error('Autodetect Error')
123+
#
124+
# Set upload_port to drive if found
125+
#
126+
if target_file_found or target_drive_found:
127+
env.Replace(UPLOAD_PORT=str(upload_disk))
128+
print('\nUpload disk: ', upload_disk, '\n')
129+
else:
130+
print_error('Autodetect Error')
131131

132-
except Exception as e:
133-
print_error(str(e))
132+
except Exception as e:
133+
print_error(str(e))
134134

135-
env.AddPreAction("upload", before_upload)
135+
env.AddPreAction("upload", before_upload)

β€ŽMarlin/src/feature/spindle_laser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class SpindleLaser {
285285
if (!menuPower) menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP);
286286
power = upower_to_ocr(menuPower);
287287
apply_power(power);
288-
} else
288+
} else
289289
apply_power(0);
290290
}
291291

β€Žbuildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
#
55
import pioutil
66
if pioutil.is_pio_build():
7-
from os.path import join, isfile
8-
import shutil
7+
from os.path import join, isfile
8+
import shutil
99

10-
Import("env")
10+
Import("env")
1111

12-
mf = env["MARLIN_FEATURES"]
13-
rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0"
14-
txBuf = mf["TX_BUFFER_SIZE"] if "TX_BUFFER_SIZE" in mf else "0"
12+
mf = env["MARLIN_FEATURES"]
13+
rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0"
14+
txBuf = mf["TX_BUFFER_SIZE"] if "TX_BUFFER_SIZE" in mf else "0"
1515

16-
serialBuf = str(max(int(rxBuf), int(txBuf), 350))
16+
serialBuf = str(max(int(rxBuf), int(txBuf), 350))
1717

18-
build_flags = env.get('BUILD_FLAGS')
19-
build_flags.append("-DSERIAL_BUFFER_SIZE=" + serialBuf)
20-
env.Replace(BUILD_FLAGS=build_flags)
18+
build_flags = env.get('BUILD_FLAGS')
19+
build_flags.append("-DSERIAL_BUFFER_SIZE=" + serialBuf)
20+
env.Replace(BUILD_FLAGS=build_flags)

0 commit comments

Comments
Β (0)