Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

DriverGet in Eventghost

If you have a question or need help, this is the place to be.
Post Reply
vbcrayon
Posts: 2
Joined: Fri Jul 30, 2010 1:30 pm

DriverGet in Eventghost

Post by vbcrayon »

Friends,

Is there anything like that http://www.autohotkey.com/docs/commands/DriveGet.htm? Can be in Python ...
Dragon470
Experienced User
Posts: 205
Joined: Thu Feb 10, 2011 2:16 am

Re: DriverGet in Eventghost

Post by Dragon470 »

Some of the stuff is available thru the WMI library. Including Type, Capacity, FS, Label, Serial, freespace, etc.


You first need to add wmi.py to your eventghost main directory.

Then you can pay around with a script like this:

Code: Select all

import wmi

DRIVE_TYPES = {
  0 : "Unknown",
  1 : "No Root Directory",
  2 : "Removable Disk",
  3 : "Local Disk",
  4 : "Network Drive",
  5 : "Compact Disc",
  6 : "RAM Disk"
}

c = wmi.WMI ()
for drive in c.Win32_LogicalDisk ():
  print drive.Caption, DRIVE_TYPES[drive.DriveType]
  #print drive #uncomment this line to get all information displayed
Or:

Code: Select all

import wmi
c = wmi.WMI()
for x in c.Win32_DiskDrive():
  print x
Or this that demonstrates the ability to use a query (doesn't grab as much info from wmi, shortening processing time) and then further uses disk.Name to only output one variable.:

Code: Select all

import wmi

c = wmi.WMI ()
wql = "SELECT Name FROM Win32_LogicalDisk WHERE DriveType <> 0"
for disk in c.query(wql):
  print disk.Name
Attachments
wmi.py
WMI.py file goes in EG main directory
(46.56 KiB) Downloaded 98 times
vbcrayon
Posts: 2
Joined: Fri Jul 30, 2010 1:30 pm

Re: DriverGet in Eventghost

Post by vbcrayon »

Thanks for the explanation, but I wanted to know if the drive is playing or not, just like autohotkey command:

Code: Select all

DriveGet, statuscd, statuscd, e
Explanation: http://www.autohotkey.com/docs/commands/DriveGet.htm
WMI library, only checks if the driver was accessed or not.

Another idea??

My temporary script:

Code: Select all

import wmi
import time
e_drive = wmi.WMI(moniker='Win32_LogicalDisk.DeviceID="E:"')
while e_drive.Access == None:
   time.sleep(1)
   e_drive = wmi.WMI(moniker='Win32_LogicalDisk.DevideID="E:"')
Post Reply