Re: [python-win32] Module not found weirdness

2006-09-20 Thread Derick Van Niekerk
You might try running the dependency walker onsite-packages/win32/win32clipboard.pyd just in case, but I suspect you
won't find anything.I don't know how...yet :) win32clipboard.SetClipboardViewer
 is a function inside ofwin32clipboard.pyd, which is a DLL in the Python directory.  It,eventually, calls SetClipboardViewer inside of user32.dll.  User32.dllhas been a part of Windows since 1992; I'm 100% confident you'll find
the problem in the Python wrapper somewhere.On a whim, can you try checksumming the DLL?  I'm running pywin32-204.If you have the same version, you should get the same number:I'm using pywin32-206. I'm using the exact same python packages on my machine at work
as on my machine a home - I installed it on both PC's using the same files on my USBthumb drive...So if it is a problem with the dlls, it must have happened *after* I installed it.I'm not ruling out a virus yet, but that is a strange attack for a virus to follow :-/
Of course it might just be a fluke corruption on one of the files that could only possiblyhappen to me because of bad karma and planets being perfectly positioned or something.I'm going to try a fresh reinstall of all things python tonight. It's very frustrating not to be
able to replicate the error on another machine. > Is there any way I could have broken the clipboard view chain in a way
> that doesn't fix itself after a restart?No, that's all in-memory.  If it were me, I'd load up Python.exe in a Cdebugger and single-step through the function call, but then I'm notlike most people...
*blink blink*. A bit over my head at this time...I did try the cookbook script here, and it works fine.
As it does with every other machine I've tried it on, and every person on #python that tested it. I can't even find anything remotely similar to my problem on Google - so chances are it's some freak situation I created
on my PC.I tried running some clipboard managers at home (Clippy and Clipmagic - both nice programs by the way)and they don't seem to have a problem recieving the clipboard draw event, so I am sure you are right
about it having nothing to do with the windows dll. It *has* to be in the python wrapper...Anyway, if my reinstall of python doesn't work - I'll do a reinstall of Windows. A dirty job but somebody has todo it. If nothing else, it has therapeutic value...fdisk. No compromise.
-d-
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Module not found weirdness

2006-09-20 Thread Derick Van Niekerk
Since you're getting pywintypes.error rather than an import error,the function is actually called.  Most likely the app that created the
window (wxPython) isn't responding correctory.  You might want tocheck if you have the same version of wx on both machines.I never even thought of that... I installed from the same files originally, 
but I think I might've upgraded the wx version on my work machine.I'm trying a reinstall tonight.-d- 
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Trying to run an external program

2006-09-20 Thread Brant Sears
Hi. I'm new to Python and I am trying to use it on Windows XP. I am trying to 
use it to replicate the same thing that I do on Linux and Mac via shell 
scripting (Batch files aren't powerful enough, so I've decided to try to use 
Python.)

What I want to do is execute a program and have the results of the execution 
assigned to a variable. According to the documentation the way to do this is as 
follows:

import commands
x = commands.getstatusoutput('dir')

This should assign "x" to be the output of the command "dir". However, when I 
run this (or any other command), x ends up being:

