The Artima Developer Community
Sponsored Link

Python Buzz Forum
Checking for drives on Windows

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Aaron Brady

Posts: 576
Nickname: insommeuk
Registered: Aug, 2003

Aaron Brady is lead developer for Crestsource
Checking for drives on Windows Posted: Jan 9, 2004 7:04 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Aaron Brady.
Original Post: Checking for drives on Windows
Feed Title: insom.me.uk
Feed URL: http://feeds2.feedburner.com/insommeuk
Feed Description: Posts related to using Python. Some tricks and tips, observations, hacks, and the Brand New Things.
Latest Python Buzz Posts
Latest Python Buzz Posts by Aaron Brady
Latest Posts From insom.me.uk

Advertisement

If I'd only known it was this easy...

import win32file

def has_drive(drive):
	index = ord(drive.upper()) - ord('A')
	r = win32file.GetLogicalDrives()
	return r >> index & 1

Suggested uses: Checking if a USB key has been inserted, if a network share is available.

import time

waiting_for_sync = 1
while 1:
	has_e = has_drive('e'):
	if waiting_for_sync:
		if has_e:
			sync_bookmarks()
			waiting_for_sync = 0
	else:
		if not has_e:
			waiting_for_sync = 1
	time.sleep(60)

Read: Checking for drives on Windows

Topic: Plone 2 and e-Commerce Previous Topic   Next Topic Topic: Microcontrollers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use