New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make plugin compatible with python3 #13

Closed
Napsty opened this Issue Jun 10, 2015 · 8 comments

Comments

Projects
None yet
2 participants
@Napsty
Owner

Napsty commented Jun 10, 2015

On Ubuntu 14.04 LTS with python 3.4 the following error is thrown:

  File "./check_esxi_hardware.py3", line 440
    print "%s %s" % (time.strftime("%Y%m%d %H:%M:%S"), message)
            ^
SyntaxError: invalid syntax

@Napsty Napsty added the enhancement label Jul 27, 2015

@Napsty Napsty added the wontfix label Mar 21, 2016

@Napsty

This comment has been minimized.

Show comment
Hide comment
@Napsty

Napsty Mar 21, 2016

Owner

As check_esxi_hardware heavily relies on pywbem and pywbem currently ONLY runs with python 2.7, this is closed as wontfix. I know the pywbem team works on making the module working with Python 3, too (https://github.com/deejross/python3-pywbem) but as long as Python 3 is not officially working, it doesn't make sense yet to rewrite the plugin.

Owner

Napsty commented Mar 21, 2016

As check_esxi_hardware heavily relies on pywbem and pywbem currently ONLY runs with python 2.7, this is closed as wontfix. I know the pywbem team works on making the module working with Python 3, too (https://github.com/deejross/python3-pywbem) but as long as Python 3 is not officially working, it doesn't make sense yet to rewrite the plugin.

@Napsty Napsty closed this Mar 21, 2016

@sbraz

This comment has been minimized.

Show comment
Hide comment
@sbraz

sbraz Dec 23, 2016

It looks like pywebm now supports Python 3 :) I guess you could re-open this.

sbraz commented Dec 23, 2016

It looks like pywebm now supports Python 3 :) I guess you could re-open this.

@Napsty

This comment has been minimized.

Show comment
Hide comment
@Napsty

Napsty Dec 24, 2016

Owner

Yep! You're right. Your wish is granted. Merry Xmas :)

Owner

Napsty commented Dec 24, 2016

Yep! You're right. Your wish is granted. Merry Xmas :)

@Napsty Napsty reopened this Dec 24, 2016

@Napsty Napsty removed the wontfix label Feb 20, 2017

@Napsty Napsty self-assigned this Oct 1, 2018

@Napsty

This comment has been minimized.

Show comment
Hide comment
@Napsty

Napsty Oct 1, 2018

Owner

The plugin now supports python3 with tested downward-compatibility for python2:

$ time python2.7 check_esxi_hardware.py -H esxhost -U root -P secret -V ibm 
OK - Server: IBM IBM System x3550 M4: -[7914FT1]- s/n: XXXXXX System BIOS: -[D7E158DUS-2.40]- 2017-04-10

real	0m5.249s
user	0m0.972s
sys	0m0.052s


$ time python3 check_esxi_hardware.py -H esxhost -U root -P secret -V ibm 
OK - Server: IBM IBM System x3550 M4: -[7914FT1]- s/n: XXXXXX System BIOS: -[D7E158DUS-2.40]- 2017-04-10

real	0m5.340s
user	0m1.016s
sys	0m0.032s

Branch is "python3".
@sbraz would you mind a minute to test it on your systems, too?
https://raw.githubusercontent.com/Napsty/check_esxi_hardware/python3/check_esxi_hardware.py
Make sure you have pywbem installed for python3, too. (pip3 install pywbem)

Owner

Napsty commented Oct 1, 2018

The plugin now supports python3 with tested downward-compatibility for python2:

$ time python2.7 check_esxi_hardware.py -H esxhost -U root -P secret -V ibm 
OK - Server: IBM IBM System x3550 M4: -[7914FT1]- s/n: XXXXXX System BIOS: -[D7E158DUS-2.40]- 2017-04-10

real	0m5.249s
user	0m0.972s
sys	0m0.052s


$ time python3 check_esxi_hardware.py -H esxhost -U root -P secret -V ibm 
OK - Server: IBM IBM System x3550 M4: -[7914FT1]- s/n: XXXXXX System BIOS: -[D7E158DUS-2.40]- 2017-04-10

real	0m5.340s
user	0m1.016s
sys	0m0.032s

Branch is "python3".
@sbraz would you mind a minute to test it on your systems, too?
https://raw.githubusercontent.com/Napsty/check_esxi_hardware/python3/check_esxi_hardware.py
Make sure you have pywbem installed for python3, too. (pip3 install pywbem)

@sbraz

This comment has been minimized.

Show comment
Hide comment
@sbraz

sbraz Oct 1, 2018

Works with both Pythons but you need to add from __future__ import print_function, otherwise calls to print with more than one argument will display a tuple:

$ python2 ./check_esxi_hardware.py …
('20181001 11:31:37', 'Found pywbem version 0.7.0')

$ python3 -c "print(1, 2)"
1 2

$ python2 -c "print(1, 2)"
(1, 2)

$ python2 -c "from __future__ import print_function; print(1, 2)"                                                                                                                          
1 2

sbraz commented Oct 1, 2018

Works with both Pythons but you need to add from __future__ import print_function, otherwise calls to print with more than one argument will display a tuple:

$ python2 ./check_esxi_hardware.py …
('20181001 11:31:37', 'Found pywbem version 0.7.0')

$ python3 -c "print(1, 2)"
1 2

$ python2 -c "print(1, 2)"
(1, 2)

$ python2 -c "from __future__ import print_function; print(1, 2)"                                                                                                                          
1 2
@Napsty

This comment has been minimized.

Show comment
Hide comment
@Napsty

Napsty Oct 1, 2018

Owner

Thanks, good hint. Added in commit 6aebd1a.

Owner

Napsty commented Oct 1, 2018

Thanks, good hint. Added in commit 6aebd1a.

@Napsty

This comment has been minimized.

Show comment
Hide comment
@Napsty

Napsty Oct 2, 2018

Owner

python3, here we come! Closing this :)

Owner

Napsty commented Oct 2, 2018

python3, here we come! Closing this :)

@Napsty Napsty closed this Oct 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment