Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 18th, 2008, 5:37 AM   #1
Freaky Chris
Professional Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 422
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
Listing HD's

Hey, i was wondering if anybody could point in the right direction. Ie give me the name of modules and links to module listing etc for a method of listing what HD's a computer, under WinXP.

Thanks,
Chris
__________________
Steven Skiena - Algorithms

,[->+>+<<]>>[-<<+>>]>++++++++[-<++++++++>]<+[-<->]>+<<[[-]+++++++++++++++.[-]>]>>[+++++++++.[-]],
brainf**k -- It's such a pretty language
Freaky Chris is online now   Reply With Quote
Old May 18th, 2008, 3:23 PM   #2
Freaky Chris
Professional Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 422
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
Re: Listing HD's

Is there a way of doing this properly or would i have to do something like this

Python Syntax (Toggle Plain Text)
  1. drives = ["A:\\", "B:\\", "C:\\", "D:\\", "E:\\", "F:\\", "G:\\", "H:\\", "I:\\", "J:\\", "K:\\", "L:\\", "M:\\", "N:\\", "O:\\", "P:\\", "Q:\\", "R:\\", "S:\\", "T:\\", "U:\\", "V:\\", "W:\\", "X:\\", "Y:\\", "Z:\\"]
  2. for drive in drives:
  3. if os.path.exists(drive):
  4. print drive, "Present"
  5. else:
  6. print drive, "Not Present"

So is that how i will have to do it, or is there an actual method to do that for you?

Chris
__________________
Steven Skiena - Algorithms

,[->+>+<<]>>[-<<+>>]>++++++++[-<++++++++>]<+[-<->]>+<<[[-]+++++++++++++++.[-]>]>>[+++++++++.[-]],
brainf**k -- It's such a pretty language
Freaky Chris is online now   Reply With Quote
Old May 18th, 2008, 3:51 PM   #3
iEngage
Newbie
 
iEngage's Avatar
 
Join Date: May 2008
Location: teh interwebz
Posts: 22
Rep Power: 0 iEngage is on a distinguished road
Re: Listing HD's

well I don't have a solution for you, but one thing worth mentioning about the way you have it done is this: every single drive that has a letter will be shown as present. This includes mapped drives, optical drives etc.

EDIT: I found the below link that may help, but it seems as if you have to have a 3rd party module to do it, because when i tried it it gave an error about win32file

http://mail.python.org/pipermail/pyt...ay/324479.html

Also instead of listing out all the drives like that in one huge array, you could just do the following if you like it better:

python Syntax (Toggle Plain Text)
  1. import os,string
  2.  
  3. for drive in string.ascii_uppercase:
  4. if os.path.exists(drive+":"):
  5. print drive+":", "Present"
  6. else:
  7. print drive+":", "Not Present"
__________________
iEngage
iEngage is offline   Reply With Quote
Old May 18th, 2008, 4:04 PM   #4
Freaky Chris
Professional Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 422
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
Re: Listing HD's

Indeed this is a 3rd party module which is not what im after, and yes im aware that the solution i use will show all drives, this is in actual fact how i would like it. You have to bare in mind in only shows drives in use not blank CD drives etc. And again mapped network drives are also wanted.

Chris
__________________
Steven Skiena - Algorithms

,[->+>+<<]>>[-<<+>>]>++++++++[-<++++++++>]<+[-<->]>+<<[[-]+++++++++++++++.[-]>]>>[+++++++++.[-]],
brainf**k -- It's such a pretty language
Freaky Chris is online now   Reply With Quote
Old May 18th, 2008, 4:13 PM   #5
iEngage
Newbie
 
iEngage's Avatar
 
Join Date: May 2008
Location: teh interwebz
Posts: 22
Rep Power: 0 iEngage is on a distinguished road
Re: Listing HD's

well then in that case your solution seems to be the way to go
__________________
iEngage
iEngage is offline   Reply With Quote
Old May 18th, 2008, 4:16 PM   #6
Freaky Chris
Professional Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 422
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
Re: Listing HD's

yes and ising string is the better option, i don't know why i didn't do that in the first place lol. O well thanks for reminding me. i May look int WMI (although it is an extra module) aparently has some functionality that could be of use to me.

Chris
__________________
Steven Skiena - Algorithms

,[->+>+<<]>>[-<<+>>]>++++++++[-<++++++++>]<+[-<->]>+<<[[-]+++++++++++++++.[-]>]>>[+++++++++.[-]],
brainf**k -- It's such a pretty language
Freaky Chris is online now   Reply With Quote
Old May 18th, 2008, 4:25 PM   #7
iEngage
Newbie
 
iEngage's Avatar
 
Join Date: May 2008
Location: teh interwebz
Posts: 22
Rep Power: 0 iEngage is on a distinguished road
Re: Listing HD's

Quote:
Originally Posted by Freaky Chris View Post
O well thanks for reminding me.
no problem
__________________
iEngage
iEngage is offline   Reply With Quote
Old May 18th, 2008, 4:48 PM   #8
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
Re: Listing HD's

Not a python person but a quick google turned up this

Hope it helps
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old May 18th, 2008, 4:57 PM   #9
Freaky Chris
Professional Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 422
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
Re: Listing HD's

Yer its another example of a third party module by the looks of it, or at least a module that is no longer supported. I'd rather use default libraries and working with the solution i have at the moment since i would like to be able to rn the script on other machines that will not have the extra modules installed.

But thanks anyway, these were the sorts of things i was getting when i googled it myself.

Chris
__________________
Steven Skiena - Algorithms

,[->+>+<<]>>[-<<+>>]>++++++++[-<++++++++>]<+[-<->]>+<<[[-]+++++++++++++++.[-]>]>>[+++++++++.[-]],
brainf**k -- It's such a pretty language
Freaky Chris is online now   Reply With Quote
Old May 20th, 2008, 10:28 AM   #10
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
Re: Listing HD's

I wouldn't stop there at all. Take a look at the source code for those 3rd party modules. Its most likely that they use the Win32 API (or another C api). If so you can use ctypes to just load the right DLL and call the needed functions directly from Python. No 3rd party module is needed. I have done this myself for other areas of Win32 API and it works just fine.
__________________
Robotics @ Maryland AUV Team - Software Lead
Game_Ender is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Query and List, PhP Main Page Auto Listing of User Actio Stryker PHP 1 Aug 21st, 2006 4:40 PM
IDX MLS Listing Software galgoz Paid Job Offers 5 May 15th, 2006 4:03 PM
Rank Listing Lightninghawk Coder's Corner Lounge 2 Nov 4th, 2005 4:04 AM
How to get file listing of a dir some1 C++ 16 May 29th, 2005 10:45 AM
Explorer Directory Listing Lance Existing Project Development 5 Jan 28th, 2005 2:03 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:46 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC