Revision 05f679d0
Added by David Sorber about 8 years ago
| software/misc/display.py | ||
|---|---|---|
|
def get_ipv4_addr(interface):
|
||
|
cmd = 'ifconfig {:s}'.format(interface)
|
||
|
for line in subprocess.check_output(cmd, shell=True).split('\n'):
|
||
|
if line.strip().startswith('inet addr:'):
|
||
|
return line.split()[1][5:]
|
||
|
if line.strip().startswith('inet '):
|
||
|
return line.split()[1]
|
||
|
else:
|
||
|
return '{:s}NO IP ASSIGNED{:s}'.format(RED, END)
|
||
|
|
||
| ... | ... | |
|
line_tokens = line.split()
|
||
|
|
||
|
usage_percent = int(line_tokens[4][:-1])
|
||
|
percent_str = '{:s}{:d}%{:s}'.format(BOLD, usage_percent, END)
|
||
|
percent_str = '{:s}{:>3d}%{:s}'.format(BOLD, usage_percent, END)
|
||
|
if usage_percent > 90:
|
||
|
percent_str = '{:s}{:s}{:d}%{:s}'.format(BOLD, RED, usage_percent, END)
|
||
|
percent_str = '{:s}{:s}{:>3d}%{:s}'.format(BOLD, RED, usage_percent, END)
|
||
|
elif usage_percent > 70:
|
||
|
percent_str = '{:s}{:s}{:d}%{:s}'.format(BOLD, YELLOW, usage_percent, END)
|
||
|
percent_str = '{:s}{:s}{:>3d}%{:s}'.format(BOLD, YELLOW, usage_percent, END)
|
||
|
|
||
|
|
||
|
output = '{:10s} ({:<9s}) - {:>4s} of {:>4s} [ {:s} ] used; '\
|
||
Minor updates after upgrading to Ubuntu 18.04.