Re: [python-win32] Bundling font with application?

2011-05-17 Thread Gabriel Genellina
En Tue, 17 May 2011 02:58:07 -0300, Greg Ewing  
 escribió:



Is there a way to tell an ordinary Windows application to
look for fonts in a specific directory, or load a font from
a specific file? The only things I've been able to find about
this using Google all relate to .NET.


I think AddFontResourceEx is what you are looking for.
http://msdn.microsoft.com/en-us/library/dd183327(v=VS.85).aspx

--
Gabriel Genellina

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


Re: [python-win32] 'No such interface supported' question

2010-01-13 Thread Gabriel Genellina
En Fri, 08 Jan 2010 00:25:15 -0300, Gareth Walters   
escribió:


I have done some python work before but I new to the COM stuff. I am  
trying to Create a MXD and layers to it from python. I have been looking  
at this PythonNet stuff and it is all getting a bit blurry.
I was wondering if you could give me some pointers to basically get  
python recognizing the ArcMap class or do you have any code that would  
help me get to that point?


Mark Hammond's book "Python Programming On Win32" covers using COM objects  
from Python. You're mostly interested in chapter 12. I think this chapter  
is available for preview from the O'Reilly site.

http://oreilly.com/catalog/9781565926219/

--
Gabriel Genellina

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


Re: [python-win32] Guaranteed cleanup code execution?

2010-01-13 Thread Gabriel Genellina
En Mon, 11 Jan 2010 23:33:23 -0300, Mario Alejandro Vilas Jerez  
 escribió:


But what I think you're really looking for is the Service Control  
Manager:


http://msdn.microsoft.com/en-us/library/ms685150(VS.85).aspx

The ControlService API lets you stop services (among other things):

http://msdn.microsoft.com/en-us/library/ms682108(VS.85).aspx

And the StartService API lets you start a service manually:

http://msdn.microsoft.com/en-us/library/ms686321(VS.85).aspx


All of which are covered in the win32service and win32serviceutil modules  
inside PyWin32. There are a couple demos too. It's quite easy to write a  
service using the classes provided.


--
Gabriel Genellina

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


Re: [python-win32] File Time: win32file vs Python ?

2009-07-05 Thread Gabriel Genellina

En Sat, 04 Jul 2009 03:31:11 -0300, Robert 
escribió:

Guess this is wrong in win32file; or win32file looses info by early  
conversion to digits.


There is certainly something fishy with win32file. GetFileTime/SetFileTime
don't even agree about the times being local or UTC:

  from win32file import CreateFile, SetFileTime, GetFileTime, CloseHandle
  from win32file import GENERIC_READ, GENERIC_WRITE, OPEN_EXISTING

fn = "test.txt"
fh = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING,
0, 0)
sts, creationTime, accessTime, writeTime = GetFileTime(fh)
print creationTime, accessTime, writeTime
SetFileTime(fh, creationTime, accessTime, writeTime)
CloseHandle(fh)

fh = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING,
0, 0)
sts, creationTime, accessTime, writeTime = GetFileTime(fh)
print creationTime, accessTime, writeTime
CloseHandle(fh)

Each time the script is executed, the file's times advances by 3 hours (I
am located at GMT-3).

D:\temp>python testfiletime.py
07/06/09 04:13:12 07/06/09 04:50:36 06/10/07 09:38:26
07/06/09 07:13:12 07/06/09 07:50:36 06/10/07 12:38:26

D:\temp>python testfiletime.py
07/06/09 07:13:12 07/06/09 07:50:36 06/10/07 12:38:26
07/06/09 10:13:12 07/06/09 10:50:36 06/10/07 15:38:26

D:\temp>dir test.txt
   El volumen de la unidad D es Dardo
   El número de serie del volumen es: 9884-7F48

   Directorio de D:\temp

10/06/2007  12:3821.468 test.txt
 1 archivos 21.468 bytes
 0 dirs 204.499.968 bytes libres


To restore the same date/time, I have to use:

  from pywintypes import Time
