azlux / nft-stats

🐾 Get the nftables counters easier to read
https://packages.azlux.fr/
MIT License
14 stars 3 forks source link

Add Support for Python 3.6 #1

Open ossie-git opened 2 years ago

ossie-git commented 2 years ago

If you currently try to run it on Python 3.6, it will fail with the following message:

Traceback (most recent call last):
  File "./nft-stats.py", line 111, in <module>
    main()
  File "./nft-stats.py", line 104, in main
    out = run_command(args)
  File "./nft-stats.py", line 42, in run_command
    nft_run = subprocess.run(command, shell=True, capture_output=True)
  File "/usr/lib64/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'capture_output'

The culprit is this line:

    nft_run = subprocess.run(command, shell=True, capture_output=True)

This is due to Python 3.6 not supporting the option capture_output. The solution is changing it to this instead:

    nft_run = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

This works on Python 3.6 and above from my testing (and should work on 3.5 as well)

azlux commented 2 years ago

Into which world do you have nftables but not at least python3.7 ?

azlux commented 1 day ago

Do you still need this feature ? If not we will close, if yes, you can make a PR.