WMI in Python

K

KING LABS

Hi All,

I am new to programming and python, Being a system administrator I
have chose Inventory (Software & Hardware ) as my first project.

I would like to know experts advice on the best way to build the same
using python. I would like to this tool to evolve into full fledge
application.

I would like to collect the complete information of system hardware &
and also software installed from registry and add/remove program and
feed this data into database.

Regards,
KINGLABS
 
R

Rodrick Brown

The easiest way to do this is to use the native OS tools readily available to do the collection and log to a central location or if possible shared location accessible by all systems, once you have all the data you want to feed into your RDBMS you could easily parse these logs using python and the native db access module.

I hope this give you a pointer.

Sent from my iPhone 4.
 
K

KING LABS

The easiest way to do this is to use the native OS tools readily available to do the collection and log to a central location or if possible shared location accessible by all systems, once you have all the data you want to feed into your RDBMS you could easily parse these logs using python and the native db access module.

I hope this give you a pointer.

Sent from my iPhone 4.

I am trying to learn Python programming. Since I need a custom
inventory management tool for my work place. I am considering it as a
project in the process of learning Python.

I am not looking for easiest way of doing things.
I am considering using Python . Also I would need to build a setup of
the tool for easy installation.

Hope I am clear this time

Regards,
KINGLABS
 
E

Ed Leafe

I am trying to learn Python programming. Since I need a custom
inventory management tool for my work place. I am considering it as a
project in the process of learning Python.

I am not looking for easiest way of doing things.
I am considering using Python . Also I would need to build a setup of
the tool for easy installation.

Hope I am clear this time


If you're looking for a rich client (i.e., desktop) application, and not a web app, you should check out Dabo: http://dabodev.com. We have hundreds of developers around the world using Dabo to build many different kinds of business applications.


-- Ed Leafe
 
A

Aahz

I would like to collect the complete information of system hardware &
and also software installed from registry and add/remove program and
feed this data into database.

You should subscribe to the win32 mailing list:

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

Before you ask questions there, do a bit of searching first -- there are
lots of examples.
--
Aahz ([email protected]) <*> http://www.pythoncraft.com/

[on old computer technologies and programmers] "Fancy tail fins on a
brand new '59 Cadillac didn't mean throwing out a whole generation of
mechanics who started with model As." --Andrew Dalke
 
J

Jerry Hill

K

KING LABS

Thank you all, I will go through the links provided and suggestions.
Shall get back to you on this soon.

The following information is exactly what I am trying to collect for
the inventory. I can find vb scripts with googling. I want to do the
same with Python & Win32. Use Server/Client architecture .
Client(agent) updates the information to server.

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

BIOS:

System serial number, manufacturer, and model
Bios manufacturer, version, and date

Processors:

Type, count (how many of them), manufacturer, speed, and cache

Memory:

Physical memory type, manufacturer, capacity, and slot number
Total physical memory
Total swap/paging memory

Video:

Video adapter: Chipset/model, manufacturer, memory size, speed, and
screen resolution

Display monitor: Manufacturer, description, refresh rate, type, serial
number, and caption

Storage/removable devices:

Manufacturer, model, size, type, speed( all when applicable)

Drive letter, filesystem type, partition/volume size, free space

Network adapters/telephony:

Manufacturer, model, type, speed, and description
MAC and IP address, mask and IP gateway, DHCP server used

Miscellaneous hardware:

Input devices: Keyboard, mouse, and pointing device
Sound devices: Manufacturer name, type, and description
System slots: Name, type, and designation
System ports: Type, name, caption, and description

Software Information: ( from registry & add/remove program )

Operating system: Name, version, comments, and registration info
Installed software: Name, publisher, version (from Add / Remove
software or Programs and Features menu)
Custom-specified registry queries (applicable to Windows OS)

------------------------------------------------------------------------------------------------------------------
 
B

bli

The following information is exactly what I am trying to collect for
the inventory. I can find vb scripts with googling. I want to do the
same with Python & Win32. Use Server/Client architecture .
Client(agent) updates the information to server.

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

BIOS:

System serial number, manufacturer, and model
Bios manufacturer, version, and date

Processors:

Type, count (how many of them), manufacturer, speed, and cache

Memory:

Physical memory type, manufacturer, capacity, and slot number
Total physical memory
Total swap/paging memory

Video:

Video adapter: Chipset/model, manufacturer, memory size, speed, and
screen resolution

Display monitor: Manufacturer, description, refresh rate, type, serial
number, and caption

Storage/removable devices:

Manufacturer, model, size, type, speed( all when applicable)

Drive letter, filesystem type, partition/volume size, free space

Network adapters/telephony:

Manufacturer, model, type, speed, and description
MAC and IP address, mask and IP gateway, DHCP server used

Miscellaneous hardware:

Input devices: Keyboard, mouse, and pointing device
Sound devices: Manufacturer name, type, and description
System slots: Name, type, and designation
System ports: Type, name, caption, and description

Software Information: ( from registry & add/remove program )

Operating system: Name, version, comments, and registration info
Installed software: Name, publisher, version (from Add / Remove
software or Programs and Features menu)
Custom-specified registry queries (applicable to Windows OS)

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