creationTime, accessTime, writeTime = [Time(timegm(localtime(int(t for
t in GetFileTime(fh)[1:]]

--
Gabriel Genellina

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


Re: [python-win32] File Time: win32file vs Python ?

2009-07-05 Thread Gabriel Genellina
En Sat, 04 Jul 2009 03:31:11 -0300, Robert   
escribió:


Guess this is wrong in win32file; or win32file looses info by early  
conversion to digits.


There is certainly something fishy with win32file. GetFileTime/SetFileTime  
don't even agree about the times being local or UTC:


from win32file import CreateFile, SetFileTime, GetFileTime, CloseHandle
from win32file import GENERIC_READ, GENERIC_WRITE, OPEN_EXISTING

fn = "test.txt"
fh = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING,  
0, 0)

sts, creationTime, accessTime, writeTime = GetFileTime(fh)
print creationTime, accessTime, writeTime
SetFileTime(fh, creationTime, accessTime, writeTime)
CloseHandle(fh)

fh = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING,  
0, 0)

sts, creationTime, accessTime, writeTime = GetFileTime(fh)
print creationTime, accessTime, writeTime
CloseHandle(fh)

Each time the script is executed, the file's times advances by 3 hours (I  
am located at GMT-3).


D:\temp>python testfiletime.py
07/06/09 04:13:12 07/06/09 04:50:36 06/10/07 09:38:26
07/06/09 07:13:12 07/06/09 07:50:36 06/10/07 12:38:26

D:\temp>python testfiletime.py
07/06/09 07:13:12 07/06/09 07:50:36 06/10/07 12:38:26
07/06/09 10:13:12 07/06/09 10:50:36 06/10/07 15:38:26

D:\temp>dir test.txt
 El volumen de la unidad D es Dardo
 El número de serie del volumen es: 9884-7F48

 Directorio de D:\temp

10/06/2007  12:3821.468 test.txt
   1 archivos 21.468 bytes
   0 dirs 204.499.968 bytes libres


To restore the same date/time, I have to use:

from pywintypes import Time
creationTime, accessTime, writeTime = [Time(timegm(localtime(int(t for  
t in GetFileTime(fh)[1:]]


--
Gabriel Genellina

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


Re: [python-win32] Problem in identifying an archived file in Windows

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 05:40:22 -0200, venu madhav   
escribió:



   I am writing an application which has to identify the
archived files in a given directory.I've tried using the function
i = win32api.GetFileAttributes (full_path)

to obtain the attributes.But am unable to identify based on the value
it returns as it is returning 5152, 13856 etc for different files but
all of them are archived. Is there any way to come to a conclusion
using these numbers about whether a file is archived or not.


So you're using the pywin32 package. It comes with a help file  
(PyWin32.chm), you can open it right from the menu: Start, All Programs,  
Python XX, Python for Windows documentation.
Go to the GetFileAttributes topic. It says "The return value is a  
combination of the win32con.FILE_ATTRIBUTE_* constants". Ok, which  
constants? Let Python tell us:


py> import win32con
py> [name for name in dir(win32con) if name.startswith("FILE_ATTRIBUTE_")]
['FILE_ATTRIBUTE_ARCHIVE', 'FILE_ATTRIBUTE_ATOMIC_WRITE',  
'FILE_ATTRIBUTE_COMPRESSED', 'FILE_ATTRIBUTE_DIRECTORY',  
'FILE_ATTRIBUTE_HIDDEN', 'FILE_ATTRIBUTE_NORMAL',  
'FILE_ATTRIBUTE_READONLY','FILE_ATTRIBUTE_SYSTEM',  
'FILE_ATTRIBUTE_TEMPORARY', 'FILE_ATTRIBUTE_XACTION_WRITE']


What do they mean? The best source is the Microsoft site. There is a very  
convenient link in the help topic: "Search for GetFileAttributes at msdn,  
google or google groups." Click on msdn, the first result is  
<http://msdn.microsoft.com/en-us/library/aa364944(VS.85).aspx>

You apparently are looking for FILE_ATTRIBUTE_ARCHIVE.

--
Gabriel Genellina

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


[python-win32] service support in 2.6 isn't working

2008-12-30 Thread Gabriel Genellina

Hello

I had some problems writting a service using Python 2.6 and pywin32 Build  
212, and I eventually found that even the pipeTestService.py demo program  
doesn't work either.


The service apparently installs fine, but refuses to start:

C:\APPS\Python26\Lib\site-packages\win32\Demos\service>python26  
pipeTestService.

py install
Installing service PyPipeTestService
Service installed

C:\APPS\Python26\Lib\site-packages\win32\Demos\service>python26  
pipeTestService.

py start
Starting service PyPipeTestService
Error starting service: El servicio no ha respondido a la petici¾n o  
inicio del

control en un tiempo adecuado.

(in english: "The service did not answer the start request in adequate  
time")
The error comes immediately, without any delay, so I guess a timeout  
somewhere is set too small.


If I uninstall the demo service, and reinstall using Python 2.5 and  
pywin32 Build 210, it works fine.


--
Gabriel Genellina

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


Re: [python-win32] Pythonwin telit

2008-09-19 Thread Gabriel Genellina
En Thu, 18 Sep 2008 15:39:40 -0300, Juan Manuel Pubill  
<[EMAIL PROTECTED]> escribió:


Hola quería saber si hay posibilidad de conseguir alguna versión más  
nueva que la que distribuye Telit del pythonwin porque es poco estable y  
tiene varios bugs.

Sin más muchas gracias


Lista de Python en castellano:
[EMAIL PROTECTED] ==  
http://dir.gmane.org/gmane.comp.python.general.castellano


--
Gabriel Genellina

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


Re: [python-win32] Internet Explorer constants

2008-09-05 Thread Gabriel Genellina
En Fri, 05 Sep 2008 05:23:01 -0300, Tim Golden <[EMAIL PROTECTED]>  
escribió:



Gabriel Genellina wrote:

Hello
 I want to control Internet Explorer. This is what I have so far:
 import win32com.client
from win32com.client.gencache import EnsureDispatch
url = "..."
IE = EnsureDispatch("InternetExplorer.Application")
IE.Navigate(url)
IE.Visible = 1
 It works fine and shows the requested page. Now I want to use the  
"Save As" command. Looks like I should call the
IWebBrowser2.ExecWB method, passing IDM_SAVEAS as the command and  
MSOCMDEXECOPT_DONTPROMPTUSER in the options. But I don't know how to  
obtain the value for such constants... I could dig into the C header  
files looking for them, but is there some other way?
 The ExecWB method is documented here  
http://msdn.microsoft.com/en-us/library/aa752117(VS.85).aspx


The usual way to get at constants after a Dispatch
is via the win32com.client.constants object. In this
case, the constant you want is OLECMDID_SAVEAS which...


import win32com.client

IE = "InternetExplorer.Application"
ie = win32com.client.gencache.EnsureDispatch (IE)

print win32com.client.constants.OLECMDID_SAVEAS 


Ok, thanks! Looks like these are the names to use instead:

IE.ExecWB(
  constants.OLECMDID_SAVEAS,
  constants.OLECMDEXECOPT_DONTPROMPTUSER,
  filename,
  None)

Altough the ...DONTPROMPTUSER option doesn't work - the Save As dialog  
always appears. Some kind of permission or safety measure, I presume.


My original intent was to save the file using the .mht format, but that  
format is not listed on the Save As dialog. I'll investigate using  
IMessage.CreateMHTMLBody but that's a different topic.


--
Gabriel Genellina

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


[python-win32] Internet Explorer constants

2008-09-05 Thread Gabriel Genellina

Hello

I want to control Internet Explorer. This is what I have so far:

import win32com.client
from win32com.client.gencache import EnsureDispatch
url = "..."
IE = EnsureDispatch("InternetExplorer.Application")
IE.Navigate(url)
IE.Visible = 1

It works fine and shows the requested page. Now I want to use the "Save  
As" command. Looks like I should call the
IWebBrowser2.ExecWB method, passing IDM_SAVEAS as the command and  
MSOCMDEXECOPT_DONTPROMPTUSER in the options. But I don't know how to  
obtain the value for such constants... I could dig into the C header files  
looking for them, but is there some other way?


The ExecWB method is documented here  
http://msdn.microsoft.com/en-us/library/aa752117(VS.85).aspx


--
Gabriel Genellina

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


Re: [python-win32] help with parsing email

2008-08-18 Thread Gabriel Genellina
En Mon, 18 Aug 2008 12:24:07 -0300, Ahmed, Shakir <[EMAIL PROTECTED]> escribió:

> Thanks everyone who tried to help me to parse incoming email from an exchange 
> server:
>
> Now, I am getting following error; I am not sure where I am doing wrong. I 
> appreciate any help how to resolve this error and extract emails from an 
> exchange server.
>
>
> First I tried:
>>>> mailserver = 'EXCHVS01.my.org'
>>>> mailuser = 'myname'
>>>> mailpasswd = 'mypass'
>>>> mailserver = poplib.POP3(mailserver)
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "C:\Python24\lib\poplib.py", line 96, in __init__
> raise socket.error, msg
> error: (10061, 'Connection refused')

The code looks right - this isn't a Python problem. Ask your administrator, or 
look into your Outlook configuration and try to reproduce exactly those 
settings, including server name and port.

>>>> mailserver = 'pop.EXCHVS01.ad.my.org'
>>>> mailuser = '[EMAIL PROTECTED]'
>>>> mailpasswd = 'mypass'
>>>> mailserver = poplib.POP3(mailserver)
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "C:\Python24\lib\poplib.py", line 84, in __init__
> for res in socket.getaddrinfo(self.host, self.port, 0, 
> socket.SOCK_STREAM):
> gaierror: (11001, 'getaddrinfo failed')

Probably pop.EXCHVS01.ad.my.org doesn't exist.

-- 
Gabriel Genellina

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


Re: [python-win32] help with parsing email

2008-08-18 Thread Gabriel Genellina
En Mon, 18 Aug 2008 12:24:07 -0300, Ahmed, Shakir <[EMAIL PROTECTED]> escribió:

> Thanks everyone who tried to help me to parse incoming email from an exchange 
> server:
>
> Now, I am getting following error; I am not sure where I am doing wrong. I 
> appreciate any help how to resolve this error and extract emails from an 
> exchange server.
>
>
> First I tried:
>>>> mailserver = 'EXCHVS01.my.org'
>>>> mailuser = 'myname'
>>>> mailpasswd = 'mypass'
>>>> mailserver = poplib.POP3(mailserver)
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "C:\Python24\lib\poplib.py", line 96, in __init__
> raise socket.error, msg
> error: (10061, 'Connection refused')

The code looks right - this isn't a Python problem. Ask your administrator, or 
look into your Outlook configuration and try to reproduce exactly those 
settings, including server name and port.

>>>> mailserver = 'pop.EXCHVS01.ad.my.org'
>>>> mailuser = '[EMAIL PROTECTED]'
>>>> mailpasswd = 'mypass'
>>>> mailserver = poplib.POP3(mailserver)
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "C:\Python24\lib\poplib.py", line 84, in __init__
> for res in socket.getaddrinfo(self.host, self.port, 0, 
> socket.SOCK_STREAM):
> gaierror: (11001, 'getaddrinfo failed')

Probably pop.EXCHVS01.ad.my.org doesn't exist.

-- 
Gabriel Genellina

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


Re: [python-win32] help with parsing email

2008-08-18 Thread Gabriel Genellina
En Thu, 14 Aug 2008 12:50:57 -0300, Ahmed, Shakir <[EMAIL PROTECTED]> escribió:

> I need to grab/parse numeric numbers such as app number from incoming
> emails stored in Microsoft Outlook (Microsoft Exchange server) with
> specified subject line.
>
> The email body is like this
>
> myregion ; tst ; 11-Aug-2008
>
> http://my.xyz.com//content/ifs/apps/myDocFolder/NoticeOfapplication/080612-21_test_337683.pdf
>
> I need to extract 080612-21_ number from above line from incoming
> emails.

I can't help with the part dealing with Outlook - but once you retrieved the 
email body, it's easy:

import re
re_number = re.compile(r"NoticeOfapplication/([0-9-_]+)")
match = re_number.search(body)
if match:
  print match.group(1)

(this matches any numbers plus "-" and "_" after the words NoticeOfapplication 
written exactly that way)

-- 
Gabriel Genellina

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


Re: [python-win32] COM works from IDLE but not when file executed from Windows Explorer

2007-03-14 Thread Gabriel Genellina
En Wed, 14 Mar 2007 13:41:17 -0300, Tim Roberts <[EMAIL PROTECTED]> escribió:

>> if __name__ == "__main__":
>> mp = Dispatch("WMPlayer.OCX")
>> tune = mp.newMedia('my_file.mp3')
>> mp.currentPlaylist.appendItem(tune)
>> mp.controls.play()
>> raw_input("Press Enter to stop playing")
>> mp.controls.stop()
>
> My guess is that you aren't in the same directory, so that "my_file.mp3"
> is not found.  Explorer might be setting the starting directory to the
> directory that contains python.exe (since that's what it is really
> executing) instead of the directory with your script.
>
> You might try providing the full path to the file, instead of just a
> relative path.

In addition, you may obtain the directory where your script resides using:

import os
print os.path.dirname(os.path.abspath(__file__))

(I suggest computing that early on your program, because if the current  
directory changes, abspath will give a wrong result)

-- 
Gabriel Genellina

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


Re: [python-win32] win32gui.GetOpenFileName()

2007-03-06 Thread Gabriel Genellina
En Mon, 05 Mar 2007 15:41:09 -0300, Tony Cappellini <[EMAIL PROTECTED]>  
escribió:

>> Is there a way I can select multiple files with either of the above
>> mentioned calls?
>> (pressing Control doesn't work)
>
>>> Pass win32con.OFN_ALLOWMULTISELECT|win32con.OFN_EXPLORER
>>> in the Flags to enable this.
>
> Thanks Roger, where did you find this information?

Look at the Microsoft site, MSDN, the primary source of information.
Many win32xxx modules are just a thin wrapper around the related Windows  
functions.
In this case, see http://msdn2.microsoft.com/en-us/library/ms646839.aspx

-- 
Gabriel Genellina

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


Re: [python-win32] py2exe all of it

2007-02-13 Thread Gabriel Genellina
En Tue, 13 Feb 2007 16:42:56 -0300, Tim Roberts <[EMAIL PROTECTED]> escribió:

> So, you could just zip up your \Python24 directory from home, export a
> few keys from the registry, then unzip the zip and import the registry
> files on your machine at work.  You would have done exactly what the
> installer did, and have a fully functional Python installation.

...just to find out that you missed the python2?.dll file that gets copied  
on windows\system32

> But what is the point?  The Python installer is just an executable.  If
> you can run a py2exe executable, why can't you run the Python installer
> executable?

I don't know what's exactly the OP's problem, but in general, asking a  
user to install Python first, then wxPython, then pyOpenGL, and only then  
the desired application may be too much. py2exe is a nice way to package  
all of them.

-- 
Gabriel Genellina

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


Re: [python-win32] how to generate an IPersistStream object?

2007-01-29 Thread Gabriel Genellina

At Monday 29/1/2007 07:43, Leo Jay wrote:


i need to pass an IPersistStream object to a COM function,
and i find a type named PyIPersistStream in the manual of pywin32.

but i don't know how to generate a PyIPersistStream object and pass it
to the function.
anyone could help me?


I've never implemented that interfase myself, but usually you only 
have to add two class attributes:  _com_interfaces_ and
_public_methods_, and implement the needed methods. You should refer 
to the Microsoft documentation on the exact semantics of each method.



--
Gabriel Genellina
Softlab SRL 







__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 

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


Re: [python-win32] Launch process

2007-01-24 Thread Gabriel Genellina

At Wednesday 24/1/2007 05:40, le dahut wrote:


What's the best way to launch a process and waiting for its exit code ?
I'm looking for something that can take win32con.SW_HIDE as argument
(os.spawnv don't).


CreateProcess and then WaitForSingleEvent on the process handle. 
Remember to close the thread and process handles when not needed.



--
Gabriel Genellina
Softlab SRL 







__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 

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


Re: [python-win32] PyWin32 - PostMessage return value

2007-01-22 Thread Gabriel Genellina

At Sunday 21/1/2007 07:56, jbd wrote:


> But since you're already using messages, maybe the easiest way is
> making the target application broadcast a message telling "I'm ready
> now", and when the caller sees it, it knows it can post the message.
> Use RegisterWindowMessage on both applications, with the same name,
> to obtain a unique message identifier.
> Use HWND_BROADCAST as the first argument to PostMessage to broadcast
> it to all top level windows.

Ok. Thanks for the tip. The fact is really don't know when the target
application is really ready. I'll have to spy it on Monday =)
Is there way to detect that a entry in a menu is not activated ?


Ouch, does that mean that you are not in control of the target 
application? If not, most of these suggestions are not very useful 
since they require to modify the app.
To detect if a menu is enabled or not, you could use GetMenuState, 
but I'm not sure if that helps you at all...



--
Gabriel Genellina
Softlab SRL 







__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 

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


Re: [python-win32] PyWin32 - PostMessage return value

2007-01-20 Thread Gabriel Genellina

At Saturday 20/1/2007 21:35, jbd wrote:


I create a process via the CreateProcess function, and i wait using
WaitForInputIdle to be sure that the process is in ready state, it works
well (ie: the process is launched).


Check also whether WaitForInputIdle returns 0, and not WAIT_TIMEOUT 
(meaning that the process is not ready yet)



I send a message via PostMessage and
i'd like to know if the command had been correctly processed, and i don't
know how to do it.

But, although the application is in ready state, some hardware
initialization has to be done and seems not to be accomplished when
WaitForInputIdle returns. The message i posted using PostMessage is
correctly processed, but nothing appends since the ressource i need were
not yet initialized. If i introduce a time.sleep(2) between the
WaitForInputIdle and the PostMessage function, everything is working fine.


And the sleep isn't an acceptable solution, I presume.
You can use some form of interprocess communication; coming from a 
Unix environment you may know some of them, like pipes,  queues. Or a 
synchornization mechanism like a semaphore.
But since you're already using messages, maybe the easiest way is 
making the target application broadcast a message telling "I'm ready 
now", and when the caller sees it, it knows it can post the message.
Use RegisterWindowMessage on both applications, with the same name, 
to obtain a unique message identifier.
Use HWND_BROADCAST as the first argument to PostMessage to broadcast 
it to all top level windows.



On the msdn site, the PostMessage function returns a BOOL, but since this
is an asynchrone function, the return value just means that the message
has been posted without problem. Am i correct ? By the way, how do i check
for this return value with pywin32 ? All message related function seems to
return None.


Yes, it appears that you cannot retrieve the return value of 
PostMessage. Anyway it won't tell you much.
The caller can communicate its own window handle to the target 
application, using the wParam or lParam arguments when it sends some 
message. This way, the target application can reply to the caller 
when he has completed processing the operation (either ok or with an error).



--
Gabriel Genellina
Softlab SRL 







__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 

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


Re: [python-win32] Displaying contents of a file using PyWin

2006-12-21 Thread Gabriel Genellina

At Friday 22/12/2006 00:28, Mark Hammond wrote:

> >import win32ui

> >from pywin.mfc import docview
> >
> >t = docview.DocTemplate()
> >t.OpenDocumentFile("d:/temp/music.log", True)
> >
> >This caused windows to close PythonWin.
>
> This appears to be a problem with pywin32.
> Using release 209 for Python 2.4 I get an Access Violation.

It was attempting to set a Python error without the GIL held.  I've fixed
that - it now results in:

win32ui: PyCDocument::OnOpenDocument handler does not exist.
>>>


Oh, thanks!


Using:

>>> t.OpenDocumentFile(None)

Opens a document - I'm afraid I can't recall the MFC semantics here at the
moment.


I think one should inherit from docview.Document and write the 
OnOpenDocument handle, but I'm not sure either. I hope the OP has 
enough info to continue from here.



> Also I've noticed that this idiom:
>
> try:
>  win32ui.GetApp().RemoveDocTemplate(template)
> except NameError:
>  # haven't run this before - that's ok
>  pass
>
> doesn't work anymore because RemoveDocTemplate raises a different
> exception now.

I can't recall any change I made that would account for that.  I'm assuming
that the NameError comes from 'template' which is yet to be assigned - but
in that case RemoveDocTemplate should not be called as the NameError happens
before.  I don't recall (and grep doesn't show) that pythonwin ever raises
this exception.


It is used in 4 scripts inside pythonwin\pywin\framework.
And can be found on your own book, chapter 20...


--
Gabriel Genellina
Softlab SRL 







__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 

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


Re: [python-win32] Displaying contents of a file using PyWin

2006-12-21 Thread Gabriel Genellina

[Forwarded from [EMAIL PROTECTED]

At Thursday 21/12/2006 13:51, MiguelS wrote:


import win32ui
from pywin.mfc import docview

t = docview.DocTemplate()
t.OpenDocumentFile("d:/temp/music.log", True)

This caused windows to close PythonWin.


This appears to be a problem with pywin32.
Using release 209 for Python 2.4 I get an Access Violation.

Also I've noticed that this idiom:

try:
win32ui.GetApp().RemoveDocTemplate(template)
except NameError:
# haven't run this before - that's ok
pass

doesn't work anymore because RemoveDocTemplate raises a different 
exception now.



--
Gabriel Genellina
Softlab SRL 







__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 

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


Re: [python-win32] USB Power Off from Python

2006-12-14 Thread Gabriel Genellina

At Wednesday 13/12/2006 23:48, James Matthews wrote:


However we see that you can unmount it ans sometimes it will be turned off


I think it's some kind of "soft" turn off; you send the device a 
command to shutdown self. The +5V stay there.



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] screen capture and win32gui.GetDesktopWindow()

2006-12-06 Thread Gabriel Genellina

At Wednesday 6/12/2006 21:32, Ray Schumacher wrote:


I've been mulling screen capture code. I tried PIL's
ImageGrab().grab() (with pymedia) but find PIL's method to be pretty
slow, ~4grabs per second max with no other processes.
pymedia is pretty quick once I hand it the data.

There has to be another way to get a copy or buffer() of the screen
DC's data that is faster (I hope).


Yes, but I doubt you can get faster without writting a specific program.
- watch for invalidate and paint events so you just grab the screen 
areas that actually have changed.
- use a "pseudo video card" driver to watch for drawing primitives as 
TightVNC does (or is it some other VNC clone?)



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Compiling a Python Windows application

2006-11-29 Thread Gabriel Genellina

At Saturday 25/11/2006 20:51, James Matthews wrote:


Try pypy


In what way would PyPy help?


> Thanks Tim for your answer, what about reaching Python from within Word?
> What I would like is a new menu in Word, clicking on a menu item 
would bring

> up a dialog box where the user sets some parameters , clicking OK is to
> start the Python app.   The open Word document and the parameters 
need to be

> made available to the app.>





--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Suggested change to document.py

2006-11-02 Thread Gabriel Genellina

At Thursday 2/11/2006 18:52, Gerard Brunick wrote:


> ...I run windows XP, and I keep
> python scripts all over my drive.  Rather than adding all sorts of
> subdirectory's to my path, i create
> hardlinks to the scripts that I need to use from the command line in a
> single \bin directory.


I don't even knew hard links existed on Windows! Thanks...


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32pdh problem on Windows Server 2003

2006-10-31 Thread Gabriel Genellina

At Tuesday 31/10/2006 19:32, Mark Hammond wrote:


> Also, the names are localized, so if you have a non-english version
> of Windows, you have to look up what are the translated names.
> (I don't know how to obtain a "neutral" name usable everywhere)

Although it is far from perfect, the find_pdh_counter_localized_name()
function in win32pdhutil does try to handle some of these localization
issues.


Good!


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32pdh problem on Windows Server 2003

2006-10-31 Thread Gabriel Genellina

At Tuesday 31/10/2006 14:48, Tim Roberts wrote:


>I am trying to get processor performance stats using the pywin32pdh and
>pywin32pdhutil modules. It works fine on Windows 2000 and Windows XP, but
>not on Windows server 2003(SP1). I am using Python 2.4.3 and
>pywin32-210.win32-py2.4.
>
Windows error messages are better handled in hex.  -1073738810 is
CBC6, and a quick Google on that shows it is basically "performance
counter not found".

You can use "perfmon" to explore what counters are really present.
Perhaps the "privileged time" counter was renamed in 2003.  In your
particular case:


Also, the names are localized, so if you have a non-english version 
of Windows, you have to look up what are the translated names.

(I don't know how to obtain a "neutral" name usable everywhere)


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] disable mouse/keyboard input

2006-10-20 Thread Gabriel Genellina

At Friday 20/10/2006 12:51, Axiom X11 wrote:

I'd like to be able to ignore all user input while a vidoe is 
playing, and then be able to allow the user to click things.


For the question as posted, the answer is simple: just ignore all input!
You should be more specific. Do you want to disable mouse and 
keyboard globally, for all the system? Just for your application? Is 
this a GUI app? which framework have you used to build the GUI?



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Calling a subprocess with spaces in the path

2006-10-18 Thread Gabriel Genellina

At Wednesday 18/10/2006 17:43, Axiom X11 wrote:

I am trying to run a command as a subprocess, and it keeps choking 
on the spaces.



import subprocess


s = 'vlc  "C:\\Documents and 
Settings\\bk\\Documents\\Resources\\WORKINPR2001.mpeg" 
:sout=\#duplicate{dst=display,dst=std{access=udp,mux=ts,dst=<http://224.0.0.0:1234>224.0.0.0:1234 
}} 
:sout=#duplicate{dst=display,dst=std{access=udp,mux=ts,dst=<http://224.0.0.0:1234>224.0.0.0:1234}}'

print s
process = subprocess.Popen([s], shell=True)


Try omitting the shell=True argument.


Is there something I am missing about spaces in the path on windows?


Yes, type cmd /? and see the rather crazy rules about quotes on the shell...


(BTW if I use

f=os.popen(s, 'w')

It works fine, but that leaves me with a blocking call, and I really 
want a subprocess)


This way you are not running your comand thru the shell.


--
Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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


Re: [python-win32] MS Word

2006-10-03 Thread Gabriel Genellina

At Tuesday 3/10/2006 12:33, Michael S wrote:


Does anyone have experience in appending multiple word
file into one big file? I have a directory full of
word files and I want to make one file out of all of
them.
I tried to google it, in order at least to see it how
it's done in VBA, but haven't found any good examples.


I usually create a macro for doing what I want, and then I inspect 
the VBA code to see how it's done.



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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


Re: [python-win32] plot function

2006-09-25 Thread Gabriel Genellina

At Sunday 24/9/2006 02:55, [EMAIL PROTECTED] wrote:


Does Python have a library providing a plot function similiar to matlab
that will plot a math plot or just some data points in a pop-up window


pychart may be useful



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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


Re: [python-win32] Fatal Error

2006-09-19 Thread Gabriel Genellina

At Tuesday 19/9/2006 16:09, Ahmed, Shakir wrote:


I am running a script and getting the following error, any idea is
highly appreciated.

The script is mainly a loop work for sixteen time and raises the error
on 10th cycle.


NO free BITSYS Channels (BITCHN)


This is not a Python error, it's generated by your script...



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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


Re: [python-win32] IMPORT path

2006-09-12 Thread Gabriel Genellina

At Monday 11/9/2006 23:49, Christian Menge wrote:

I have a simple script that will create a window and print "Hello 
World". What I want to do is import this script into another script 
which control may program. The problem I'm having is with the Import 
path. When I move my "Hello World" script away from the development 
directories the path gets lost and Python can not find the modules.


Reading the Python tutorial may help 
http://docs.python.org/tut/tut.html, specially about packages.




Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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


Re: [python-win32] Shape file field update problem

2006-08-25 Thread Gabriel Genellina

At Friday 25/8/2006 17:49, Ahmed, Shakir wrote:


I generated this python script from Arc GIS Model, tried to run from
python win but getting error. I am trying to update a text field from a
date filed data. Any help is highly appreciated.


# Calculating the fields to the date as a text field
gp.calculatefield_management("br_er_primary.shp", "LEGAL_CDT",
"[APP_NO]")
#the above line works fine
gp.calculatefield_management("br_er_primary.shp", "FINAL_CDT",
"FORMAT([final_acti],'mm/dd/')")
# this above line is not working getting the following error.

  File "", line 2, in
calculatefield_management
com_error: (-2147467259, 'Unspecified error', None, None)


Since the first call to calculatefield_management succeeds with the 
same argument types, I think this is not related to Python nor the 
Pythonwin wrapper.

Check the docs for that function or contact the vendor.


Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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


Re: [python-win32] win32ui.CreateFileDialog error

2006-08-09 Thread Gabriel Genellina

At Wednesday 9/8/2006 17:41, Tim Roberts wrote:


> Can anyone explain to me why the following code will return a list if
> I select 12 files but will return None if I select 13?


It's an ugly but well-known limitation: the buffer passed to
CreateFileDialog is big, but not big enough.  When you select more files
than will fit, the API returns an error, and the wrapper returns that
error instead of reallocating and retrying.


But how can one detect that?
DoModal() returns 2 (IDCANCEL) in this case, how can be distinguished 
from the user pressing the Cancel button?




Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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


Re: [python-win32] sleep() for less than .001s?

2006-08-04 Thread Gabriel Genellina

At Thursday 3/8/2006 22:45, Ray Schumacher wrote:

I have been trying to use sleep() and 
kernel32.QueryPerformanceCounter together; I want to delay until a 
particular tick without trying up the CPU badly.
However, while time.sleep(.001) relieves the CPU, it has wildly 
unpredictable delay, and sleep(.0001) delays almost nothing at all! 
(I'm watching the parallel port on a scope).
If I use a while and just count ticks with 
QueryPerformanceCounter(), it is very stable and as desired - but it 
uses 100% CPU.


I'm not sure if this really works, but you could try:
- Raise your thread/process's priority using SetPriorityClass or 
SetThreadPriority. This is to minimize the (unpredictable) delay of sleep()

- Keep your qPC loop, but insert a sleep(0) call, this would free the CPU.



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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


Re: [python-win32] testing ADSI GUID buffer objects

2006-07-26 Thread Gabriel Genellina

At Wednesday 26/7/2006 19:44, David Primmer wrote:


I am trying to write a unit test for a function that accepts a buffer
   object. As far as I can tell, buffer's cannot be directly represented
in code. How do I create the object for the test? (The buffer object comes
through ADSI in an Active Directory query of the user GUID property).
If I print the GUID property, it prints a Unicode encoded string of the
byte stream: u'8108fd1ac12c0d42924355c8d9987f19'. I don't believe this
is the 'native' representation. The function I'm trying to test
translates it to MS's hex format: '{38303138-6466-6131-6331-326330643432}'

Any danger using this unicode format?


I think you are mixing many things.

You *can* create a buffer object, using the built-in function buffer():

>>> x=buffer('hello')
>>> print x[0]
h
>>> print x[4]
o
>>> print x[5]
Traceback (most recent call last):
  File "", line 1, in ?
IndexError: buffer index out of range

A GUID is always 16 bytes length. Your Unicode string is 32 bytes 
length; apparently it is the hex representation (two hex chars per 
byte). If you feed the function with that string, it interprets the 
first 16 bytes only, *each* hex number as a byte: 38h='8', 30h='0', 
31h='1'...64h='d' 34h='4' 32h='2'


Can you post an example showing the expected interfase?



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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


Re: [python-win32] [Errno 2] No such file or directory:

2006-07-26 Thread Gabriel Genellina

At Wednesday 26/7/2006 16:33, Ahmed, Shakir wrote:


I am trying to change the file permission for all of the files in a
directory but getting errno 2, the code is as follows, any help is
highly appreciated. I am using pythonwin version 2.1



permission.py

for fl in os.listdir("V:\\data\\tst\\mdb"):


import os


def unicode_test(fl):
try:
f = file(fl, 'w')
f.close()
except IOError, e:
print e
return
try:
os.chmod(fl, -0777)
except OSError, e:
print e



The error I am getting :

>>> [Errno 2] No such file or directory: 'gend_taskstatus.mdb'
[Errno 2] No such file or directory: 'str.mdb'


os.listdir() returns the names *without* path. Use os.path.join to 
join path+name.
-0777 looks like Unix permission bits (negative?), but a path with \\ 
is strange...

The enclosed function unicode_test is useless.
And, the import statement usually is located at the top of the module.



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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


Re: [python-win32] starnge error at startup

2006-07-20 Thread Gabriel Genellina

At Thursday 20/7/2006 12:20, Robin Becker wrote:


I get the following error when starting pythonwin on a particular script. I
would like to be able to debug the script, but pythonwin won't seem 
to open it.




 import tokenize
   File "C:\Python\lib\tokenize.py", line 38, in ?
 COMMENT = N_TOKENS
exceptions.NameError: name 'N_TOKENS' is not defined


Looking at tokenize.py, it imports all from token.py
Look at your token.py. There is a notice at the top of the file, it 
should have been built automatically, but perhaps something failed.




Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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


Re: [python-win32] Try to got short path for files - but got error...

2006-05-29 Thread Gabriel Genellina
At Monday 29/5/2006 08:01, DurumDara wrote:

>Ok, I found the error in FSUM, but the question is remaining in opened
>state,
>because every of the solutions are little complex, chaotic, or not
>speeding up
>my code.
>The main question - the parameterizing of subprocess (wroted by another
>developer)
>with unicode filenames, and the short path "misery"...

I've checked the FSUM homepage and it says:

- FSUM is *not* a DOS program, but a console program for Windows 
95/98/Me/NT/2000/XP. So in principle you are not limited to short 
file names, you could pass it the LONG filename (perhaps enclosed in 
double quotes).

- FSUM is just a wrapper around the QuickHash library. They provide a 
TypeLibrary and a standalone DLL. You should be able to use win32com 
or ctypes to access them.



Gabriel Genellina
Softlab SRL 





___ 
1GB gratis, Antivirus y Antispam 
Correo Yahoo!, el mejor correo web del mundo 
http://correo.yahoo.com.ar 

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


Re: [python-win32] how to only accept local computer requests

2006-05-08 Thread Gabriel Genellina

At Monday 8/5/2006 10:38, Michael Li wrote:


I have a python server with twisted framework running
24x7. I want to have a config file to setup accepting local
computer requests or remote computer requests.
If the config file exists, it only accepts local computer
request, does not accept requests from other computers.
If the config file does not exist, it accepts requests
from any computers.
Is there any easy way to do it ?


To see if the config file exists, use os.path.isfile(filename)
To enable only local connections to your server, see the Twisted documentation.



Gabriel Genellina
Softlab SRL 




_ 
Horóscopos, Salud y belleza, Chistes, Consejos de amor: 
el contenido más divertido para tu celular está en Yahoo! Móvil. 
Obtenelo en http://movil.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] killProcName.py not working for processes under user SYSTEM

2006-05-02 Thread Gabriel Genellina
At Tuesday 2/5/2006 16:50, Gerrat Rickert wrote:

>I’m logged in as an administrator on my computer 
>(actually a domain admin) and I can’t seem to 
>get the killProcName.py program (that came with 
>Mark Hammond’s python extensions) to kill ANY 
>process owned by ‘SYSTEM’ (I’ve tried a few – eg. ‘iPodService’, ‘Apache’)
>
>I can open the windows task manager, right-click 
>the process and do an ‘End Process’, and that 
>kills it just fine, but I just get an error when I try it from Python:
>(5, ‘OpenProcess’, ‘Access is denied.’)

Thats because you, even as administrator, do not 
have enough privilege to grab the process handle. 
This is a common scenario for services running as Local System.
See http://support.microsoft.com/kb/197155/en-us



Gabriel Genellina
Softlab SRL 

__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] select.poll()

2006-05-02 Thread Gabriel Genellina

At Sunday 30/4/2006 05:04, Vahid Noroozi wrote:

i have a python program that use sellect.poll() to control some 
sockets but in windows we doesn't have sellect.poll()


You can use select.select() which is available on Windows too. 
asyncore.poll() is an example.



also how can i find information about WaitForMultipleEvent


It's a Windows function, search msdn.microsoft.com. But you dont need 
it if you only have to poll sockets.




Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] select.poll()

2006-04-24 Thread Gabriel Genellina

At Saturday 22/4/2006 09:56, Vahid Noroozi wrote:


in windows python select module doesn't suppport poll()
i wanted to know if it is possible to implement poll function by 
using select.select() function in windows.


What do you want to do?
select.select() only accepts sockets in Windows, not any file.
WaitForMultipleEvent might be useful but depends on what you need.



Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] BSTR

2006-04-14 Thread Gabriel Genellina
> P.S.: Gabriel, yes, I have put Sleep(1) now, even
> though it
> worked without the parenthesis too, even thought it
> shouldn't,
> right?

Well, it "worked" in the sense that it gave no errors
because time.sleep is a valid Python expression, but
it has not the desired effect.
It's a common pitfall, specially if you come from VB,
that's why I menction it here.
Like, in C: if (a=b) {...} which "works" but usually
is not the intended behavior.



Gabriel Genellina
Softlab SRL

__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] BSTR

2006-04-14 Thread Gabriel Genellina
Some remarks (altough not directly related to your
current problem):

> >while CCDCamera.ImageReady == False:
> > time.sleep

Should be time.sleep(1) or something. Remember that in
Python you always need to use () to call a function.

>if CCDCamera.LinkEnabled == False:

It's not a good idea to compare strictly against
True/False; for True just remove the comparison; for
False use the "not" operator:
>if not CCDCamera.LinkEnabled:

>>> def always_true():
...   return 3 # any number!=0 is considered true
...
>>> if always_true(): print 'Ok'
... else: print 'Wrong!'
...
Ok
>>> if always_true()==True: print 'Ok'
... else: print 'Wrong!'
...
Wrong!
>>>


Gabriel Genellina
Softlab SRL

__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] mciSendCommand from win32 ???

2005-11-28 Thread Gabriel Genellina
At Monday 28/11/2005 09:55, [EMAIL PROTECTED] wrote:

>I want to call mciSendCommand to record a music in Windows.
>I want to do same thing like in this code (Delphi):
>1. Can I do it ?
>2. If not, what is the solution (I haven't Delphi... I have only
>freeware things)

Try http://www.freepascal.org/ and Lazarus.
Or, there is a small DirectSound example, see the PyWin32 help.


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] PythonWin - Start in script's directory

2005-11-22 Thread Gabriel Genellina
At Tuesday 22/11/2005 15:14, Gregory Piñero wrote:

>And then is there a way to make Pythonwin run that automatically or do I 
>have to add that to my script:
>os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))

