unixsurfer / haproxyadmin

A python library to interact with HAProxy over UNIX socket
Apache License 2.0
113 stars 31 forks source link

'ConnectionRefusedError' is not defined #12

Closed oovs closed 5 years ago

oovs commented 6 years ago

Throws an exception on Python 2.7.9:

  File "/usr/local/lib/python2.7/dist-packages/haproxyadmin/haproxy.py", line 110, in __init__
    if is_unix_socket(_file) and connected_socket(_file):
  File "/usr/local/lib/python2.7/dist-packages/haproxyadmin/utils.py", line 179, in connected_socket
    except (ConnectionRefusedError, PermissionError, socket.timeout, OSError):
NameError: global name 'ConnectionRefusedError' is not defined

Packages version:

haproxyadmin (0.2.1)
six (1.11.0)
unixsurfer commented 6 years ago

ConnectionRefusedError exception is not available in Python2, only in Python3. Thus you get that error. I guess I have to switch to socket.error exception which is present in both versions of Python.

oovs commented 6 years ago

I've applied the PR #8 locally because I require quick fix and I could say it works fine.

unixsurfer commented 5 years ago

A simpler solution was done by https://github.com/unixsurfer/haproxyadmin/commit/9227df29495e7ba079c5f8ca3f6616e82e91fd81