Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def update():
- """ Updating state to host """
- longest_ip = 0
- longest_desc = 0
- for hosts in HOSTS_ARR:
- if len(hosts[0]) > longest_ip:
- longest_ip = len(hosts[0])
- if len(hosts[1]) > longest_desc:
- longest_desc = len(hosts[1])
- while True:
- if TEMP_HOSTS_ARR != HOSTS_ARR:
- pre_string = '{0:<' + str(longest_desc) + 's} | {1:' + str(longest_ip) + 's} | {2:15s}'
- print(pre_string.format('DESC.', 'IP', 'STATE'))
- pre_string = '{0:-^' + str(longest_desc + longest_ip + 18) + 's}'
- print(pre_string.format(''))
- for hosts in HOSTS_ARR:
- pre_string = '{0:<' + str(longest_desc) + 's} | {1:' + str(longest_ip) + 's} | {2:15s}'
- print(pre_string.format(hosts[1], hosts[0], hosts[2]))
- TEMP_HOSTS_ARR = HOSTS_ARR
- for update_hosts in HOSTS_ARR:
- _thread.start_new_thread(ping, (str(update_hosts[0]), str(update_hosts[1],)))
- time.sleep(5)
- subprocess.call('clear')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement