[python-win32] win32api documentation

2009-10-09 Thread J
Hi everyone...

I've been searching high and low looking for any sort of decent
reference for the win32api in python and I can't find anything that is
useful.

The only real explanation I've found is the msdn site, but as I'm not
a C programmer, translating the various calls to python and guessing
what the python functions are called is probably an exercise in
futility at best.

So I wanted to start off by asking if any of you can point me to some
site or document that lists the various python calls to the win32api.

What I'm trying to do ultimately, is improve our testing scripts,
which are all python.  They are cross-platform and geared to run on
both windows and Linux systems in test.  The linux side is fairly
trivial, as I am pretty intimate with getting  what I want from a
Linux system.  However, getting that info, programmatically in Windows
is new ground for me and because I want this stuff to be as light as
possible, and portable, I don't want to rely on a bunch of extra
Windows tools to get the info.

The win32api has the calls I need, I just need help or a reference to
get them over to python.

So what I'm trying to do for now, is fairly simple.  I just want to be
able to make a couple calls and get system info like the number of
processor packages, the number of processor cores, processor flags (if
possible), free mem, total mem, OS version and a few other tidbits of
system information.

Any ideas that will help me get a clue?

Jeff

-- 

Stephen Leacock  - "I detest life-insurance agents: they always argue
that I shall some day die, which is not so." -
http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32api documentation

2009-10-09 Thread Tim Golden

J wrote:

I've been searching high and low looking for any sort of decent
reference for the win32api in python and I can't find anything that is
useful.


There isn't much, in spite of a few attempts (my own included)
to get something going. There's never enough time...


Ultimately, the win32api calls *are* wrapping the MSDN calls
almost directly so you just have to dive in, but ...



So what I'm trying to do for now, is fairly simple.  I just want to be
able to make a couple calls and get system info like the number of
processor packages, the number of processor cores, processor flags (if
possible), free mem, total mem, OS version and a few other tidbits of
system information.



Here at least I can help. Try using WMI which eats this kind of
thing for breakfast[*]. Start here:

 http://timgolden.me.uk/python/wmi.html

taking in this:

 http://timgolden.me.uk/python/wmi-tutorial.html

and this:

 http://timgolden.me.uk/python/wmi_cookbook.html

and feel free to get back with specifics.

TJG

[*] I hope :)
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32api documentation

2009-10-09 Thread J
On Fri, Oct 9, 2009 at 11:06, Tim Golden  wrote:

> Here at least I can help. Try using WMI which eats this kind of
> thing for breakfast[*]. Start here:
>
>  http://timgolden.me.uk/python/wmi.html
>
> taking in this:
>
>  http://timgolden.me.uk/python/wmi-tutorial.html
>
> and this:
>
>  http://timgolden.me.uk/python/wmi_cookbook.html
>
> and feel free to get back with specifics.

Awesome!  Thanks a lot.  I'll dig into that after lunch.  I finally
stumbled on the ActiveState info on win32api with a ref for all the
calls, and I'll have to do a little more digging.  I found out finally
how to pull SYSTEM_INFO (turns out it IS farily trivial) but now I
have other things to figure out (which is nice, as it actually gives
me something to do while I'm waiting on the next project to start).

I can pull most of what I need now after finding the ActiveState
reference, but specifically, I'm having trouble with:

Number of logical processors (counting cores with and without
HyperThreading enabled in BIOS)
Number of processor packages
Total system RAM
Available RAM

I think I can figure out the RAM, but right now it's the processor
counting and info that's dogging me.

Anyway, like I said, I'll dig into the WMI stuff in a bit after a nice
break from the lab and this nasty chair.

Thanks a lot for the pointers!

Jeff

-- 

Ogden Nash  - "The trouble with a kitten is that when it grows up,
it's always a cat." -
http://www.brainyquote.com/quotes/authors/o/ogden_nash.html
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] SSPI/NTLM authentication via XMLRPC

