Skip to content
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

python 3.5 #2

Closed
turboc1208 opened this issue Apr 19, 2019 · 7 comments
Closed

python 3.5 #2

turboc1208 opened this issue Apr 19, 2019 · 7 comments
Labels

Comments

@turboc1208
Copy link

Errors under Python3.5.3 when trying to run the example on the GIT README

Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.

from nut2 import PyNUTClient
client = PyNUTClient()
client.help()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.5/dist-packages/nut2.py", line 425, in help
self._srv_handler.write("HELP\n")
File "/usr/lib/python3.5/telnetlib.py", line 287, in write
if IAC in buffer:
TypeError: 'in ' requires string as left operand, not bytes
client.list_ups()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.5/dist-packages/nut2.py", line 133, in list_ups
self._srv_handler.write("LIST UPS\n")
File "/usr/lib/python3.5/telnetlib.py", line 287, in write
if IAC in buffer:
TypeError: 'in ' requires string as left operand, not bytes

rshipp added a commit that referenced this issue Apr 19, 2019
@rshipp
Copy link
Owner

rshipp commented Apr 19, 2019

Thanks for the issue! I don't have access to NUT+UPSs right now, but I think I have a solution for this anyway. I've published version 2.1.1 to PyPI, could you install it and let me know if it works for you?

@rshipp rshipp added the bug label Apr 19, 2019
@turboc1208
Copy link
Author

turboc1208 commented Apr 20, 2019 via email

@rshipp
Copy link
Owner

rshipp commented Apr 20, 2019

Make sure you're using parentheses after the PyNUTClient to instantiate the object:

client = PyNUTClient()

@turboc1208
Copy link
Author

turboc1208 commented Apr 20, 2019 via email

@rshipp
Copy link
Owner

rshipp commented Apr 20, 2019

Awesome, if that works I'll close this issue. Let me know if you run into anything else. :)

@rshipp rshipp closed this as completed Apr 20, 2019
@turboc1208
Copy link
Author

turboc1208 commented Apr 20, 2019 via email

@rshipp
Copy link
Owner

rshipp commented Apr 20, 2019

I'm not sure, I know you can configure NUT to alert on certain things (going on battery, low battery, etc) and take actions on a server, but I don't know if that is just polling battery.status behind the scenes or what. You'll have better luck going through the NUT docs as I'm not that familiar with anything beyond polling the UPS variables - this seems relevant https://networkupstools.org/docs/user-manual.chunked/ar01s06.html#UPS_shutdown, but I don't know what those events it's mentioning are. Maybe you can figure something out with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants