Skip to content

Commit

Permalink
[devices]: Fix unit test script in order to run stretch python 3.5.3 (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
qiluo-msft authored Oct 22, 2021
1 parent c1d5e06 commit 12b8cac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sonic-device-data/tests/platform_asic_checker
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down

0 comments on commit 12b8cac

Please sign in to comment.