blob: 0d8c1c06689f432e10e92e65e53921f2ffc826f5 [file] [log] [blame]
from time import sleep
from discoverer import Discoverer
class DevicesCommand:
def __init__(self):
self.discoverer = Discoverer()
def run(self, args):
sleep(1)
print('Devices found:')
discoveries = self.discoverer.discoveries
for host, address in discoveries.items():
print('{0}\t\t({1})'.format(host, address))
class DevicesWaitCommand:
def __init__(self):
self.found_devices = False
self.discoverer = Discoverer(self)
def add_device(self, hostname, address):
self.found_devices = True
self.hostname = hostname
self.address = address
def run(self, args):
print('Waiting for device...')
while not self.found_devices:
sleep(0.1)
print('Device found: {0} ({1})'.format(self.hostname, self.address))