I'm not sure what Pythonwin has to do with this exactly...
You always can run a process with a "startup directory" different from 
where it is located. If you want to ensure that they are the same, you must 
do something like above. Or create a shortcut icon.


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] PythonWin - Start in script's directory

2005-11-22 Thread Gabriel Genellina
At Tuesday 22/11/2005 14:22, Gregory Piñero wrote:

>I'm not sure how to phrase this question.  How can I make PythonWin have 
>it's current directory automatically set to the same directory as my script?
>
>For example I want the statement:
>file('test.txt','w')
>to make a file in the same directory as my script, instead of wherever 
>PythonWin wants to put it by default, I think somewhere in C:\Python?

os.path.dirname(os.path.abspath(sys.argv[0])) returns the directory where 
your script is.
You can make it the current dir using os.chdir


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] COM object has been seperated from its underlying RCW cannot be used.

2005-11-09 Thread Gabriel Genellina
At Wednesday 9/11/2005 03:42, Amit Upadhyay wrote:

>I am getting a crash with message: "COM object has been seperated from its 
>underlying RCW cannot be used.", when using a COM server written in 
>win32com and being accessed by .NET client. I have win2k-sp3 on that 
>machine, and its not very reproducable. I get no results on msdn about 
>this message, and can't locate any informaiton about how to solve it via 
>google either, just that it is somehow related to threading. Can anyone 
>tell me how to go about solving it?

