Re: get output of du / ls command - currently ugly code ...

2009-08-13 Thread Esmail
Albert Hopkins wrote: I don't know about "easier", but a more elegant way is to not use os.popen() and to use Python's functions os.path.getsize (or os.stat) and os.walk (or os.path.walk) to achieve this. In fact if you look at the docstring for os.walk there is an example that almost does what

Re: get output of du / ls command - currently ugly code ...

2009-08-13 Thread Albert Hopkins
On Thu, 2009-08-13 at 15:28 -0400, Esmail wrote: > Hi all, > > Essentially all I want to know the size of a directory, and the size > of a zipped tarball so that I can compute/report the compression ratio. > > The code I have seems hideous, but it seems to work. Surely there is an > easier,more e

Re: get output of du / ls command - currently ugly code ...

2009-08-13 Thread Esmail
re...@yahoo.co.uk wrote: On Aug 13, 8:28 pm, Esmail wrote: Hi all, Essentially all I want to know the size of a directory, and the size of a zipped tarball so that I can compute/report the compression ratio. dir_size = os.popen('du -sk somename') data = dir_size.readlines()

Re: get output of du / ls command - currently ugly code ...

2009-08-13 Thread re...@yahoo.co.uk
On Aug 13, 8:28 pm, Esmail wrote: > Hi all, > > Essentially all I want to know the size of a directory, and the size > of a zipped tarball so that I can compute/report the compression ratio. > > The code I have seems hideous, but it seems to work. Surely there is an > easier,more elegant way to do

get output of du / ls command - currently ugly code ...

2009-08-13 Thread Esmail
Hi all, Essentially all I want to know the size of a directory, and the size of a zipped tarball so that I can compute/report the compression ratio. The code I have seems hideous, but it seems to work. Surely there is an easier,more elegant way to do this? dir_size = os.popen('du -sk somena