(1, "'{' is not recognized as an internal or external command,\noperable 
program or batch file.")

>From looking through the documentation, I'm believing that the implementation 
>of commands.getstatusoutput is actually some multi-step thing that starts with 
>issuing the bracket character that is being choked on. This leads me to 
>believe that Python or perhaps just the commands module is not setup correctly 
>on my computer.

I installed Python using the Python2-5.msi link that I found at:
http://www.python.org/download/releases/2.5/

I left everything the default during installation, so Python was installed to 
C:\Python25. The only other thing I did was add this PATH variable on my 
computer.

Any ideas on what I might do to troubleshoot this?

Thanks!

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


Re: [python-win32] Trying to run an external program

2006-09-20 Thread John Machin
On 21/09/2006 8:03 AM, Brant Sears wrote:
> Hi. I'm new to Python and I am trying to use it on Windows XP. I am trying to 
> use it to replicate the same thing that I do on Linux and Mac via shell 
> scripting (Batch files aren't powerful enough, so I've decided to try to use 
> Python.)
> 
> What I want to do is execute a program and have the results of the execution 
> assigned to a variable. According to the documentation the way to do this is 
> as follows:
> 
> import commands
> x = commands.getstatusoutput('dir')
> 
> This should assign "x" to be the output of the command "dir". However, when I 
> run this (or any other command), x ends up being:
> 
> (1, "'{' is not recognized as an internal or external command,\noperable 
> program or batch file.")

Actually, the output is defined to be a tuple (exitstatus, 
command_result). The exitstatus is 1, and the "is not recognised" thing 
is the result of the command, which was evidently "{" (!!)

> 
>>From looking through the documentation, I'm believing that the implementation 
>>of commands.getstatusoutput is actually some multi-step thing that starts 
>>with issuing the bracket character that is being choked on. This leads me to 
>>believe that Python or perhaps just the commands module is not setup 
>>correctly on my computer.
> 
> I installed Python using the Python2-5.msi link that I found at:
> http://www.python.org/download/releases/2.5/
> 
> I left everything the default during installation, so Python was installed to 
> C:\Python25. The only other thing I did was add this PATH variable on my 
> computer.
> 
> Any ideas on what I might do to troubleshoot this?
> 

(1) Read the manual: "Availability: Unix"
(2) Read line 25 of the source code (c:\python25\lib\commands.py)

Others may know of canned Python solutions for Windows; all I can 
suggest is to write something like the (very short) commands module, 
using the functions in the subprocess module.

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


[python-win32] Trying to run an external program

2006-09-20 Thread Roger Upole
Brant Sears wrote:
> Hi. I'm new to Python and I am trying to use it on Windows XP. I am trying to 
> use it to replicate the same thing that I do on 
> Linux and Mac via shell scripting (Batch files aren't powerful enough, so 
> I've decided to try to use Python.)
>
> What I want to do is execute a program and have the results of the execution 
> assigned to a variable. According to the 
> documentation the way to do this is as follows:
>
> import commands
> x = commands.getstatusoutput('dir')
>
> This should assign "x" to be the output of the command "dir". However, when I 
> run this (or any other command), x ends up 
> being:
>
> (1, "'{' is not recognized as an internal or external command,\noperable 
> program or batch file.")
>
>>From looking through the documentation, I'm believing that the implementation 
>>of commands.getstatusoutput is actually some 
>>multi-step thing that starts with issuing the bracket character that is being 
>>choked on. This leads me to believe that Python 
>>or perhaps just the commands module is not setup correctly on my computer.
>
> I installed Python using the Python2-5.msi link that I found at:
> http://www.python.org/download/releases/2.5/
>
> I left everything the default during installation, so Python was installed to 
> C:\Python25. The only other thing I did was add 
> this PATH variable on my computer.
>
> Any ideas on what I might do to troubleshoot this?
>
> Thanks!
>
> Brant Sears

The commands module doesn't work on Windows.  You could try using
os.popen, or maybe the subprocess module.

   Roger

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


[python-win32] How to launch acrobat with data

2006-09-20 Thread Roger Upole
Andrew Diederich wrote:
> Hello python-win32,
> 
> I'm storing some Adobe forms (application/vnd.fdf) in a database.
> Using ADODBAPI I've been able to pull the data out.  Does anyone know
> how I can launch Adobe Acrobat with the data?
> 
> Here's how I get the data:
 import adodbapi
> 
 conn = adodbapi.connect('Driver={SQL Server};Data
> Source=dbServer,1433;Initial Catalog=theDatabase;User
> ID=theUser;Password=thePassword;')
> 
 curs=conn.corsor()
> 
 curs.execute('''select documentID, BLOBcol from mytable where 
 documentID=5;''')
> 
 answer=curs.fetchall()
> 
> And answer is:
 answer
> ((u'5', ),)
> 
> I can get just the FDF data, of course.
> 
 print answer[0][1]
> %+++-1.2
> /FDF << /Fields [ << /T (All_Activity_ActivityID)/V /Off >> << /T (All_
> 
> 
> Does anyone know how to launch Acrobat with data?  I'm very behind the
> power curve on windows programming, so I'm not really even sure how to
> search through windows to discover how to Dispatch correctly.  I
> searched the registry for applicatoin/vnd.fdf, and found HKCR\.fdf,
> which had AcroExch.FDFDoc, and PDFs look to be AcroExch.Document, but
> how I would use, say, win32com.client.Dispatch to launch Acrobat with
> some data (or even launch Acrobat)?
> 
> Thanks for the help.
> 
> -- 
> Best regards,
> Andrew Diederich

You could write the data out to a file and use os.startfile
to launch acrobat.  If you need to actually control Acrobat
as a COM object, it has to be embedded in a container.
Using IE as a container is fairly easy, you just Navigate to
a PDF document:
import win32com.client
ie=win32com.client.Dispatch('internetexplorer.application')
ie.Visible=1
ie.Navigate('somedocument.pdf')

Roger

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


Re: [python-win32] How to implement a COM interface (that is not part

2006-09-20 Thread Ken Channing
Thanks for your help -- I searched around some more and I think I
have the basic idea down -- if you want to implement a COM interface, it should
look something like this:

Use makepy -i to generate a file from the typelib containing the
interface definition.
In my case the file generated is named:
13F76618-D199-4485-8C95-DC524958686Cx0x2x0.py

I assume the typelib GUID is: 13F76618-D199-4485-8C95-DC524958686C
and the typelib version is: 2,0

The interface I'm trying to implement is named: "IMbtQuotesNotify"

universal.RegisterInterfaces('{13F76618-D199-4485-8C95-DC524958686C}',0,2,0,["IMbtQuotesNotify"])
class Q:
_com_interfaces_ = ['IMbtQuotesNotify']
_typelib_guid_ = '{13F76618-D199-4485-8C95-DC524958686C}'
_typelib_version_ = 2, 0

def OnQuoteData(self,pQuote):
print "got onquote!"
print type(pQuote)
print "%s" % pQuote

import win32com.server.util
qnotify = win32com.server.util.wrap(Q())

The object named qnotify is now something I can pass to another COM
function that
expects an object implementing the interface.

import win32com.client as com
quote = com.Dispatch("MBTrading.MbtQuotes")
quote.AdviseSymbol(qnotify,'GOOG',1)

The callback functions defined in qnotify should be called with quote
data whenever a new quote for 'GOOG' is available.  For whatever
reason, this doesn't happen. Sometimes the OnQuoteData callback is
invoked with an int (the int is 1240772, if that means anything)
instead of the quote datatype as advertised. Sometimes the interpreter
crashes.  However, I suspect that the above code is correct, unless I
am still doing something wrong.  (Perhaps using wrap is not the right
function for creating an object that is passed as an argument to
another COM function?)

Thanks again for your help!



> > I think the post here outlines a similar problem:
> > http://mail.python.org/pipermail/python-win32/2004-May/001990.html
> >
> > Is there some obvious way to do this that I'm missing?
> > In the VB version of the program I'm trying to re-implement in python,
> > it seems to be able to
> > implement the interface by simply calling "Implements Foo" and subclassing 
> > by
> > "Private Sub Foo_OnSomeEvent(..."
> >
> > Thanks for any help!
>
> You should be able to implement it just as you would a small COM server.
> Basically, your class would need to specify the interface with
>  _com_interfaces_=[iid of Foo]
> and define an event method.
> def OnSomeEvent(self,.):
>
>  Roger

Thanks for your help -- I've created a class as you've suggested.
The function that takes as an argu
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32