when I found Python :) I downloaded from a Ms site many (+- 120) py
programs for hardware and os stuff and collated them into one script.
Astonishing amount of data in the innards of a computer, do not print
some of these!@#!
I meant to wrap it in a neat menu (any time now), but it is easy to
use as is.
A few of the options :
102 --- -List Terminal Services Terminals-
103 --- -List Terminal Services Permissions-
104 --- -List Terminal Services Session Settings-
105 --- - List Terminal Services Session Directory Settings-
106 --- - List Terminal Services Network Adapter-
107 --- -List Terminal Services Environment Settings-
108 --- -List Terminal Services Logon Settings-
109 --- -List Terminal Services General Settings-
110 --- -List Terminal Services Client Settings-
111 --- -List Terminal Services Terminal Settings-
112 --- -List Terminal Service Service Properties-
113 --- -List Info about Binary Files used on Computer-
114 --- -List Info about CODECS on this computer-
115 --- -List Installed Software-
116 --- -List Installed Software Features-

Happy to send to you, will post it somewhere soon.
 
A

alex23

KING LABS said:
The following information is exactly what I am trying to collect for
the inventory. I can find vb scripts with googling. I want to do the
same with Python & Win32. Use Server/Client architecture .
Client(agent) updates the information to server.

I highly agree with the recommendations for Tim Golden's WMI library.
I once used it during an MS VBScript course for sys admins to produce
python equivalents of the VBS code; it was far, _far_ easier to
componentise & reuse python code than VBS.

However, for a quick & ready solution, have you looked at Microsoft's
Scriptomatic?[2] It's a handy little tool that lets you specify the
WMI query you want and produces code for you, with Python being one of
the targets. It _should_ be able to handle most of everything you're
after, with the exception of Software Information (from memory that's
not something WMI covers?).

Once Scriptomatic has generated the bulk of the WMI code, that's the
payload of your client-side script. There are many many many ways of
doing simple client/server set ups in python, just google and pick one
that works at a suitable abstraction level for you. Here's a
straightforward sockets-based approach[3] (that I've never used but
looks okay).

1: http://timgolden.me.uk/python/wmi/index.html
2: http://www.microsoft.com/downloads/...42-648b-4119-b7eb-783b0f7d1178&displaylang=en
3: http://wdvl.internet.com/Authoring/python/client/watts06152009.html
 
L

Lawrence D'Oliveiro

In message
alex23 said:
However, for a quick & ready solution, have you looked at Microsoft's
Scriptomatic?[2] It's a handy little tool that lets you specify the
WMI query you want and produces code for you, with Python being one of
the targets.

Why not just call Scriptomatic directly from within the Python script, then?
Machine-generated code has no place in a source file to be maintained by a
human.
 
A

alex23

Lawrence D'Oliveiro said:
Why not just call Scriptomatic directly from within the Python script, then?

Because Scriptomatic _generates scripts to access WMI_, that's what it
_does_. Are you _seriously_ advocating writing Python code to fire up
a Windows application, programmatically manipulating a GUI to generate
more Python code for your original script to import or exec?

For your question to make any real sense, you'd want to ask "Why not
access WMI directly...", which you might notice was the first
recommendation I made.
Machine-generated code has no place in a source file to be maintained by a
human.

As you've made your disdain for Windows _perfectly_ clear through your
incessant sniping on this list, I think I'm pretty safe in saying you
have no idea of the quality of Scriptomatic's output. I don't
understand what possibly makes you believe you're qualified to make
such a statement.
 
K

KING LABS

Because Scriptomatic _generates scripts to access WMI_, that's what it
_does_. Are you _seriously_ advocating writing Python code to fire up
a Windows application, programmatically manipulating a GUI to generate
more Python code for your original script to import or exec?

For your question to make any real sense, you'd want to ask "Why not
access WMI directly...", which you might notice was the first
recommendation I made.


As you've made your disdain for Windows _perfectly_ clear through your
incessant sniping on this list, I think I'm pretty safe in saying you
have no idea of the quality of Scriptomatic's output. I don't
understand what possibly makes you believe you're qualified to make
such a statement.

Thank you all .... looks I got lot of reading to be done now based on
all your suggestions.
 
L

Lawrence D'Oliveiro

In message
alex23 said:
Because Scriptomatic _generates scripts to access WMI_, that's what it
_does_.

Precisely why I suggested running it on the fly. Because machine-generated
code has no place in a source file to be maintained by a human.
Are you _seriously_ advocating writing Python code to fire up
a Windows application, programmatically manipulating a GUI to generate
more Python code for your original script to import or exec?

If that’s the only way you can use Scriptomatic, then the stupidity lies
with the one who suggested using such a brain-dead tool in the first place.
As you've made your disdain for Windows _perfectly_ clear through your
incessant sniping on this list, I think I'm pretty safe in saying you
have no idea of the quality of Scriptomatic's output.

The quality of the output is not at issue here. The point is that it is
machine-generated from an input command, therefore it makes sense from a
maintenance viewpoint to keep the input command, not the machine-generated
output, in the source file, and simply generate the latter from the former
as part of the build process.

Unfortunately, as you have made abundantly clear above, Scriptomatic is a
GUI-only tool, totally unsuited to this sort of use.
 
A

alex23

Lawrence D'Oliveiro said:
Because machine-generated
code has no place in a source file to be maintained by a human.

Endlessly repeating your bigotry doesn't make it any more true.
 
L

Lawrence D'Oliveiro

In message
alex23 said:
Endlessly repeating your bigotry doesn't make it any more true.

The point is that it is machine-generated from an input command, therefore
it makes sense from a maintenance viewpoint to keep the input command, not
the machine-generated output, in the source file, and simply generate the
latter from the former as part of the build process.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top