Pārlūkot izejas kodu

🔨 Fix LPC1768 automatic upload port (#24599)

Graham Reed 1 gadu atpakaļ
vecāks
revīzija
dab60a1cb7
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
1 mainītis faili ar 8 papildinājumiem un 8 dzēšanām
  1. 8
    8
      Marlin/src/HAL/LPC1768/upload_extra_script.py

+ 8
- 8
Marlin/src/HAL/LPC1768/upload_extra_script.py Parādīt failu

82
 					for drive in drives:
82
 					for drive in drives:
83
 						try:
83
 						try:
84
 							fpath = mpath / drive
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
 						except:
86
 						except:
87
 							continue
87
 							continue
88
 						else:
88
 						else:
89
-							if target_filename in files:
89
+							if target_filename in filenames:
90
 								upload_disk = mpath / drive
90
 								upload_disk = mpath / drive
91
 								target_file_found = True
91
 								target_file_found = True
92
 								break
92
 								break
104
 				# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
104
 				# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
105
 				#
105
 				#
106
 				dpath = Path('/Volumes')  # human readable names
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
 				if target_drive in drives and not target_file_found:  # set upload if not found target file yet
108
 				if target_drive in drives and not target_file_found:  # set upload if not found target file yet
109
 					target_drive_found = True
109
 					target_drive_found = True
110
 					upload_disk = dpath / target_drive
110
 					upload_disk = dpath / target_drive
111
 				for drive in drives:
111
 				for drive in drives:
112
 					try:
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
 					except:
115
 					except:
116
 						continue
116
 						continue
117
 					else:
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
 							target_file_found = True
120
 							target_file_found = True
121
+							break
122
 
122
 
123
 			#
123
 			#
124
 			# Set upload_port to drive if found
124
 			# Set upload_port to drive if found

Notiek ielāde…
Atcelt
Saglabāt