Skip to content

Commit

Permalink
MAINTENANCE: Python3 Avahi service publishing compatibility
Browse files Browse the repository at this point in the history
In machinekit#324 it became obvious, that changes in how strings are represented in Python 3 from legacy Python 2 caused that request through DBus to Avahi were rejected. Python Avahi module includes function 'string_array_to_txt_array', which transcodes Python strings into byte arrays.

Only used on the TXT value, as all others seem to be working. (Minimal changes to just get working system.)
  • Loading branch information
cerna committed Oct 18, 2020
1 parent 2524ccd commit 07a6f10
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/python/machinekit/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def publish(self):

# insert fqdn in announcement
fqdn = str(server.GetHostNameFqdn())
text = [t % {'fqdn': fqdn} for t in self.text]
text = avahi.string_array_to_txt_array(
[t % {'fqdn': fqdn} for t in self.text])
name = self.name % {'fqdn': fqdn}

iface = avahi.IF_UNSPEC
Expand Down Expand Up @@ -114,7 +115,8 @@ def __init__(

if name is None:
pid = os.getpid()
self.name = '%s service on %s pid %i' % (self.type.title(), self.host, pid)
self.name = '%s service on %s pid %i' % (
self.type.title(), self.host, pid)

me = uuid.uuid1()
self.status_txtrec = [
Expand Down

0 comments on commit 07a6f10

Please sign in to comment.