Friday, January 22, 2016

wmi python module - part 001.

Named WMI from Windows Management Instrumentation, this python module allow you to use Microsoft’s implementation of Web-Based Enterprise Management ( WBEM ).
Is a set of extensions to the Windows Driver Model AND that provides an operating system interface.
allows you to scripting languages like VBScript to manage Microsoft Windows personal computers and servers, both locally and remotely.
You cand read about this python module here.

C:\Python34\Scripts>pip install  wmi
Installing collected packages: wmi
Running install for wmi
warning: install_data: setup script did not provide a directory for 'readme.
txt' -- installing right in 'C:\Python34'
Successfully installed wmi
Cleaning up...

Let try first example :

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wmi
>>> remote_process = wmi.WMI (computer="home").new ("Win32_Process")
>>> for i in wmi.WMI ().Win32_OperatingSystem ():
...     print (i.Caption)
Microsoft Windows 10 Home

Now let's see another example can used by you with wmi python module.
This example let you see your processes.

import wmi
import datetime
c = wmi.WMI()
process_watcher = c.Win32_Process.watch_for("modification")
while True:
  new_process = process_watcher()
  print (new_process.Caption)

I used the python version 3.3.5 and Spyder ( Scientific PYthon Development EnviRonment ) to test the script.
You can change .watch_for method args with: creation, deletion, modification or operation.

Python and uno python module - wrong.

I know that from some time and I think is wrong to lineup python modules with python and software.
Also I know just few people know how really working python with the python community and development team , but I need to show us how hard can be when you try to show or make a brief of open source.
Many people can tell about python can be a great programming language and can be used with open source software like LibreOffice.
Then you can stop and tell this:

Not working from years!

Let's see.
C:\Python34>cd Scripts

C:\Python34\Scripts>pip3.4.exe install uno
Collecting uno
  Downloading uno-0.3.3.tar.gz
Collecting py==1.4.22 (from uno)
  Downloading py-1.4.22.tar.gz (189kB)
    100% |################################| 192kB 687kB/s
 You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm

so I update the pip application

C:\Python34\Scripts>C:\Python34\python.exe -m pip install --upgrade pip
Collecting pip
  Using cached pip-8.0.2-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 7.1.2
    Uninstalling pip-7.1.2:
      Successfully uninstalled pip-7.1.2
Successfully installed pip-8.0.2
Very good for now , but as we can see ... I got this:
C:\Python34\Scripts>cd ..

Traceback (most recent call last):
  File "", line 21, in <module>
    import uno
  File "C:\Python34\lib\site-packages\uno\", line 4, in <module>
    from base import Element, Css, Payload, UnoBaseFeature, UnoBaseField
ImportError: No module named 'base'</module></module>

If the development team will make one huge effort to fix all necessary python modules and all python source code from LibreOffice then we can tell:

It's working now.