Perhaps updating your .NET would help: 
http://support.microsoft.com/default.aspx?scid=kb;EN-US;818612
An explanation of the problem:
http://radio.weblogs.com/0105852/stories/2002/12/21/comInteropNotFundamentallyFlawedButHard.html


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] Bug in pythoncom.CoInitialize(Ex)

2005-11-09 Thread Gabriel Genellina
At Tuesday 8/11/2005 22:36, Mark Hammond wrote:

>What I propose is that I change CoInitialize() to ignore this specific
>RPC_E_CHANGED_MODE error.  My reasoning is that people calling
>CoInitialize() don't care about the threading model - all they want is to be
>able to use a COM object from their thread.  However, I think
>CoInitializeEx() should always raise an exception on error return, including
>for that specific error.  My reasoning is that people explicitly calling
>CoInitializeEx(thread_model) *do* care about the threading model, and may
>take great interest in the fact the thread has already been initialized
>differently.  If it is prepared to work in a different threading model, it
>just needs to catch the exception.

I think these are reasonable asumptions so it's unlikely you would break 
existing code. None mine, FWIW.


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] drag/move image from staticBitmap control?

2005-10-28 Thread Gabriel Genellina
At Friday 28/10/2005 17:05, James Hu wrote:

>I have an application to show bitmap image on one wx.staticBitmap control 
>area, I can display part of the image, or the whole image(detail is unclear),
>But I would like to use mouse to drag/move the image inside 
>thewx.staticBitmap control when only part image on the screen, just like 
>maps.google does,
>is it possible to do that?

