df = subprocess.Popen(["df", options.partname], stdout=subprocess.PIPE)
output = df.communicate()[0]
print output
gives the following:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/sys-scratch
1446412616 847216452 524555652 62% /scratch
In some cases (machines),
output.split("\n")[1]
gives me
/dev/mapper/sys-scratch
where as I want
/dev/mapper/sys-scratch 1446412616 847216452 524555652 62% /scratch # in one line
I am using the values in the output like this :
device, size, used, available, percent, mountpoint = output.split("\n")[1].split()
For some machines, this fails because output.split("\n")[1]
only has a single value. How can I fix this ?