def main(): global args parser = argparse.ArgumentParser( "Check availability of devices on the network") parser.add_argument('--siri', action="store_true") args = parser.parse_args() data = LoadConfig() if not args.siri: print(data) if not data: return if data == "retry": main() devices = [] for d in data.get('devices', []): device = Device(d) devices.extend(device.GetAllDevices()) if not args.siri: print() TestDevices(devices) if not args.siri: print() if not args.siri: for device in devices: if not device.parent: device.PrintResults() print() if args.siri: offline = [] for device in devices: offline += device.GetAllOffline() offline = list(set(offline)) output = "Okay. " if offline: output += ', '.join(offline) if len(offline) > 1: index = output.rfind(',') output = output[:index + 1] + " and" + output[index + 1:] output += " are not responding" else: output += " is not responding" else: output += random.choice(good_responses) print(output)