[Twisted-Python] Windows Programming Info

Michael Schneider michaelschneider at fuse.net
Sat Feb 14 00:02:09 EST 2004


Thanks to all for the help with win32eventreactor and spawnprocess.


I came across a great windows package called wmi (for microsoft's
Windows Managment Interface).

It gives you very low level access to your windows system. It uses
win32.

Here is the URL:

http://tgolden.sc.sabren.com/python/wmi.html

Here is some sample code to run


Thanks for the help on this,
I will post my final code for the compute node class

----------------------------------------------------------
import wmi
c = wmi.WMI ()

diskList = [x for x in c.Win32_LogicalDisk (DriveType=3) ]
procList = [proc for proc in  c.Win32_Process () ]

for x in range(10):
    for disk in diskList:
        print disk

    for process in procList:
        print process



----------------------------------------------------------


Note: to kill a job, you can call terminate on a process object

result = process.Terminate ()

------------------------------------------

disk output:
instance of Win32_LogicalDisk
{
        Caption = "G:";
        Compressed = FALSE;
        CreationClassName = "Win32_LogicalDisk";
        Description = "Local Fixed Disk";
        DeviceID = "G:";
        DriveType = 3;
        FileSystem = "FAT32";
        FreeSpace = "9506979840";
        MaximumComponentLength = 255;
        MediaType = 12;
        Name = "G:";
        Size = "12572344320";
        SupportsDiskQuotas = FALSE;
        SupportsFileBasedCompression = FALSE;
        SystemCreationClassName = "Win32_ComputerSystem";
        SystemName = "BDSWXP1";
        VolumeDirty = FALSE;
        VolumeName = "LOCAL DISK";
        VolumeSerialNumber = "ED293D74";
};
-------------------------------------------------
process output

instance of Win32_Process
{
        Caption = "System Idle Process";
        CreationClassName = "Win32_Process";
        CSCreationClassName = "Win32_ComputerSystem";
        CSName = "BDSWXP1";
        Description = "System Idle Process";
        Handle = "0";
        HandleCount = 0;
        KernelModeTime = "7163013906250";
        Name = "System Idle Process";
        OSCreationClassName = "Win32_OperatingSystem";
        OSName = "Microsoft Windows XP
Professional|C:\\WINDOWS|\\Device\\Harddi
sk0\\Partition1";
        OtherOperationCount = "0";
        OtherTransferCount = "0";
        PageFaults = 1;
        PageFileUsage = 0;
        ParentProcessId = 0;
        PeakPageFileUsage = 0;
        PeakVirtualSize = "0";
        PeakWorkingSetSize = 20480;
        Priority = 0;
        PrivatePageCount = "0";
        ProcessId = 0;
        QuotaNonPagedPoolUsage = 0;
        QuotaPagedPoolUsage = 0;
        QuotaPeakNonPagedPoolUsage = 0;
        QuotaPeakPagedPoolUsage = 0;
        ReadOperationCount = "0";
        ReadTransferCount = "0";
        SessionId = 0;
        ThreadCount = 1;
        UserModeTime = "0";
        VirtualSize = "0";
        WindowsVersion = "5.1.2600";
        WorkingSetSize = "20480";
        WriteOperationCount = "0";
        WriteTransferCount = "0";
};






More information about the Twisted-Python mailing list