2009-10-09 Thread David
Thanks,
Sorry for not doing my homework but what does the "auth dance" entail, how
many backwards and forwards would there be, seeing as every bit of data
would have to be encapsulated via xmlrpc, would that potentially mean many
calls?



On Fri, Oct 9, 2009 at 6:09 AM, Mark Hammond wrote:

> On 9/10/2009 10:11 AM, David wrote:
>
>> Hi,
>>
>> I was wondering if this would be possible:
>>
>> At the minute i have a login xmlrpc call that takes a username/password
>> as an argument. simple enough, authenticates off the windows domain via
>> LogonUser(pywin32), the user then gets a cookie for the session(to
>> execute further xmlrpc calls).
>>
>> I was wondering if it would be possible to achieve SSO using SSPI/NTLM
>> via XMLRPC?
>>
>> I see an example in win32/Demos/sspi/socket_server.py, im not sure if
>> something similar could be used via XMLRPC.
>>
>
> Off the top of my head I can't see why not if you control both the client
> and the server and don't mind making them do an auth dance to set things up
> - you probably want to check out the simple_auth.py sample for some idea of
> how it could be implemented.
>
> Cheers,
>
> Mark
>
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32api documentation

2009-10-09 Thread Tim Golden

J wrote:

Awesome!  Thanks a lot.  I'll dig into that after lunch.  I finally
stumbled on the ActiveState info on win32api with a ref for all the
calls, and I'll have to do a little more digging.  


Well that's simply a copy of the CHM which is provided with
the pywin32 installation. I host another copy over here:

 http://timgolden.me.uk/pywin32-docs/contents.html

for private entertainment. It's fairly searchable using Google, eg:

http://www.google.co.uk/search?q=site%3Atimgolden.me.uk%2Fpywin32-docs+EnumProcesses

and has a bit of breadcrumbness about it to help you out. But,
as I say, it's merely an online copy of the .chm which is itself
eminently searchable.


I found out finally

how to pull SYSTEM_INFO (turns out it IS farily trivial) but now I
have other things to figure out (which is nice, as it actually gives
me something to do while I'm waiting on the next project to start).

I can pull most of what I need now after finding the ActiveState
reference, but specifically, I'm having trouble with:

Number of logical processors (counting cores with and without
HyperThreading enabled in BIOS)
Number of processor packages
Total system RAM
Available RAM

I think I can figure out the RAM, but right now it's the processor
counting and info that's dogging me.

Anyway, like I said, I'll dig into the WMI stuff in a bit after a nice
break from the lab and this nasty chair.


Although I'm the author of the Python wmi module, WMI itself
covers such a huge area that I have absolutely no pretence
at comprehensive knowledge. Faced with queries such as yours,
I'd normally just stick, eg, "available ram wmi" into Google
and go from there. There's lots of info out there aimed at
C or vbs developers; translating it into Python's usually
not too hard.

TJG
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] PythonWin Grep modifications

2009-10-09 Thread Elias Fotinis
I've made some modifications to PythonWin's Grep functionality. At first I 
just wanted to add highlighting for the regex matches, but I guess I got 
carried away. :b  I'll eventually submit it to SourceForge, so that Mark may 
include it in the official release if he wants. In the meantime, here's the 
current version: http://www.mediafire.com/file/mmjntzmjwmm/sgrepmdi.py


To test it, replace "pythonwin\pywin\framework\sgrepmdi.py". If anyone's got 
any more suggestions, fire away.


Here's a list of the changes so far:
   Functionality:
   - added match highlighting
   - replaced editboxes with combos to store MRU items
   - added keyboard handling:
 - Enter opens match (same as double-click)
 - AppMenu opens context menu (same as right-click)
   - added support for registry root key shorthands ('HKLM', 'HKCU', etc.)
   - added folder selection via common dlg
   - changed settings INI location to %AppData%;
 originally it defaulted to %WinDir% which wouldn't allow writing in 
