discovery module

class vidhubcontrol.discovery.AddedMessage(info)[source]

Bases: vidhubcontrol.discovery.Message

class vidhubcontrol.discovery.BMDDiscovery(mainloop, service_type='_blackmagic._tcp.local.')[source]

Bases: vidhubcontrol.discovery.Listener

Zeroconf listener for Blackmagic devices

vidhubs

Contains discovered Videohub devices. This DictProperty can be used to subscribe to changes.

Type:dict
smart_views

Contains discovered SmartView devices. This DictProperty can be used to subscribe to changes.

Type:dict
smart_scopes

Contains discovered SmartScope devices. This DictProperty can be used to subscribe to changes.

Type:dict
class vidhubcontrol.discovery.Listener(mainloop, service_type)[source]

Bases: pydispatch.dispatch.Dispatcher

An async zeroconf service listener

Allows async communication with zeroconf.Zeroconf through asyncio.AbstractEventLoop.run_in_executor() calls.

Parameters:
  • mainloop (asyncio.BaseEventLoop) – asyncio event loop instance
  • service_type (str) – The fully qualified service type name to subscribe to
services

All services currently discovered as instances of ServiceInfo. Stored using ServiceInfo.id as keys

Type:dict
message_queue

Used to communicate actions and events with instances of Message

Type:asyncio.Queue
published_services

Stores services that have been published using publish_service() as ServiceInfo instances.

Type:dict
coroutine add_message(msg)[source]

Adds a message to the message_queue

Parameters:msg (Message) – Message to send
coroutine publish_service(type_, port, name=None, addresses=None, properties=None, ttl=60)[source]

Publishes a service on the network

Parameters:
  • type (str) – Fully qualified service type
  • port (int) – The service port
  • name (str, optional) – Fully qualified service name. If not provided, this will be generated from the type_ and the hostname detected by get_local_hostname()
  • addresses (optional) – If provided, an iterable of IP addresses to publish. Can be ipaddress.IPv4Address or any type that can be parsed by ipaddress.ip_address()
  • properties (dict, optional) – Custom properties for the service
  • ttl (int, optional) – The TTL value to publish. Defaults to PUBLISH_TTL
coroutine run()[source]

Main loop for communicating with zeroconf.Zeroconf

Waits for messages on the message_queue and processes them. The loop will exit if an object placed on the queue is not an instance of Message.

When the loop exits, the zeroconf.Zeroconf instance will be closed.

run_zeroconf()[source]

Starts zeroconf.Zeroconf and zeroconf.ServiceBrowser instances

This is meant to be called inside of an concurrent.futures.Executor and not used directly.

coroutine start()[source]

Starts the service listener

Runs zeroconf.Zeroconf in an Executor instance through asyncio.AbstractEventLoop.run_in_executor (see run_zeroconf()).

coroutine stop()[source]

Stops the loop in run()

stop_zeroconf()[source]

Closes the zeroconf.Zeroconf instance

This is meant to be called inside of an concurrent.futures.Executor and not used directly.

coroutine unpublish_service(type_, port, name=None, addresses=None, properties=None)[source]

Removes a service published through publish_service()

Parameters:
  • type (str) – Fully qualified service type
  • port (int) – The service port
  • name (str, optional) – Fully qualified service name. If not provided, this will be generated from the type_ and the hostname detected by get_local_hostname()
  • addresses (optional) – If provided, an iterable of IP addresses to unpublish. Can be ipaddress.IPv4Address or any type that can be parsed by ipaddress.ip_address()
  • properties (dict, optional) – Custom properties for the service
class vidhubcontrol.discovery.Message(info)[source]

Bases: object

A message to communicate actions to and from Listener

info

The ServiceInfo related to the message

Note

This class and its subclasses are not meant to be used directly. They are used internally in Listener methods.

class vidhubcontrol.discovery.PublishMessage(info, ttl=60)[source]

Bases: vidhubcontrol.discovery.Message

class vidhubcontrol.discovery.RemovedMessage(info)[source]

Bases: vidhubcontrol.discovery.Message

class vidhubcontrol.discovery.ServiceInfo(**kwargs)[source]

Bases: pydispatch.dispatch.Dispatcher

Container for Zeroconf service information

Closely related to zeroconf.ServiceInfo

type

Fully qualified service type

Type:str
name

Fully qualified service name

Type:str
server

Fully qualified name for service host (defaults to name)

Type:str
address

The service ip address

Type:ipaddress.IPv4Address
port

The service port

Type:int
properties

Custom properties for the service

Type:dict
classmethod from_zc_info(info)[source]

Creates an instance from a zeroconf.ServiceInfo object

Parameters:info (zeroconf.ServiceInfo) –
Returns:An instance of ServiceInfo
id

Unique id for the service as a tuple of (type, name)

to_zc_info()[source]

Creates a copy as an instance of zeroconf.ServiceInfo

update(other)[source]

Updates the properties from another ServiceInfo instance

class vidhubcontrol.discovery.UnPublishMessage(info)[source]

Bases: vidhubcontrol.discovery.Message