I just answered this email on the py2exe list without being aware you also 
posted it here - the issue is almost certainly incorrect usage of "com_server" 
and "console" in the py2exe script.

Mark
----

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tejovathi P
Sent: Tuesday, 8 January 2008 10:04 PM
To: Pramod P G; python-win32@python.org
Subject: Re: [python-win32] Regarding COM server and exe

Here is my sample COM server and py2exe setup file
 
testCOM.py
 
import win32com.client
import os.path
import shutil
from win32api import Sleep
import string
import os
import sys
import pythoncom
        
class FirstEx:
 
    _reg_clsid_ = "{A6DE9DF8-5EBF-48E6-889E-C71CB84CFF2C}"
    pythoncom.frozen = 1
    if hasattr(sys, 'importers'):
        # In the py2exe-packed version, specify the module.class
        # to use. In the python script version, python is able
        # to figure it out itself.
        _reg_class_spec_ = "__main__.FirstEx"
    _reg_desc_ = "My first COM server" 
    _reg_progid_ = "SAMPLE.Lib"   
    _public_methods_ = ['init', 'Version']
    _public_attrs_ = ['softspace', 'noCalls']
    _readonly_attrs_ = ['noCalls'] 
    _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER

    def __init__(self):
        self.softspace = 1
        self.noCalls = 0
    
    def Version(self):
        self.noCalls = self.noCalls + 1
        # insert "softspace" number of spaces
        return "Version: 0.0.1" 
    
   
if __name__=='__main__':
    import sys
    if hasattr(sys, 'importers'): 
        # running as packed executable.
        if '--register' in sys.argv[1:] or '--unregister' in sys.argv[1:]:
        # --register and --unregister work as usual
            import win32com.server.register 
            win32com.server.register.UseCommandLine(FirstEx)
        else:
            # start the server.
            from win32com.server import localserver
            localserver.main()
    else:
        import win32com.server.register
        win32com.server.register.UseCommandLine(FirstEx)
 Here is my setup file:
#Start here 
from distutils.core import setup 
import py2exe 
setup(options = {"py2exe": {"compressed": 1,
                          "optimize": 2,
                          "ascii": 1,
                          "bundle_files": 1}}, 
    zipfile = None,
    com_server = ["win32com.servers.interp"],
    console = ["testCOM.py"]) 
#End here
Here is my VB code:
Sub subRoutine()
Dim connection As Object
Dim returnvalue1 As String
Dim returnvalue2 As String
Dim flag3 As Boolean
Set connection = CreateObject("SAMPLE.Lib")
returnvalue1 = connection.Version()
MsgBox (returnvalue1)
End Sub
The non exe version of the COM server ie. directlly running the testCOM.py 
registers the library properly and 
in the VB application, the message box displays the version as 0.0.1.
But, after I create the EXE file using the setup.py file and run it, it 
registers the library.
When I run the VB application, it hangs at the line
Set connection = CreateObject("SAMPLE.Lib")
and displays. " ACTIVEX cannot create the object"
Any suggestions please....
 
On 1/8/08, Tejovathi P <[EMAIL PROTECTED]> wrote: 
I am trying to create the obj in VB in the same manner, ie
 
Set Obj = CreateObject("sample.lib")
Strangely, the non exe version of the COM server works fine and I am able to 
access the public functions in VB application.
 
Problem comes with the EXE version of the COM server, VB application jus hangs 
while executing, 
       Set obj = CreateObject("sample.lib")


 
On 1/8/08, Pramod P G <[EMAIL PROTECTED] > wrote: 
Hi,
Try out this  statement
 
This might help U ☺ 
 
       Set obj = CreateObject("sample.lib")
 
Thanks and regards,
Pramod P G
 
________________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tejovathi P
Sent: Tuesday, January 08, 2008 3:57 PM
To: python-win32@python.org
Subject: [python-win32] Regarding COM server and exe
 
Hi All,
 
I have a Python COM server. I need to deploy it on various sytems. When I run 
the COM server from
python its showing an output " Registered : sample.lib"
 
If I try to use the COM obj from a VB client like:
 
obj = CreateObject("sample.lib")
 
Its working fine without any errors
 
Now I am trying to convert this COM server to an exe through py2exe and after I 
run the exe, I am
getting the same output " Registered : sample.lib"
 
But If I try to use the COM obj from a VB client like
 
obj = CreateObject("sample.lib")
 
A console pops up saying " Registered : sample.lib" and VB application hangs 
there.
Its throwing a VB error that "ActiveX object cannot be created......etc etc"
 
Any suggestions please.......
 
Regards,
Tejovathi

The information contained in, or attached to, this e-mail, contains 
confidential information and is intended solely for the use of the individual 
or entity to whom they are addressed and is subject to legal privilege. If you 
have received this e-mail in error you should notify the sender immediately by 
reply e-mail, delete the message from your system and notify your system 
manager. Please do not copy it for any purpose, or disclose its contents to any 
other person. The views or opinions presented in this e-mail are solely those 
of the author and do not necessarily represent those of the company. The 
recipient should check this e-mail and any attachments for the presence of 
viruses. The company accepts no liability for any damage caused, directly or 
indirectly, by any virus transmitted in this email. 

www.aztecsoft.com



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

Reply via email to