A better place to ask would be the wxPython list


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] findwindow by its class name

2005-10-21 Thread Gabriel Genellina
At Friday 21/10/2005 16:26, you wrote:

>Thanks a lot! Yes, GetHandle() can return 'wxWindowClassNR', which is
>nice,
>but all wxPython apps return wxWindowClassNR as well, so when I Post
>Message, it goes to itself.

Application A can broadcast a private known message (using 
RegisterWindowMessage) including its own HWND; Application B handles it and 
replies to A with its own HWND.  After that, both apps know the other's 
HWND and can post messages.



Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] String weirdness on python 2.4 / windows

2005-10-19 Thread Gabriel Genellina
At Wednesday 19/10/2005 21:04, you wrote:

>I think you might be correct with the headers suggestion, that was
>going to be my next point of investigation.  I don't think the
>MIME type of image/bmp is acceptable to IE.

Should be image/vnd.microsoft.icon or image/x-icon, but NOT image/bmp
(icon files having different format than bmp files)


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] Control-C

2005-10-13 Thread Gabriel Genellina
At Thursday 13/10/2005 17:33, you wrote:

I've looked around, but I wasn't able to find anything about this
>issue.  I am writing an application that calls a separate windows
>application as a process.  That's not a problem, I can get it to run and
>do what it needs to do.  However, the normal way to stop the separate
>windows application is to hit CTRL-C.  That allows it to end and do
>finishing processes.  Is there a way to send a CTRL-C signal to a
>process?  I tried simply doing a TerminateProcess on the process, as
>suggested to me earlier, however, this doesn't allow the normal cleanup
>operations to do what they need to do.  Any help you might have would be
>greatly appreciated.

