On Thu, 2010-12-30 at 11:16 -0200, Cleber Rosa wrote:
> Instead of running a 'df' external command, simply use python's builtin
> os.statvfs() for fetching the very same information.

Hi Cleber, this command is implemented like this for a reason: We want
to know what is the free space on the client machine, self.run is
implemented on higher level classes as an SSH command. Although it would
be nice, it's not possible to get that data using python, unless we ran
a subcommand such as python "code snippet" there. So I'm going to reject
this particular patch. Thanks!

> Signed-off-by: Cleber Rosa <[email protected]>
> ---
>  client/common_lib/hosts/base_classes.py |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/client/common_lib/hosts/base_classes.py 
> b/client/common_lib/hosts/base_classes.py
> index 0b6ce0c..86c1ea5 100644
> --- a/client/common_lib/hosts/base_classes.py
> +++ b/client/common_lib/hosts/base_classes.py
> @@ -230,8 +230,8 @@ class Host(object):
>      def check_diskspace(self, path, gb):
>          logging.info('Checking for >= %s GB of space under %s on machine %s',
>                       gb, path, self.hostname)
> -        df = self.run('df -mP %s | tail -1' % path).stdout.split()
> -        free_space_gb = int(df[3])/1000.0
> +        statvfs = os.statvfs(path)
> +        free_spage_gb = int((statvfs.f_bavail * statvfs.f_bsize) / 
> 1000000000)
>          if free_space_gb < gb:
>              raise error.AutoservDiskFullHostError(path, gb, free_space_gb)
>          else:


_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to