#!/usr/bin/env python3

""" Example of resolving a service with a known name """

import logging
import sys

from zeroconf import Zeroconf

TYPE = '_test._tcp.local.'
NAME = 'My Service Name'

if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    if len(sys.argv) > 1:
        assert sys.argv[1:] == ['--debug']
        logging.getLogger('zeroconf').setLevel(logging.DEBUG)

    zeroconf = Zeroconf()

    try:
        print(zeroconf.get_service_info(TYPE, NAME + '.' + TYPE))
    finally:
        zeroconf.close()

Add an example of resolving a known service by service name
examples: Add an example of resolving a known service by service name

To use:
* `avahi-publish-service -s 'My Service Name' _test._tcp 0`
* `./examples/resolver.py` should print a `ServiceInfo`
* Kill the `avahi-publish-service` process
* `./examples/resolver.py` should print `None`

Signed-off-by: Simon McVittie <0e1aea601907c1a85c2dc96e5ea37e23c58d2e9b@collabora.com>