win32api.GenerateConsoleCtrlEvent

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/generateconsolectrlevent.asp


Gabriel Genellina
Softlab SRL  

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


Re: [python-win32] Weird ADSI hang.

2005-10-06 Thread Gabriel Genellina
At Thursday 6/10/2005 00:51, you wrote:

>import win32com.client
>
>def recurse(objstr):
> for obj in win32com.client.GetObject(objstr):
> print "Digging into", obj.ADsPath, "class=" + obj.Class
> recurse(obj.ADsPath)
>
>print "At the start"
>print recurse("IIS://localhost/W3SVC")
>print "At the end"
>
>END CODE
>
>"At the end" does print and at that point it just hangs there.

Maybe it doesn't matter, but try removing the print statement on print 
recurse(...) since recurse() doesnt return anything

print "At the start"
recurse("IIS://localhost/W3SVC")
print "At the end"


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] create word document?

2005-10-05 Thread Gabriel Genellina
At Tuesday 4/10/2005 12:20, [EMAIL PROTECTED] wrote:

>A final approach would be to record a macro of what you trying to do and 
>then examine the code to find the appropriate objects, interfaces and methods.

I consider this the easiest way, specially when you don't know how the 
exposed objects work. Just record a macro doing whatever you want to do in 
Word and see the resulting code.


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] handling paths in windows services

