bareos / python-bareos

Python libraries to access Bareos
7 stars 10 forks source link

fix TypeError: a bytes-like object is required, not 'str' #12

Closed sergeymazin closed 6 years ago

sergeymazin commented 6 years ago

Fixes issue when in python3 user gets following error trying to connect to Director service:

>>> import bareos.bsock
>>> password=bareos.bsock.Password(pwd)
>>> directorconsole=bareos.bsock.DirectorConsoleJson(address=host, port=9101, password=password)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/sergey/PycharmProjects/python-bareos-source/bareos/bsock/directorconsolejson.py", line 15, in __init__
    super(DirectorConsoleJson, self).__init__(*args, **kwargs)
  File "/Users/sergey/PycharmProjects/python-bareos-source/bareos/bsock/directorconsole.py", line 19, in __init__
    self.auth(name=name, password=password, auth_success_regex=b'^1000 OK.*$')
  File "/Users/sergey/PycharmProjects/python-bareos-source/bareos/bsock/lowlevel.py", line 77, in auth
    return self.__auth()
  File "/Users/sergey/PycharmProjects/python-bareos-source/bareos/bsock/lowlevel.py", line 90, in __auth
    self.recv_msg(self.auth_success_regex)
  File "/Users/sergey/PycharmProjects/python-bareos-source/bareos/bsock/lowlevel.py", line 202, in recv_msg
    lastlineindex = self.receive_buffer.rfind('\n') + 1
TypeError: a bytes-like object is required, not 'str'
joergsteffens commented 6 years ago

Thank you for your patches. As more and more people are using Python3 I'm sure it will be valued.