Details
-
Improvement
-
Resolution: Fixed
-
Major
-
None
-
Community Edition, Professional Edition
-
Ubuntu 20.04 LTS with Python3
Description
The nginx script for linux system on Python3 (default on Ubuntu 20.04) returns several errors regarding the deprecation of some functions / libraries.
On python3, urllib2 is not used in favor of urlib.request
On python3, print "" is not used in favor of print()
To fix this and allow compatibility, adding a "try" for the lib and change the fetch function could allow python2 and python3 requests.
try: |
from urllib.request import urlopen < python3 |
except ImportError:
|
from urllib2 import urlopen < the fall back to python2 |
When using urllib, because of the next part of the code, we need to add '.decode('utf8')'
data = urlopen('http://localhost/nginx-status').read().decode('utf-8') |