problems with pyzeroconf and linux

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simo Hosio

    #1

    problems with pyzeroconf and linux


    Hi all,
    I am trying to get pyzeroconf (http://sourceforge.net/projects/pyzeroconf)
    running on my machine but having trouble... Running the Zeroconf.py file
    seems to register the service, but is unable to find it.

    (same situation than in
    http://www.nabble.com/pyzeroconf-on-....-t481215.html, but differenet
    cause, I'm sure..)

    """
    Multicast DNS Service Discovery for Python, version 0.12
    1. Testing registration of a service...
    Registering service...
    Registration done.
    2. Testing query of service information...
    Getting ZOE service: None
    Query done.
    3. Testing query of own service...
    Getting self: None
    Query done.
    4. Testing unregister of service information...
    Unregister done.
    """

    Running ethereal reveals that there are no responses to the 2) and
    3)...The queries are certainly there. I'm runnin this with Ubuntu Dapper in
    a WLAN network. I am not too familiar with networking in Linux environment,
    so if anyone has any help on how to get it running, I would appreciate. :)


    Best Regards,
    Simo Hosio
  • Damjan

    #2
    Re: problems with pyzeroconf and linux

    I am trying to get pyzeroconf (http://sourceforge.net/projects/pyzeroconf)
    running on my machine but having trouble... Running the Zeroconf.py file
    seems to register the service, but is unable to find it.
    You should be running avahi.. it also comes python support.

    Here's an example that registers a CNAME that points to your hostname (that
    avahi itself publishes)

    #! /usr/bin/env python
    import avahi, dbus
    from encodings.idna import ToASCII

    # Got these from /usr/include/avahi-common/defs.h
    CLASS_IN = 0x01
    TYPE_CNAME = 0x05

    TTL = 60

    def publish_cname(c name):
    bus = dbus.SystemBus( )
    server = dbus.Interface( bus.get_object( avahi.DBUS_NAME ,
    avahi.DBUS_PATH _SERVER),
    avahi.DBUS_INTE RFACE_SERVER)
    group = dbus.Interface( bus.get_object( avahi.DBUS_NAME ,
    server.EntryGro upNew()),
    avahi.DBUS_INTE RFACE_ENTRY_GRO UP)

    rdata = createRR(server .GetHostNameFqd n())
    cname = encode_dns(cnam e)

    group.AddRecord (avahi.IF_UNSPE C, avahi.PROTO_UNS PEC, dbus.UInt32(0),
    cname, CLASS_IN, TYPE_CNAME, TTL, rdata)
    group.Commit()


    def encode_dns(name ):
    out = []
    for part in name.split('.') :
    if len(part) == 0: continue
    out.append(ToAS CII(part))
    return '.'.join(out)

    def createRR(name):
    out = []
    for part in name.split('.') :
    if len(part) == 0: continue
    out.append(chr( len(part)))
    out.append(ToAS CII(part))
    out.append('\0' )
    return ''.join(out)

    if __name__ == '__main__':
    import time, sys, locale
    for each in sys.argv[1:]:
    name = unicode(each, locale.getprefe rredencoding())
    publish_cname(n ame)
    try:
    while 1: time.sleep(60)
    except KeyboardInterru pt:
    print "Exiting"


    --
    damjan

    Comment

    • Simo Hosio

      #3
      Re: problems with pyzeroconf and linux


      On Sat, 27 Jan 2007, Damjan wrote:
      >
      >I am trying to get pyzeroconf (http://sourceforge.net/projects/pyzeroconf)
      >running on my machine but having trouble... Running the Zeroconf.py file
      >seems to register the service, but is unable to find it.
      >
      You should be running avahi.. it also comes python support.
      >
      Here's an example that registers a CNAME that points to your hostname (that
      avahi itself publishes)
      >
      #! /usr/bin/env python
      import avahi, dbus
      from encodings.idna import ToASCII
      >
      # Got these from /usr/include/avahi-common/defs.h
      CLASS_IN = 0x01
      TYPE_CNAME = 0x05
      >
      TTL = 60
      >
      def publish_cname(c name):
      bus = dbus.SystemBus( )
      server = dbus.Interface( bus.get_object( avahi.DBUS_NAME ,
      avahi.DBUS_PATH _SERVER),
      avahi.DBUS_INTE RFACE_SERVER)
      group = dbus.Interface( bus.get_object( avahi.DBUS_NAME ,
      server.EntryGro upNew()),
      avahi.DBUS_INTE RFACE_ENTRY_GRO UP)
      >
      rdata = createRR(server .GetHostNameFqd n())
      cname = encode_dns(cnam e)
      >
      group.AddRecord (avahi.IF_UNSPE C, avahi.PROTO_UNS PEC, dbus.UInt32(0),
      cname, CLASS_IN, TYPE_CNAME, TTL, rdata)
      group.Commit()
      >
      >
      def encode_dns(name ):
      out = []
      for part in name.split('.') :
      if len(part) == 0: continue
      out.append(ToAS CII(part))
      return '.'.join(out)
      >
      def createRR(name):
      out = []
      for part in name.split('.') :
      if len(part) == 0: continue
      out.append(chr( len(part)))
      out.append(ToAS CII(part))
      out.append('\0' )
      return ''.join(out)
      >
      if __name__ == '__main__':
      import time, sys, locale
      for each in sys.argv[1:]:
      name = unicode(each, locale.getprefe rredencoding())
      publish_cname(n ame)
      try:
      while 1: time.sleep(60)
      except KeyboardInterru pt:
      print "Exiting"
      >
      >
      --
      damjan
      Hi,
      I actually tried Avahi also at first, but was having a lot of difficulties
      setting it up to my actual target environment (Maemo platform, based on
      Debian, and used on Nokia 770&N800 devices...).

      Probably this is anyhow an issue of Debian network configuration, so maybe
      I'll ask the lists there also.

      I will later utilize Avahi, if possible, so thanks for the code snippet. :)
      And if anyone knows what might be the propblem with Pyzeroconf and my dear
      Ubuntu, please tell me.

      Br,
      Simo

      Comment

      Working...