Dear Stephen, You agree this pacth, it means I don't need modify it and commit again? liwencheng@phytium.com.cn From: Stephen Hemminger Date: 2024-11-06 11:55 To: liwencheng CC: dev Subject: Re: [PATCH v1 2/2] /usertools/dpdk-devbind:add the binding and unbinding of platform device On Fri, 1 Nov 2024 10:07:20 +0000 liwencheng wrote: > +def unbind_platform_one(dev_name): > + filename = "/sys/bus/platform/devices/%s/driver" % dev_name > + > + if exists(filename): > + try: > + f = open(os.path.join(filename, "unbind"), "w") > + except OSError as err: > + sys.exit("Error: unbind failed for %s - Cannot open %s: %s" % > + (dev_name, os.path.join(filename, "unbind"), err)) > + f.write(dev_name) > + f.close() > + filename = "/sys/bus/platform/devices/%s/driver_override" % dev_name > + try: > + f = open(filename, "w") > + except OSError as err: > + sys.exit("Error: unbind failed for %s - Cannot open %s: %s" % > + (dev_name, filename, err)) > + f.write("") > + f.close() > + print("Successfully unbind platform device %s" % dev_name) > + > + Looks fine, but probably worth the effort in the future to update to current Python style guidelines. Applies to all of devbind. Acked-by: Stephen Hemminger ************* Module dpdk-devbind usertools/dpdk-devbind.py:1:0: C0114: Missing module docstring (missing-module-docstring) usertools/dpdk-devbind.py:1:0: C0103: Module name "dpdk-devbind" doesn't conform to snake_case naming style (invalid-name) usertools/dpdk-devbind.py:104:0: C0103: Constant name "loaded_modules" doesn't conform to UPPER_CASE naming style (invalid-name) usertools/dpdk-devbind.py:107:0: C0103: Constant name "b_flag" doesn't conform to UPPER_CASE naming style (invalid-name) usertools/dpdk-devbind.py:108:0: C0103: Constant name "status_flag" doesn't conform to UPPER_CASE naming style (invalid-name) usertools/dpdk-devbind.py:109:0: C0103: Constant name "force_flag" doesn't conform to UPPER_CASE naming style (invalid-name) usertools/dpdk-devbind.py:110:0: C0103: Constant name "noiommu_flag" doesn't conform to UPPER_CASE naming style (invalid-name) usertools/dpdk-devbind.py:115:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:116:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:142:17: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:150:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:151:4: W0601: Global variable 'platform_devices' undefined at the module level (global-variable-undefined) usertools/dpdk-devbind.py:157:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:171:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:212:33: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:226:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:234:4: W0602: Using global for 'devices' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:235:4: W0602: Using global for 'dpdk_drivers' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:246:31: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:248:31: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:278:4: C0206: Consider iterating with .items() (consider-using-dict-items) usertools/dpdk-devbind.py:278:13: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:299:51: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:230:0: R0912: Too many branches (21/12) (too-many-branches) usertools/dpdk-devbind.py:311:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:312:4: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate) usertools/dpdk-devbind.py:312:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks) usertools/dpdk-devbind.py:343:4: C0206: Consider iterating with .items() (consider-using-dict-items) usertools/dpdk-devbind.py:343:13: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:352:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:356:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:357:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:361:16: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:363:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:367:19: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:361:16: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:369:16: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:371:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:375:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:369:16: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:382:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:388:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:393:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:395:12: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:397:17: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:395:12: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:403:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:404:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:407:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:410:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:414:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:417:16: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:419:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:425:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:428:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:417:16: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:430:12: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:432:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:439:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:442:10: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:430:12: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:453:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:460:18: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:474:19: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:477:20: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:479:22: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:483:24: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:486:22: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:491:23: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:493:20: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:495:22: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:500:24: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:504:22: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:509:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:493:20: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:511:12: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:513:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:528:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:537:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:511:12: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:540:16: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:542:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:548:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:445:0: R0911: Too many return statements (9/6) (too-many-return-statements) usertools/dpdk-devbind.py:445:0: R0912: Too many branches (18/12) (too-many-branches) usertools/dpdk-devbind.py:445:0: R0915: Too many statements (61/50) (too-many-statements) usertools/dpdk-devbind.py:540:16: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:556:8: C0206: Consider iterating with .items() (consider-using-dict-items) usertools/dpdk-devbind.py:556:17: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:582:4: W0602: Using global for 'noiommu_flag' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:586:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:596:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:605:4: W0602: Using global for 'devices' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:614:17: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:622:17: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:644:18: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:644:62: W0631: Using possibly undefined loop variable 'd' (undefined-loop-variable) usertools/dpdk-devbind.py:645:8: C0206: Consider iterating with .items() (consider-using-dict-items) usertools/dpdk-devbind.py:645:17: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:665:10: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:672:31: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:677:31: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:683:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:684:4: W0602: Using global for 'dpdk_drivers' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:690:4: C0206: Consider iterating with .items() (consider-using-dict-items) usertools/dpdk-devbind.py:690:13: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:704:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:712:24: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:718:24: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:722:24: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:731:7: E0606: Possibly using variable 'status_dev' before assignment (possibly-used-before-assignment) usertools/dpdk-devbind.py:777:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:778:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:779:4: W0601: Global variable 'status_dev' undefined at the module level (global-variable-undefined) usertools/dpdk-devbind.py:780:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:781:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:782:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:887:4: W0602: Using global for 'b_flag' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:888:4: W0602: Using global for 'status_flag' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:889:4: W0602: Using global for 'force_flag' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:890:4: W0602: Using global for 'args' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:916:9: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) ------------------------------------------------------------------ Your code has been rated at 7.69/10 (previous run: 7.69/10, +0.00)