-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaido_utils.py
32 lines (25 loc) · 1.11 KB
/
aido_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from typing import List
debugging = True
def get_device_list(input_file):
device_list = []
try:
with open(input_file, 'r') as filestream:
for line in filestream:
hostname = line.rstrip()
if hostname=='':
continue
device_list.append(hostname)
if len(device_list) == 0:
msg = 'Could not find any device in %s' % input_file
raise CouldNotReadDeviceList(msg)
return device_list
except IOError as e:
msg = 'Could not read from %s' % input_file
def show_status(device_list, results):
if debugging:
print('\t {:<4}{:<20}|{:<4}{:<20} '.format('=' * 4, '=' * 20, '=' * 4, '=' * 20))
print('\t|{:<4}{:<20}|{:<4}{:<20}|'.format('', 'Device', '', 'Status'))
print('\t|{:<4}{:<20}|{:<4}{:<20}|'.format('=' * 4, '=' * 20, '=' * 4, '=' * 20))
for (res, device) in zip(results, device_list):
print('\t|{:<4}{:<20}|{:<4}{:<20}|'.format('', device, '', res))
print('\t {:<4}{:<20}|{:<4}{:<20} '.format('=' * 4, '=' * 20, '=' * 4, '=' * 20))