Re: How to get the total size of a local hard disk?

2009-06-16 Thread Tim Roberts
willgun  wrote:
>
>Unfortunately,I'm on win32.
>Actually,I prefer a cross-platform method.

Why do you need this?  This kind of information is not very useful in a
cross-platform application.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cross platform method Re: How to get the total size of a local hard disk?

2009-06-16 Thread Nigel Rantor
Tim Harig wrote:
> 
> This is a joke.  Do not take it seriously.  I do not actually suggest
> anybody use this method to measure the size of their drive.  I do not take any
> responsibility for any damages incurred by using this method.  I will laugh
> at you if you do.  Offer not valid in AK, HI, Puero Rico, or U.S Virgin 
> Ilands.
> 

Like most jokes it's not really funny if you have to explain it.

But I appreciate that you're worried that anyone who would actually
follow the advice would also probably be rabidly litigious even if they
were one of those rare-breed of living brain-donors.

  n

-- 
http://mail.python.org/mailman/listinfo/python-list


How to get the total size of a local hard disk?

2009-06-15 Thread willgun
Hi,everyone!

How to get the total size of a local hard disk?
I mean total size,not free space.

Thanks in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


cross platform method Re: How to get the total size of a local hard disk?

2009-06-15 Thread Tim Harig
On 2009-06-15, Tim Golden  wrote:
> These kind of things tend to be fairly platform specific.

There is however a way to do it in a cross platform manner which will
return an appoximation of the available space.

1. delete all of the files (and folders) on the partition that  you want to
test.

2. create a file as large as the drive will permit.

3. repeat two with as many files as the drive will allow to be written.
This needs to be done on filesystems with file size limits (ie,
FAT file systems will only allow files as large as 4G).

4. Once all the files have been written, calculate the total size of all of
the files to get your answer.

This method is a little descructive and slow; but, it should work on
all platforms.


This is a joke.  Do not take it seriously.  I do not actually suggest
anybody use this method to measure the size of their drive.  I do not take any
responsibility for any damages incurred by using this method.  I will laugh
at you if you do.  Offer not valid in AK, HI, Puero Rico, or U.S Virgin Ilands.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the total size of a local hard disk?

2009-06-15 Thread willgun

Unfortunately,I'm on win32.
Actually,I prefer a cross-platform method.
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the total size of a local hard disk?

2009-06-15 Thread Tim Golden

willgun wrote:

Unfortunately,I'm on win32.
Actually,I prefer a cross-platform method.
Thanks.


These kind of things tend to be fairly platform specific.
Obviously, nothing's stopping anyone writing a module
which does some platform-sniffing
and conditional imports and provides a consistent
interface. Far as I know, though, there's no such thing
for Python at the mo.  Think of it as a market opportunity!

TJG
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the total size of a local hard disk?

2009-06-15 Thread Tim Golden

Paul Boddie wrote:

On 15 Jun, 14:58, willgun  wrote:

How to get the total size of a local hard disk?
I mean total size,not free space.


Which platform are you using? On a Linux-based system you might look
at the contents of /proc/partitions and then, presumably with Python,
parse the contents to yield a number of blocks for the hard disk in
question. This quantity would then be converted into a more familiar
measure.

One might expect something like PSI to support this kind of
activity...

http://bitbucket.org/chrismiles/psi/

...but I think it only really provides process-related information.



On Windows, WMI is nearly always the answer to these
kind of things (altho' since WMI is nearly always a
shell around other APIs there's usually some other way).

http://timgolden.me.uk/python/wmi_cookbook.html#percentage_free

TJG
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the total size of a local hard disk?

2009-06-15 Thread Paul Boddie
On 15 Jun, 14:58, willgun  wrote:
>
> How to get the total size of a local hard disk?
> I mean total size,not free space.

Which platform are you using? On a Linux-based system you might look
at the contents of /proc/partitions and then, presumably with Python,
parse the contents to yield a number of blocks for the hard disk in
question. This quantity would then be converted into a more familiar
measure.

One might expect something like PSI to support this kind of
activity...

http://bitbucket.org/chrismiles/psi/

...but I think it only really provides process-related information.

Paul
-- 
http://mail.python.org/mailman/listinfo/python-list