Переглянути джерело

🔨 Fix LPC1768 automatic upload port (#24599)

Graham Reed 2 роки тому
джерело
коміт
dab60a1cb7
Аккаунт користувача з таким Email не знайдено
1 змінених файлів з 8 додано та 8 видалено
  1. 8
    8
      Marlin/src/HAL/LPC1768/upload_extra_script.py

+ 8
- 8
Marlin/src/HAL/LPC1768/upload_extra_script.py Переглянути файл

@@ -82,11 +82,11 @@ if pioutil.is_pio_build():
82 82
 					for drive in drives:
83 83
 						try:
84 84
 							fpath = mpath / drive
85
-							files = [ x for x in fpath.iterdir() if x.is_file() ]
85
+							filenames = [ x.name for x in fpath.iterdir() if x.is_file() ]
86 86
 						except:
87 87
 							continue
88 88
 						else:
89
-							if target_filename in files:
89
+							if target_filename in filenames:
90 90
 								upload_disk = mpath / drive
91 91
 								target_file_found = True
92 92
 								break
@@ -104,21 +104,21 @@ if pioutil.is_pio_build():
104 104
 				# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
105 105
 				#
106 106
 				dpath = Path('/Volumes')  # human readable names
107
-				drives = [ x for x in dpath.iterdir() ]
107
+				drives = [ x for x in dpath.iterdir() if x.is_dir() ]
108 108
 				if target_drive in drives and not target_file_found:  # set upload if not found target file yet
109 109
 					target_drive_found = True
110 110
 					upload_disk = dpath / target_drive
111 111
 				for drive in drives:
112 112
 					try:
113
-						fpath = dpath / drive   # will get an error if the drive is protected
114
-						files = [ x for x in fpath.iterdir() ]
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 115
 					except:
116 116
 						continue
117 117
 					else:
118
-						if target_filename in files:
119
-							if not target_file_found:
120
-								upload_disk = dpath / drive
118
+						if target_filename in filenames:
119
+							upload_disk = dpath / drive
121 120
 							target_file_found = True
121
+							break
122 122
 
123 123
 			#
124 124
 			# Set upload_port to drive if found

Завантаження…
Відмінити
Зберегти