2005-09-09 Thread Gabriel Genellina
At Friday 9/9/2005 11:08, you wrote:

>The 'svc.cfg' is on the the same directory that contains the python
>script, but its path is obviously not available to the windows
>service. Short of using absolute paths, what would be the correct way
>to handle this.

Try this:

import os,sys
print os.path.join(
 os.path.dirname(
   os.path.abspath(
 sys.argv[0])),
 'svc.cfg')



Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] Possibility of calling static functions using window/thread handles?

2005-08-23 Thread Gabriel Genellina
At Monday 22/8/2005 15:09, Kevin White wrote:

>I don't know much about Windows API programming, so this may be a 
>laughable question.  Is it possible to use the 
>win32process.CreateProcess() function to launch a program then somehow use 
>the returned window/thread handle to invoke a static method.  My guess is 
>that the process would have to somehow magically be converted back to its 
>native class/object and I don't know if that's really feasible.  Thoughts?

I don't believe you could do that without some form of inter process 
communication, like a named pipe, or DDE. (try the DDE demo)


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] win32 version

2005-07-27 Thread Gabriel Genellina
At Wednesday 27/7/2005 05:46, Neil Benn wrote:

>   If I have an installed instance of win32 et al, is there a way
>to get the version number that is installed on  a box (preferably
>without having to start python up - ie is it written in a text file
>somewhere in the install?).

You could enumerate the uninstall keys and see what "looks like" a Python 
installation...
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\pywin32-py2.3
(I hope there is a better way)


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] Task Scheduler

2005-07-19 Thread Gabriel Genellina
At Friday 15/7/2005 00:44, [EMAIL PROTECTED] wrote:

>Thank you, Roger, for pointing that out.  I tried the
>test sample and it did create the scheduler object as
>one would expect.
>
>However, same as the at.exe attempt I did from CLI,
>the object doesn't run when the time came.  I manually
>requested "Run" and the task runs fine (with the
>message dialog poping up).
>
>I retried several times by playing around with the
>settings (manually entering password and so forth) but
>nothing worked.
>
>Any clues?

Does the process depends on its startup directory?
Runs under any user account?
Needs any privilege?
Is interactive? (use /interactive)


Gabriel Genellina
Softlab SRL  

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


Re: [python-win32] list/kill processes on Win9x and NT+...

2005-07-12 Thread Gabriel Genellina
At Wednesday 13/7/2005 00:30, RayS wrote:

>Ah, now I just found after searching for "CreateToolhelp32Snapshot"
>http://sourceforge.net/mailarchive/message.php?msg_id=8291643
> >>Does anyone have a way to list/kill without the external process that 
> works in all 9x and XP?
> >
> >PDH will work for NT, 2000 and up. For Win95/98 you can enumerate 
> processes using ToolHelp32: http://support.microsoft.com/kb/q175030/

If you eventually craft a function for enumerating all processes which 
works on all platforms, would be nice if you could post it here...


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] list/kill processes on Win9x and NT+...

2005-07-12 Thread Gabriel Genellina
At Tuesday 12/7/2005 14:04, Ray Schumacher wrote:

>I had looked over the methods to list/kill processes on Win32, and could 
>not (yet) find a "pure" Python way to do it that works on 9x, since I 
>could not get win32pdhutil to work on 98.
>So, I combined subprocess.py and pv.exe from
>http://www.xmlsp.com/pview/PrcView.zip
>and wrote a quick app to kill unauthorized process and compiled with py2exe.
>
>Does anyone have a way to list/kill without the external process that 
>works in all 9x and XP?

PDH will work for NT, 2000 and up. For Win95/98 you can enumerate processes 
using ToolHelp32: http://support.microsoft.com/kb/q175030/


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] win32pipe and buffer size

2005-07-12 Thread Gabriel Genellina
At Tuesday 12/7/2005 13:09, Frank Guenther wrote:

>That is exactly the problem, but how can I get the text  which the 
>buffering client prints to the screen?
>
>The C++ Code looks like:
>
> printf ("1. Run Static  Tests contained in Sections 5  through 
> 9.\n");
> printf ("2. Run Dynamic Tests contained in Sections 10 through 
> 11.\n\n");
> printf ("Enter choice (1 or 2): ");
> scanf  ("%d", &nTestChoice);
>
>If I use the program manually the stdout is displayed on the screen.
>
>A solution would be to change the program, but I don't have the 
>possibility to change it.
>Is there an other way?

See the C FAQ on this topic: http://www.eskimo.com/~scs/C-faq/q12.4.html

If the OS is buffering the output, perhaps a call to FlushFileBuffers (on 
the other end of the pipe) would help.
But if the buffering is at the C run-time library, I'm afraid there is 
nothing you could do to flush the output without rewriting the code or 
hacking the RTL DLLs.

To disable buffering on stdout, put any of these calls at the very 
beginning of the program:
setbuf(stdout, NULL)
or: setvbuf(stdout, NULL, _IONBF, 0)


Gabriel Genellina
Softlab SRL  

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


Re: [python-win32] Unable to set an Excel chart's title through win32com : can you reproduce this problem ?

2005-06-28 Thread Gabriel Genellina
At Tuesday 28/6/2005 06:03, Capiez Fabrice wrote:

>chart.Location (Where=constants.xlLocationAsObject,
>Name=sheet.Name)
>try:
> chart.HasTitle = True
> chart.ChartTitle.Characters.Text ="title"
>
>The following produces:
>
>Excel failed with code -2146827864: OLE error 0x800a01a8
>No extended information
>
>The same error occurs if I try to set an axis title
>instead of the chart's title. It also occurs whether I
>first set chart.HasTitle to True or not. I

Error 800a01a8 is "Object required"
The error is triggered by the chart.HasTitle line, before setting the title 
text.
So I guessed, chart does not point to a valid object on that line.
Commenting out the previous line chart.Location(...) solved the problem.
I was unable to find documentation on the Location() method, but I guess 
that moving the chart to another sheet invalidates the object reference 
(which may be tied to its current location...)


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] Forcing win32com.client.dispatch to start up a fresh Excel

2005-06-21 Thread Gabriel Genellina
At Tuesday 21/6/2005 17:27, [EMAIL PROTECTED] wrote:

>Soon I'll be doing the more involved thing, with a farm of one. I'll 
>certainly let y'all know if it doesn't work!

Might be interesting to know if it *does* work too!


Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] word

