zabbix-tools / zabbix-template-converter

Migrate Zabbix templates between versions
MIT License
45 stars 30 forks source link

Not compatible with python 3.6.8 #14

Open brenocrs opened 2 years ago

brenocrs commented 2 years ago

Symptom

After the instalation process

[11:56:43] nsvcadm@DESKTOP-ABF8GII:2.BEEGOL_V4 $ pip3 install zabbix-template-converter
Defaulting to user installation because normal site-packages is not writeable
Collecting zabbix-template-converter
  Downloading zabbix-template-converter-1.1.0.tar.gz (5.1 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: zabbix-template-converter
  Building wheel for zabbix-template-converter (setup.py) ... done
  Created wheel for zabbix-template-converter: filename=zabbix_template_converter-1.1.0-py3-none-any.whl size=5396 sha256=9906875d1bb749e17cb598cacbc901014f34c8ee2bdca3319218f95c3d6b838f
  Stored in directory: /home/nsvcadm/.cache/pip/wheels/03/5c/a8/589ab4c1562f49e5265ed7c9de614c8b6f17d33690c17ecb55
Successfully built zabbix-template-converter
Installing collected packages: zabbix-template-converter
Successfully installed zabbix-template-converter-1.1.0

Is not possible to execute any command from the script since it has an sintax error.

[11:56:51] nsvcadm@DESKTOP-ABF8GII:2.BEEGOL_V4 $ zabbix-template-converter -h
  File "/home/nsvcadm/.local/bin/zabbix-template-converter", line 339
    print '<?xml version="1.0" encoding="UTF-8"?>'
                                                 ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('<?xml version="1.0" encoding="UTF-8"?>')?

Possible problems:

Related

7

Environment:

OS:

[11:47:09] nsvcadm@DESKTOP-ABF8GII:2.BEEGOL_V4 $ cat /etc/*release*
Oracle Linux Server release 8.5
NAME="Oracle Linux Server"
VERSION="8.5"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="8.5"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Oracle Linux Server 8.5"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:8:5:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"

ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
ORACLE_BUGZILLA_PRODUCT_VERSION=8.5
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=8.5
Red Hat Enterprise Linux release 8.5 (Ootpa)
Oracle Linux Server release 8.5
cpe:/o:oracle:linux:8:5:server
[11:47:27] nsvcadm@DESKTOP-ABF8GII:2.BEEGOL_V4 $ uname -a
Linux DESKTOP-ABF8GII 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Python3 version:

[11:47:41] nsvcadm@DESKTOP-ABF8GII:2.BEEGOL_V4 $ python3
Python 3.6.8 (default, Nov 10 2021, 06:50:23)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3.0.2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version
'3.6.8 (default, Nov 10 2021, 06:50:23) \n[GCC 8.5.0 20210514 (Red Hat 8.5.0-3.0.2)]'
>>> quit()
[11:52:31] nsvcadm@DESKTOP-ABF8GII:2.BEEGOL_V4 $ pip3 --version
pip 21.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

Installed Python packages/modules

[11:52:43] nsvcadm@DESKTOP-ABF8GII:2.BEEGOL_V4 $ pip3 list
Package              Version
-------------------- -------
ansible              2.9.4
argon2-cffi          21.3.0
argon2-cffi-bindings 21.2.0
async-generator      1.10
attrs                21.4.0
backcall             0.1.0
bleach               4.1.0
cffi                 1.15.0
cryptography         36.0.1
dataclasses          0.8
dbus-python          1.2.4
decorator            4.2.1
defusedxml           0.7.1
entrypoints          0.4
gpg                  1.13.1
importlib-metadata   4.8.3
iniconfig            1.1.1
ipykernel            5.5.6
ipython              7.16.1
ipython-genutils     0.2.0
ipywidgets           7.6.5
isc                  2.0
jedi                 0.15.1
Jinja2               3.0.3
jsonschema           3.2.0
jupyter              1.0.0
jupyter-client       7.1.2
jupyter-console      6.4.0
jupyter-core         4.9.1
jupyterlab-pygments  0.1.2
jupyterlab-widgets   1.0.2
libcomps             0.1.16
MarkupSafe           2.0.1
mistune              0.8.4
nbclient             0.5.9
nbconvert            6.0.7
nbformat             5.1.3
nest-asyncio         1.5.4
notebook             6.4.8
packaging            21.3
pandocfilters        1.5.0
parso                0.5.1
pexpect              4.3.1
pickleshare          0.7.5
pip                  21.3.1
pluggy               1.0.0
ply                  3.9
prometheus-client    0.13.1
prompt-toolkit       3.0.5
ptyprocess           0.5.2
py                   1.11.0
pycparser            2.21
Pygments             2.11.2
pyparsing            3.0.7
pyrsistent           0.18.0
pytest               7.0.1
python-dateutil      2.6.1
PyYAML               6.0
pyzmq                22.3.0
qtconsole            5.2.2
QtPy                 2.0.1
rpm                  4.14.3
Send2Trash           1.8.0
setuptools           39.2.0
six                  1.11.0
terminado            0.12.1
testpath             0.5.0
tomli                1.2.3
tornado              6.1
traitlets            4.3.3
typing_extensions    4.0.1
wcwidth              0.2.5
webencodings         0.5.1
wheel                0.37.1
widgetsnbextension   3.5.2
zipp                 3.6.0
dlyserg commented 1 year ago

pip 20.3.4 for python 3.8 line 339 change to:

print('<?xml version="1.0" encoding="UTF-8"?>')

Traceback (most recent call last):
  File "/usr/local/sbin/zabbix-template-converter", line 343, in <module>
    __main__()
  File "/usr/local/sbin/zabbix-template-converter", line 317, in __main__
    type=file)
NameError: name 'file' is not defined

file() is not supported in Python 3

line line 317 change to:

type=argparse.FileType('r'))

but:

  File "/usr/local/sbin/zabbix-template-converter", line 345, in <module>
    __main__()
  File "/usr/local/sbin/zabbix-template-converter", line 335, in __main__
    rule.apply()
  File "/usr/local/sbin/zabbix-template-converter", line 75, in apply
    if self.versioncmp('3') < 0:
  File "/usr/local/sbin/zabbix-template-converter", line 61, in versioncmp
    return cmp(V(self.version), V(version))
NameError: name 'cmp' is not defined

cmp function exists only in Python 2. It was deprecated in Python 3.