def any_changed_state(state, *args): from comitup.states import dns_names from comitup import mdns interesting_states = PASS_STATES + FAIL_STATES if state in interesting_states: mdns.clear_entries() mdns.add_hosts(dns_names)
def hotspot_pass(): log.debug("Activating mdns") # IP tolerance for PI 2 for _ in range(5): log.debug("states: Calling nm.get_active_ip()") ip = nm.get_active_ip(modemgr.get_state_device('HOTSPOT')) if ip: mdns.clear_entries() mdns.add_hosts(dns_names) break time.sleep(1)
def connected_start(): global conn_list # IP tolerance for PI 2 for _ in range(5): log.debug("states: Calling nm.get_active_ip()") ip = nm.get_active_ip(modemgr.get_state_device('CONNECTED')) if ip: mdns.clear_entries() mdns.add_hosts(dns_names) break time.sleep(1) conn_list = []
def hotspot_start(dummy: int) -> None: global conn_list log.info("Activating hotspot") if startup: mdns.clear_entries() mdns.add_hosts(dns_names) hs_ssid: str = dns_to_conn(dns_names[0]) if startup and modemgr.get_mode() == modemgr.SINGLE_MODE: log.debug("Passing on hotspot connection for now") timeout_add(100, fake_hs_pass, state_id) elif hs_ssid != nm.get_active_ssid(modemgr.get_state_device("HOTSPOT")): conn_list = [] log.debug("Activating connection {}".format(hs_ssid)) activate_connection(hs_ssid, "HOTSPOT") else: log.debug("Didn't need to reactivate - already running") # the connect callback won't happen - let's 'pass' manually timeout_add(100, fake_hs_pass, state_id)
def test_avahi_add_hosts(avahi_fxt): mdns.add_hosts(['host1', 'host2']) assert mdns.group.Commit.called
def test_avahi_add_hosts(avahi_fxt): mdns.add_hosts(["host1", "host2"], "1.2.3.4") assert mdns.group.Commit.called
def reset_mdns(): mdns.clear_entries() mdns.add_hosts(dns_names)