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

Fix TypeError: a bytes-like object is required, not 'str' #37

Merged
merged 1 commit into from
Oct 21, 2021
Merged

Fix TypeError: a bytes-like object is required, not 'str' #37

merged 1 commit into from
Oct 21, 2021

Conversation

Vatson112
Copy link
Contributor

Using add_host_supersede raise traceback with Type Error.

Traceback (most recent call last):
  File "manage_dhcp.py", line 99, in <module>
    main(sys.argv)
  File "manage_dhcp.py", line 92, in main
    add_soft_lease(omapi, lease)
  File "manage_dhcp.py", line 65, in add_soft_lease
    omapi.add_host_supersede(str(host['IPAddress']), str(host['ClientID']).replace('-', ':'), str(host['HostName']))
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 1326, in add_host_supersede
    response = self.query_server(msg)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 1053, in query_server
    self.send_message(message)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 1044, in send_message
    self.protocol.send_message(message, sign)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 944, in send_message
    message.sign(self.authenticators[self.defauth])
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 466, in sign
    self.signature = authenticator.sign(self.as_string(forsigning=True))
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 457, in as_string
    self.serialize(ret, forsigning)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 443, in serialize
    outbuffer.add_bindict(self.obj)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 212, in add_bindict
    self.add_net16string(key).add_net32string(value)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 183, in add_net32string
    return self.add_net32int(len(string)).add(string)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 145, in add
    self.buff.write(data)
TypeError: a bytes-like object is required, not 'str'

Using add_host_supersede raise traceback with Type Error.


Traceback (most recent call last):
  File "manage_dhcp.py", line 99, in <module>
    main(sys.argv)
  File "manage_dhcp.py", line 92, in main
    add_soft_lease(omapi, lease)
  File "manage_dhcp.py", line 65, in add_soft_lease
    omapi.add_host_supersede(str(host['IPAddress']), str(host['ClientID']).replace('-', ':'), str(host['HostName']))
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 1326, in add_host_supersede
    response = self.query_server(msg)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 1053, in query_server
    self.send_message(message)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 1044, in send_message
    self.protocol.send_message(message, sign)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 944, in send_message
    message.sign(self.authenticators[self.defauth])
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 466, in sign
    self.signature = authenticator.sign(self.as_string(forsigning=True))
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 457, in as_string
    self.serialize(ret, forsigning)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 443, in serialize
    outbuffer.add_bindict(self.obj)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 212, in add_bindict
    self.add_net16string(key).add_net32string(value)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 183, in add_net32string
    return self.add_net32int(len(string)).add(string)
  File "/home/mn.albeschenko/Yandex.Disk/Work/Projects/dhcp-manage/venv/lib/python3.6/site-packages/pypureomapi.py", line 145, in add
    self.buff.write(data)
TypeError: a bytes-like object is required, not 'str'
```
@cygnusb cygnusb merged commit 03b27e9 into CygnusNetworks:master Oct 21, 2021
@cygnusb
Copy link
Contributor

cygnusb commented Oct 21, 2021

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants