@@ -210,28 +210,31 @@ def _update_device_from_fs(self, device, read_details_txt):
210
210
device ['device_type' ] = 'unknown'
211
211
return
212
212
213
- device ['device_type' ] = self ._detect_device_type (device ['mount_point' ])
213
+ directory_entries = os .listdir (device ['mount_point' ])
214
+ device ['device_type' ] = self ._detect_device_type (directory_entries )
214
215
device ['target_id' ] = device ['target_id_usb_id' ]
215
216
216
217
{
217
218
'daplink' : self ._update_device_details_daplink ,
218
219
'jlink' : self ._update_device_details_jlink
219
- }[device ['device_type' ]](device , read_details_txt )
220
+ }[device ['device_type' ]](device , read_details_txt , directory_entries )
220
221
221
- def _detect_device_type (self , mount_point ):
222
+
223
+ def _detect_device_type (self , directory_entries ):
222
224
""" Returns a string of the device type
225
+ @param directory_entries List of directories and files on the device
223
226
@return 'daplink' or 'jlink'
224
227
"""
225
228
226
- files = [f .lower () for f in os .listdir (mount_point )]
227
- return 'jlink' if 'segger.html' in files else 'daplink'
229
+ return 'jlink' if 'segger.html' in [e .lower () for e in directory_entries ] else 'daplink'
228
230
229
231
230
- def _update_device_details_daplink (self , device , read_details_txt ):
232
+ def _update_device_details_daplink (self , device , read_details_txt , _ ):
231
233
""" Updates the daplink-specific device information based on files from its 'mount_point'
232
234
@param device Dictionary containing device information
233
235
@param read_details_txt A boolean controlling the presense of the
234
236
output dict attributes read from other files present on the 'mount_point'
237
+ @param directory_entries List of directories and files on the device
235
238
"""
236
239
self ._update_device_from_htm (device )
237
240
if read_details_txt :
@@ -247,12 +250,12 @@ def _update_device_details_daplink(self, device, read_details_txt):
247
250
else :
248
251
device ['platform_name' ] = None
249
252
250
- def _update_device_details_jlink (self , device , _ ):
253
+ def _update_device_details_jlink (self , device , _ , directory_entries ):
251
254
""" Updates the jlink-specific device information based on files from its 'mount_point'
252
255
@param device Dictionary containing device information
256
+ @param directory_entries List of directories and files on the device
253
257
"""
254
- files = os .listdir (device ['mount_point' ])
255
- lower_case_map = {f .lower (): f for f in files }
258
+ lower_case_map = {e .lower (): e for e in directory_entries }
256
259
257
260
if 'board.html' in lower_case_map :
258
261
board_file_key = 'board.html'
0 commit comments