Skip to content
Snippets Groups Projects
df.py 816 B
Newer Older
from pcl_expect import controller
from pcl_expect.popen import popen

df = popen("df -k")

x = controller()
while x.loop():
    if x.re(df, "Filesystem.*\n"):
        print "Header:", df.match.group()

x = controller()
while x.loop():
    if x.re(df, "^/.* .*(?=\n)"):
        print "Normal line:", df.match.group()
        x.cont()
        continue
    elif x.re(df, "^/.*(?=\n)"):
        print "Mount point only:", df.match.group()
        x.cont()
        continue
    elif x.re(df, "^ .*(?=\n)"):
        print "Info only:", df.match.group()
        x.cont()
        continue
    elif x.re(df, "^\n"):
        x.cont()
        continue
    elif x.re(df, "^.*(?=\n)"):
        print "Unexpected line", df.match.group()
        x.cont()
        continue
    elif x.eof(df):
        print "And that's all, folks!"