27 def find_modules(device_path, bundles_list): |
27 def find_modules(device_path, bundles_list): |
28 """ |
28 """ |
29 Function to extract metadata from the connected device and available bundles and |
29 Function to extract metadata from the connected device and available bundles and |
30 returns this as a list of Module instances representing the modules on the device. |
30 returns this as a list of Module instances representing the modules on the device. |
31 |
31 |
32 @param device_path path to the connected board |
32 @param device_path path to the connected board or a disk backend object |
33 @type str |
33 @type str or circup.DiskBackend |
34 @param bundles_list list of supported bundles |
34 @param bundles_list list of supported bundles |
35 @type list of circup.Bundle |
35 @type list of circup.Bundle |
36 @return list of Module instances describing the current state of the |
36 @return list of Module instances describing the current state of the |
37 modules on the connected device |
37 modules on the connected device |
38 @rtype list of circup.Module |
38 @rtype list of circup.Module |
39 """ |
39 """ |
|
40 if isinstance(device_path, str): |
|
41 backend = circup.DiskBackend(device_path, circup.logger) |
|
42 else: |
|
43 backend = device_path |
40 result = [] |
44 result = [] |
41 try: |
45 try: |
42 device_modules = circup.get_device_versions(device_path) |
46 device_modules = backend.get_device_versions() |
43 bundle_modules = circup.get_bundle_versions(bundles_list) |
47 bundle_modules = circup.get_bundle_versions(bundles_list) |
44 for name, device_metadata in device_modules.items(): |
48 for name, device_metadata in device_modules.items(): |
45 if name in bundle_modules: |
49 if name in bundle_modules: |
46 path = device_metadata["path"] |
50 path = device_metadata["path"] |
47 bundle_metadata = bundle_modules[name] |
51 bundle_metadata = bundle_modules[name] |