X-Git-Url: https://git.ucc.asn.au/?p=progcomp10.git;a=blobdiff_plain;f=src%2Flink%2Fpexpect%2Fexamples%2Fdf.py;fp=src%2Flink%2Fpexpect%2Fexamples%2Fdf.py;h=0000000000000000000000000000000000000000;hp=64bbf93a1b29a9c7090fbb31e9944be877a24324;hb=edf8e5b569e75692d61a44f2c3241fb6410e4fbd;hpb=35ff18a5beda685e59ca898026570d67b7ead333 diff --git a/src/link/pexpect/examples/df.py b/src/link/pexpect/examples/df.py deleted file mode 100755 index 64bbf93..0000000 --- a/src/link/pexpect/examples/df.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python - -"""This collects filesystem capacity info using the 'df' command. Tuples of -filesystem name and percentage are stored in a list. A simple report is -printed. Filesystems over 95% capacity are highlighted. Note that this does not -parse filesystem names after the first space, so names with spaces in them will -be truncated. This will produce ambiguous results for automount filesystems on -Apple OSX. """ - -import pexpect - -child = pexpect.spawn ('df') - -# parse 'df' output into a list. -pattern = "\n(\S+).*?([0-9]+)%" -filesystem_list = [] -for dummy in range (0, 1000): - i = child.expect ([pattern, pexpect.EOF]) - if i == 0: - filesystem_list.append (child.match.groups()) - else: - break - -# Print report -print -for m in filesystem_list: - s = "Filesystem %s is at %s%%" % (m[0], m[1]) - # highlight filesystems over 95% capacity - if int(m[1]) > 95: - s = '! ' + s - else: - s = ' ' + s - print s -