[devices]: Fix unit test script in order to run stretch python 3.5.3 (#9030)
It is required by stretch/sonic-device-data_1.0-1_all.deb, which is required by docker-sonic-mgmt.gz. Stretch distribution has old Python 3.5.3. scandir.close() is new in Python version 3.6. ref: https://docs.python.org/3/library/os.html#os.scandir.close
This commit is contained in:
parent
c1d5e0682f
commit
12b8cacaa8
@ -29,11 +29,16 @@ def main(argv):
|
||||
|
||||
# Load all the valid platforms as strings
|
||||
platforms = set()
|
||||
with os.scandir(args.platform_folder) as it:
|
||||
it = os.scandir(args.platform_folder)
|
||||
try:
|
||||
for entry in it:
|
||||
p = entry.path
|
||||
if entry.is_dir() and os.path.isfile(os.path.join(p, 'rules.mk')):
|
||||
platforms.add(entry.name)
|
||||
finally:
|
||||
# os.scandir().close() is only available in python 3.6 and later
|
||||
if callable(getattr(it, "close", None)):
|
||||
it.close()
|
||||
# dnx platform is special broadcom platform, add it manually
|
||||
platforms.add('broadcom-dnx')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user