Re: [PATCH nft v1] tests: json_echo: fix python3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Sat, May 25, 2019 at 12:14:09AM +0530, Shekhar Sharma wrote:
> This patch converts the 'run-test.py' file to run on both python2 and python3.
> 
> Signed-off-by: Shekhar Sharma <shekhar250198@xxxxxxxxx>
> ---
>  tests/json_echo/run-test.py | 45 +++++++++++++++++++------------------
>  1 file changed, 23 insertions(+), 22 deletions(-)
> 
> diff --git a/tests/json_echo/run-test.py b/tests/json_echo/run-test.py
> index 0132b139..f5c81b7d 100755
> --- a/tests/json_echo/run-test.py
> +++ b/tests/json_echo/run-test.py
> @@ -1,5 +1,7 @@
>  #!/usr/bin/python2

If the script now runs with either python 2 or 3, maybe change the
shebang to just '/usr/bin/python'?

> +from nftables import Nftables
> +from __future__ import print_function
>  import sys
>  import os
>  import json
> @@ -7,14 +9,13 @@ import json
>  TESTS_PATH = os.path.dirname(os.path.abspath(__file__))
>  sys.path.insert(0, os.path.join(TESTS_PATH, '../../py/'))
>  
> -from nftables import Nftables

Are you aware that the import was put here deliberately after the call
to sys.path.insert()? Why did you decide to move the import call?

>  # Change working directory to repository root
>  os.chdir(TESTS_PATH + "/../..")
>  
>  if not os.path.exists('src/.libs/libnftables.so'):
> -    print "The nftables library does not exist. " \
> -          "You need to build the project."
> +    print("The nftables library does not exist. " \
> +          "You need to build the project.")
>      sys.exit(1)

Drop the backslash here?

Cheers, Phil



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux