Browse Source

🔨 Fix LPC1768 automatic upload port (#24599)

FB4S_WIFI
Graham Reed 2 years ago
committed by Scott Lahteine
parent
commit
98e6aacbef
  1. 16
      Marlin/src/HAL/LPC1768/upload_extra_script.py

16
Marlin/src/HAL/LPC1768/upload_extra_script.py

@ -82,11 +82,11 @@ if pioutil.is_pio_build():
for drive in drives: for drive in drives:
try: try:
fpath = mpath / drive fpath = mpath / drive
files = [ x for x in fpath.iterdir() if x.is_file() ] filenames = [ x.name for x in fpath.iterdir() if x.is_file() ]
except: except:
continue continue
else: else:
if target_filename in files: if target_filename in filenames:
upload_disk = mpath / drive upload_disk = mpath / drive
target_file_found = True target_file_found = True
break break
@ -104,21 +104,21 @@ if pioutil.is_pio_build():
# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive' # platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
# #
dpath = Path('/Volumes') # human readable names dpath = Path('/Volumes') # human readable names
drives = [ x for x in dpath.iterdir() ] drives = [ x for x in dpath.iterdir() if x.is_dir() ]
if target_drive in drives and not target_file_found: # set upload if not found target file yet if target_drive in drives and not target_file_found: # set upload if not found target file yet
target_drive_found = True target_drive_found = True
upload_disk = dpath / target_drive upload_disk = dpath / target_drive
for drive in drives: for drive in drives:
try: try:
fpath = dpath / drive # will get an error if the drive is protected fpath = dpath / drive # will get an error if the drive is protected
files = [ x for x in fpath.iterdir() ] filenames = [ x.name for x in fpath.iterdir() if x.is_file() ]
except: except:
continue continue
else: else:
if target_filename in files: if target_filename in filenames:
if not target_file_found: upload_disk = dpath / drive
upload_disk = dpath / drive
target_file_found = True target_file_found = True
break
# #
# Set upload_port to drive if found # Set upload_port to drive if found

Loading…
Cancel
Save