[python-win32] Questions about deploying COM server via py2exe

Matteo Boscolo matteo.boscolo at boscolini.eu
Fri Aug 19 09:01:19 CEST 2011


Hi Kevin ,

Il 18/08/2011 17:10, Kevin Walzer ha scritto:
> Hi all,
>
> I'm working on a Tkinter app that is being deployed to Windows via 
> py2exe for wrapping and InnoSetup for its installer. In order to 
> provide a similar scripting capability to the app that is present in 
> its Mac version, I've made the app a COM server using the examples 
> from python-win32 code base.
>
> I am running into two issues with the app that I would like some 
> clarification on:
>
> 1. What is the best way to register the exe as a COM server? I'm using 
> the code from the python-win32 extension to register the code 
> dynamically, but on Windows 7 this requires administrator 
> privileges--which means that the entire app must be run as an 
> administrator (via a flag in py2exe). This works, but seems overkill. 
> I understand from the list archives that there is no current built-in 
> way to escalate UAC privileges for a single function, cf. to register 
> the server. Is there another way to register the wrapped exe as a 
> server, i.e. from the command line (regsvr32) during the installation 
> phase?
For registering the com server we use innosetup with the following line
[Run]
Filename: "{app}\openclerk.exe"; Parameters: "/regserver"; WorkingDir: 
"{app}" ; StatusMsg: "Registering openclerk.exe ..."
>
> 2. I am testing the app via a simple vbscript with a create object() 
> call and then running the command exported by the COM server. While my 
> app launches, it blocks forever, and then eventually the Windows 
> Scripting Host times out with an error ("couldn't create ActiveX 
> object"). Any suggestions on how to debug this?

usually you get this error because you miss some reference into py2exe
the way that we use to trace this error is to try catch all com method 
even the __init__ and use the logging system:

here you get an example:

     def SetIntegration(self, integrationObject, activeEditor=""):
         """
             set the integration object
         """
         try:

         except:
             print_exc_plus()
             return E_FAIL
         return S_O

def print_exc_plus():
     """
         Print the usual traceback information, followed by a listing of
         all the local variables in each frame.
     """
     logging.error("*"*20)
     for m in sys.exc_info():
         logging.error(str(m))
     logging.error("*"*20)
     tb = sys.exc_info( )[2]
     while tb.tb_next:
         tb = tb.tb_next
     stack = [  ]
     f = tb.tb_frame
     while f:
         stack.append(f)
         f = f.f_back
     stack.reverse( )
     traceback.print_exc()
     logging.error( "Locals by frame, innermost last")
     for frame in stack:
         logging.error("Frame %s in %s at line %s" % (frame.f_code.co_name,
                                              frame.f_code.co_filename,
                                              frame.f_lineno))
         for key, value in frame.f_locals.items():
             # we must _absolutely_ avoid propagating exceptions, and 
str(value)
             # COULD cause any exception, so we MUST catch any...:
             try:
                 logging.error("\t%20s = %s"%(key ,str(value)))
             except:
                 logging.error( "<ERROR WHILE PRINTING VALUE>")


Regards,
Matteo

> I can find no obvious error in my code and the app does start up 
> successfully, which tells me it's registered, but for some reason it 
> locks up before it can run its command. (The app does pop up a dialog 
> on startup, I don't know if that would have any effect or not.)
>
> Thanks,
> Kevin
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
> Nessun virus nel messaggio.
> Controllato da AVG - www.avg.com <http://www.avg.com>
> Versione: 10.0.1392 / Database dei virus: 1520/3841 - Data di 
> rilascio: 17/08/2011
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20110819/f90110e8/attachment.html>


More information about the python-win32 mailing list