2005-04-15 Thread Gabriel Genellina
At Thursday 14/4/2005 15:33, ryan pinto wrote:
wordApp.CommandBars.FindControl(Id=23).Execute
Remember that, in Python, you must use () to invoke a function, even if it 
has no arguments.

Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] Python and Hardwaremanagement

2005-04-12 Thread Gabriel Genellina
At Tuesday 12/4/2005 18:45, daniel(1und1) wrote:
I'm new to Python. Till today I have only written two small programs and 
tried out some window object functions. Therefore I apologize for any 
"nonsense". My problem is how to take control with Python of my hardware 
(keyboard, monitor, etc.). I have downloaded the win32com.client but could 
no find any commands/modules related to such issues. Microsoft offer only 
Python programs which produce information about the drivers and properties 
but not a way to manage them. Any help or suggestions?
That depends on what you mean by "take control of my hardware".
Unless you're doing very specific things, just let the OS take control of 
your hardware...
What do you want to do?

Gabriel Genellina
Softlab SRL 

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


Re: [python-win32] How Can I exec() a statement?

2005-04-11 Thread Gabriel Genellina


At Thursday 7/4/2005 10:53, * William wrote:
Please stay in the list - and even move to the Python-list as those
topics are not specific to Windows.
Exactly what I want to do -- for
the enquiry about "what" I want to do, it is best to use as an
example.


#4

b = 2

print "Before:"

print "   a = %s" % str( a )

print "   b = %s" % str( b )# 

codeLine = 'a = b + 6'

exec codeLine  in globals(), locals()

#

print "After:"

print "   a = %s"% str( a )

print "   b = %s" % str( b )


... of course the notion, is a little more elaborate though still in
its infancy.  I am thinking it will be a basic verification tool or
even an aid for debugging.  By chopping up the line, I can print the
value of all the symbols in the codeLine.  The 'trick' is going to
be Not calling functions twice (in case there is a side-effect). 

So you are going to write your own debugger? I'd try the existing ones
first :)
It's hard to recognize automatically the relevant symbols, even using the
tokenize/token/parser modules.
Unles you restrict yourself to very simple expressions with no objects,
no attribute selection, no subscripting...

a[round(math.sin(2*math.pi*obj.current_angle/180.0+obj.phase))]*x+config['offset']
There is a lot of names there: a,round,math,sin,pi,obj... Some just make
sense in the context of another (by example, there is no phase variable,
it's an attribute of obj). Maybe current_angle is a property and getting
its value actually means invoking a function wich reads a
sensor...
 For example, I'd like a
way to get the symbol name for variable a above.  Is there a
function like "nameOF( a )"?
Maybe a Python hacker guru could say something, but AFAIK, once you get
inside the function nameOF( a ), there is no way to tell where its
argument came from. In the following example, I think there is no way to
distinguish inside f if it was called with a or b as an argument, since
both are simply names pointing to the same object:
>>> def f(x):
...   print x, id(x)
...
>>>
>>> a = [1,2,3]
>>> b = a
>>> a
[1, 2, 3]
>>> b
[1, 2, 3]
>>> id(a)
6999440
>>> id(b)
6999440
>>> f(a)
[1, 2, 3] 6999440
>>> f(b)
[1, 2, 3] 6999440
>>>

Gabriel Genellina
Softlab SRL

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


Re: [python-win32] How Can I exec() a statement?

2005-04-06 Thread Gabriel Genellina
At Wednesday 6/4/2005 14:57, * William wrote:
HOW -- or, is it possible -- to execute the an assignment statement from a 
string?
Try 'exec'
>>> a=1
>>> b=2
>>> exec 'a=b+3'
>>> a
5
Gabriel Genellina
Softlab SRL 

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


[python-win32] Changing desktop color (Chris Stromberger)

2005-02-08 Thread Gabriel Genellina
At Tuesday 8/2/2005 08:00, [EMAIL PROTECTED] wrote:
How can I change the desktop color?  I want to set it to black.  Can
be just for the current session.
SetSysColors: 
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/setsyscolors.asp>

Ouch, unfortunately that function isn't available thru win32all
Using ctypes:

from ctypes.wintypes import windll, c_int, byref, RGB
COLOR_BACKGROUND = 1 # from winuser.h or win32con
SetSysColors = windll.user32.SetSysColors
which_color = RGB(255,0,0) # red
SetSysColors(1, byref(c_int(COLOR_BACKGROUND)), byref(c_int(which_color)))

Gabriel Genellina
Softlab SRL  

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


[python-win32] Re: sleep() fine-control in Python - RDTSC, select() etc.

2005-01-24 Thread Gabriel Genellina
At 24/1/2005 21:24, you wrote:
I have a need for a time.clock() with >0.16 second (16us) accuracy.
The sleep() (on Python 2.3, Win32, at least) has a .001s limit. Is it 
lower/better on other's platforms?
Try a waitable timer 
 

SetWaitableTimer specifies the interval with 100ns granularity, but maybe 
the actual timer precision depends on hardware or OS version or ...

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


[python-win32] Re: on the way to find pi!

2005-01-24 Thread Gabriel Genellina
At 24/1/2005 08:00, you wrote:
# Call pi(20) for first 20 digits, or pi() for all digits
def pi(n=-1):
printed_decimal = False
r = f((1,0,1,1))
while n != 0:
if len(r) == 5:
stdout.write(str(r[4]))

This code gives the number in an unusual format like "3.1415'None'" it has 
a number part and a string part . I want to seperate these from easc other 
but I couldn't manage. I mean when I try to turn it into string format 
then try to use things like [:4] or like that they don't work.Any idea how 
to seperate this 'None' from the number and make it a real normal number 
on which I can do operations like +1 -1 or like that :)
I bet: you call the function using:
print pi(20)
instead of just:
pi(20)
That function already prints the output, one digit at a time. You could 
accumulate the answer into a list, or perhaps into a string, and get 
thousands of digits; but it doesnt make sense to store the answer in a 
"real normal number" because you are limited by the underlying floating 
point precision to a few decimals. To get pi as a real number, just say: 
from math import pi

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


[python-win32] Re: Window capture using WM_PRINT and Python

2005-01-18 Thread Gabriel Genellina
At 18/1/2005 20:08, you wrote:
I'm a Java developper and I wish to make a capture of an offscreen window 
(on WinXP). It's not possible in Java, so I use a python script and 
WM_PRINT, but it doesn't seem to work.
I think device contexts are not shareable between processes, so you can't 
pass a DC handle.
Anyway, try to stay in Java - running a Python script to send some windows 
messages looks crazy to me!
You're using SWT, dont you? I'm almost sure it *is* possible to capture the 
image, but ask in a Java or Eclipse list for help.

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


Subject: AW: [python-win32] Geting values from a thread

2005-01-11 Thread Gabriel Genellina
At 11/1/2005 08:01, you wrote:

while True:
retval=win32event.WaitForMultipleObjects
(self.close_evt,self.accept_evt),False,win32event.INFINITE)
if retval == win32event.WAIT_OBJECT_0:
win32file.CloseHandle(self.accept_evt)
self.socket.close()
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(self._svc_name_, ''))
return
elif retval == win32event.WAIT_OBJECT_0 + 1:
thread.start_new_thread(self.FetchData,(self.socket,))
def FetchData(self,socket):
##code
  import servicemanager
  message= 'Processed %d bytes for client connection and printed out 
on port
%s' % (value1,value2) ##value 1,2 set inside the FetchData code
  servicemanager.LogInfoMsg(message)

If the service runs in debug mode, the message is written to the console. 
If the
service runs normal (with 'start' parameter) no message send to the 
eventlog (no
error message, no exit code, nothing happens). If I put the message line 
and the
LogInfoMsg line under thread.start_new_thread the message is send to the
eventlog, but I cannot pass the two values of the FetchData function.
That's the whole problem. Don't know how to solve :-(
If you really need another thread to process FetchData, you could use a 
Queue to pass data between threads.
But, for a server accepting multiple simultaneous connections the asyncore 
module may be a better solution than multiple threads.

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