Vista

   - made richedit control readonly
   Code & UI:
   - added a couple of comments, docstrings, and constants
   - added SearchOptions, PathSet, IniFile
   - replaced list-based dir/file/mask traversal with a generator
   - added msgboxes for Open/Save errors
   - added specific types to except clauses
   - replaced glob() with os.listdir() (glob() chokes on dirnames with 
square brackets)

   - replaced 'MS Sans Serif' dlg font with 'MS Shell Dlg'
   - tweaked dlg layouts and added a couple of icons
   BUGS:
   - setting text format is off by 1 sometimes (e.g. XP vs. Vista); maybe 
richedit EOL related

   - saved results file has junk at the end and uses \n as EOL
   - dirs and files are not generated in sorted order
   - context menu should be shown over the richedit cursor (not the mouse) 
when opened with the keyboard

   - right-clicking should move the caret before showing the context menu
   TODO:
   - tweak "More" dialog and rename to "Favorites"
   - keyboard: make Delete remove whole match line
   - add options for fonts, colors, regex (e.g. highlight all matches, not 
just first)

   - test on Python 3

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to use COM when there isn't a type library or IDL file

2009-10-09 Thread Thomas Heller
Mark Hammond schrieb:
> This is very tricky to do in pure-python.  Other interfaces with this 
> issue (eg, the shell interfaces) tend to use custom c++ code (often 
> generated by the 'makegw' package then heavily edited) to implement a 
> win32com 'sub-module'.  The best alternative for you may be to 
> investigate how comtypes might help...

comtypes: If neither a type library nor an idl file is available,
then you can still create the interface definition manually.
You can probably, given some experience, define the interface
by looking at the header file.  I started this for the first few
methods of the IRealTimeStylus interface:

"""
# module realtimestylus.py
from ctypes import *
from ctypes.wintypes import *
from comtypes import IUnknown
from comtypes import GUID
from comtypes import COMMETHOD

class IRealTimeStylus(IUnknown):
_iid_ = GUID('{A8BB5D22-3144-4A7B-93CD-F34A16BE513A}')

IRealTimeStylus._methods_ = [
COMMETHOD(['propget'], HRESULT, 'Enabled',
  ( ['retval', 'out'], POINTER(c_int), 'pfEnable' )),
COMMETHOD(['propput'], HRESULT, 'Enabled',
  ( ['in'], c_int, 'pfEnable' )),

COMMETHOD(['propget'], HRESULT, 'HWND',
  ( ['retval', 'out'], POINTER(c_int), 'phwnd' )),
COMMETHOD(['propput'], HRESULT, 'HWND',
  ( ['in'], c_int, 'phwnd' )),

COMMETHOD(['propget'], HRESULT, 'WindowInputRectangle',
  ( ['retval', 'out'], POINTER(RECT), 'prcWndInputRect' )),
COMMETHOD(['propput'], HRESULT, 'WindowInputRectangle',
  ( ['in'], c_int, 'prcWndInputRect' )),

# here are quite some methods missing...
]
"""

Then you can create such an object, QI for the interface, and try to use it.
I had to look up the CLSID for the RealTimeStylus class in the registry.

>>> p = CreateObject("{E26B366D-F998-43CE-836F-CB6D904432B0}")
>>> print p

>>> p.QueryInterface(IRealTimeStylus)

>>> s = p.QueryInterface(IRealTimeStylus)
>>> s.Enabled
0
>>> s.Enabled = 1
Traceback (most recent call last):
  File "", line 1, in 
  File "comtypes\__init__.py", line 278, in __setattr__
value)
_ctypes.COMError: (-2144862203, 'The clear disable flag is set and all clear 
operations now require physical access.', (None, None, None, 0, None))
>>>


However, I would only recommend this approach to an experienced
COM developer.

Thomas

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32