frozen win32com problem 
Author Message
 frozen win32com problem

I am attempting to implement a frozen python win32com object.
We are using a variant of Gordon McMillan's 4.x installer framework
to create a python.exe which works fine. Most .pycs are in a .pyz file,
but the win32/lib files and win32com/server+client files are in
the real file system.

I have only got pythoncom21.dll, pywintypes21.dll, win32api.pyd and win32trace.pyd
on the target system.

I find that I can use my objects if I manually register them to use my
localserver only. So I have a working setup except for registration on
the target machine.

When I try to use the standard command line registration/unregistration
mechanism I'm getting an error from win32com.server.register._cat_registrar

eg with the cut down file \tmp\dingo.py

import pythoncom
def _cat_registrar():
  return pythoncom.CoCreateInstance(
    pythoncom.CLSID_StdComponentCategoriesMgr,
    None,
    pythoncom.CLSCTX_INPROC_SERVER,
    pythoncom.IID_ICatRegister
    )

print 'CLSID_StdComponentCategoriesMgr', pythoncom.CLSID_StdComponentCategoriesMgr
print 'CLSCTX_INPROC_SERVER', pythoncom.CLSCTX_INPROC_SERVER
print 'IID_ICatRegister', pythoncom.IID_ICatRegister
print _cat_registrar()

C:\ReportLab>\tmp\dingo.py
CLSID_StdComponentCategoriesMgr <iid:{0002E005-0000-0000-C000-000000000046}>
CLSCTX_INPROC_SERVER 1
IID_ICatRegister <iid:{0002E012-0000-0000-C000-000000000046}>
Traceback (most recent call last):
  File "C:\tmp\dingo.py", line 13, in ?
    print _cat_registrar()
  File "C:\tmp\dingo.py", line 7, in _cat_registrar
    pythoncom.IID_ICatRegister
pywintypes.com_error: (-2147221164, 'Class not registered', None, None)

this is on an NT4 system that has no python/pythonwin etc. Any ideas what
I'm missing/haven't registered?
--
Robin Becker



Tue, 22 Jun 2004 01:21:48 GMT  
 frozen win32com problem

Quote:

> I am attempting to implement a frozen python win32com object.
> We are using a variant of Gordon McMillan's 4.x installer framework
> to create a python.exe which works fine. Most .pycs are in a .pyz file,
> but the win32/lib files and win32com/server+client files are in
> the real file system.

> I have only got pythoncom21.dll, pywintypes21.dll, win32api.pyd and
> win32trace.pyd on the target system.

> I find that I can use my objects if I manually register them to use my
> localserver only. So I have a working setup except for registration on
> the target machine.

localserver only applies if you're using LOCAL_SERVER.

Quote:
> When I try to use the standard command line registration/unregistration
> mechanism I'm getting an error from
> win32com.server.register._cat_registrar

> eg with the cut down file \tmp\dingo.py

> import pythoncom
> def _cat_registrar():
>   return pythoncom.CoCreateInstance(
>     pythoncom.CLSID_StdComponentCategoriesMgr,
>     None,
>     pythoncom.CLSCTX_INPROC_SERVER,
>     pythoncom.IID_ICatRegister
>     )

> print 'CLSID_StdComponentCategoriesMgr',
> pythoncom.CLSID_StdComponentCategoriesMgr print 'CLSCTX_INPROC_SERVER',
> pythoncom.CLSCTX_INPROC_SERVER print 'IID_ICatRegister',
> pythoncom.IID_ICatRegister print _cat_registrar()

> C:\ReportLab>\tmp\dingo.py
> CLSID_StdComponentCategoriesMgr
> <iid:{0002E005-0000-0000-C000-000000000046}
> CLSCTX_INPROC_SERVER 1
> IID_ICatRegister <iid:{0002E012-0000-0000-C000-000000000046}>
> Traceback (most recent call last):
>   File "C:\tmp\dingo.py", line 13, in ?
>     print _cat_registrar()
>   File "C:\tmp\dingo.py", line 7, in _cat_registrar
>     pythoncom.IID_ICatRegister
> pywintypes.com_error: (-2147221164, 'Class not registered', None, None)

> this is on an NT4 system that has no python/pythonwin etc. Any ideas
> what I'm missing/haven't registered?

You seem to be asking for INPROC_SERVER. That means COM loads
pythoncomXX.dll which (implicitly) loads pythonXX.dll. There's no chance for
the import hooks to get installed.

Unless you upgrade to release 5.

-- Gordon
http://www.mcmillan-inc.com/



Tue, 22 Jun 2004 04:05:08 GMT  
 frozen win32com problem

 >>def _cat_registrar():
 >>  return pythoncom.CoCreateInstance(
 >>    pythoncom.CLSID_StdComponentCategoriesMgr,
 >>    None,
 >>    pythoncom.CLSCTX_INPROC_SERVER,
 >>    pythoncom.IID_ICatRegister
 >>    )

...

Quote:

>>this is on an NT4 system that has no python/pythonwin etc. Any ideas
>>what I'm missing/haven't registered?

> You seem to be asking for INPROC_SERVER. That means COM loads
> pythoncomXX.dll which (implicitly) loads pythonXX.dll. There's no chance for
> the import hooks to get installed.

Actually, the code is only trying to get a reference to a standard COM
object, not a Python implemented one.  I assume that the test program
works OK when not frozen, or is this only on a single machine "in the
field"?

Mark.



Tue, 22 Jun 2004 13:37:35 GMT  
 frozen win32com problem


.....
Quote:

>Actually, the code is only trying to get a reference to a standard COM
>object, not a Python implemented one.  I assume that the test program
>works OK when not frozen, or is this only on a single machine "in the
>field"?

>Mark.

yes this works fine on the win2k build system, but not on my test NT4
machine. Could it be that I need some extra library/pyd on the target.
On the build system the frozen python.exe seems to be able to register
stuff correctly and it looks like it's only using stuff from the frozen
distribution, but it has python & win32all installed so maybe it can see
stuff via the registry.
--
Robin Becker


Tue, 22 Jun 2004 19:30:36 GMT  
 frozen win32com problem
It could also be that the component category manager is not
registered right on yout NT system. Try this

RegSvr32.Exe <Path To Windows\System(32)>\ComCat.DLL

on your NT machine and look if it helps.

        Stefan

Quote:
> -----Original Message-----

> Sent: Friday, January 04, 2002 12:31 PM

> Subject: Re: frozen win32com problem



> .....

> >Actually, the code is only trying to get a reference to a
> standard COM
> >object, not a Python implemented one.  I assume that the
> test program
> >works OK when not frozen, or is this only on a single
> machine "in the
> >field"?

> >Mark.

> yes this works fine on the win2k build system, but not on my test NT4
> machine. Could it be that I need some extra library/pyd on the target.
> On the build system the frozen python.exe seems to be able to register
> stuff correctly and it looks like it's only using stuff from
> the frozen
> distribution, but it has python & win32all installed so maybe
> it can see
> stuff via the registry.
> --
> Robin Becker
> --
> http://mail.python.org/mailman/listinfo/python-list



Tue, 22 Jun 2004 19:50:01 GMT  
 frozen win32com problem


Quote:
>It could also be that the component category manager is not
>registered right on yout NT system. Try this

>RegSvr32.Exe <Path To Windows\System(32)>\ComCat.DLL

>on your NT machine and look if it helps.

>       Stefan

.....
thanks I'll try that.
--
Robin Becker


Tue, 22 Jun 2004 21:58:17 GMT  
 frozen win32com problem


Quote:
>It could also be that the component category manager is not
>registered right on yout NT system. Try this

>RegSvr32.Exe <Path To Windows\System(32)>\ComCat.DLL

>on your NT machine and look if it helps.

>       Stefan

.....
OK that's the problem. It seems that a standard bare bones install of
NT4 is not required to have Comcat.dll at all. Checking with google I
see that there are very large numbers of problems associated with
comcat.dll (mainly versioning and non-registration).

I have a vague understanding that comcat.dll implements the "Component
Categories Manager" required for controls, but not for com objects. I
have set _reg_disable_pycomcat_ = 1 in my com class, but even so it
seems that the win32com/server/register.py module contains an
unconditional attempt to register the "Python COM Server" category.

This is a bit restrictive.
--
Robin Becker



Sun, 27 Jun 2004 19:23:17 GMT  
 frozen win32com problem

Quote:



> I have a vague understanding that comcat.dll implements the "Component
> Categories Manager" required for controls, but not for com objects. I
> have set _reg_disable_pycomcat_ = 1 in my com class, but even so it
> seems that the win32com/server/register.py module contains an
> unconditional attempt to register the "Python COM Server" category.

> This is a bit restrictive.

I agree, but I can't see why this would happen.  Please have a quick
look at RegisterServer and the use of 'addPyComCat', and if you can see
the problem send me a patch.

Thanks,

Mark.



Mon, 28 Jun 2004 12:35:21 GMT  
 frozen win32com problem

Actually, I could see how this happens.  I just checked in the following
patch.

RCS file: /home/cvsroot/PyWin32/com/win32com/server/register.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -r1.4 -r1.5
12a13
 > import win32com
420c421,424
<   RegisterPyComCategory()
---
 >   try:
 >     RegisterPyComCategory()
 >   except win32com.error: # Error with the COM category manager - oh well.
 >     pass

Mark.



Mon, 28 Jun 2004 12:46:27 GMT  
 frozen win32com problem


Quote:

>Actually, I could see how this happens.  I just checked in the following
>patch.

>RCS file: /home/cvsroot/PyWin32/com/win32com/server/register.py,v
>retrieving revision 1.4
>retrieving revision 1.5
>diff -r1.4 -r1.5
>12a13
>> import win32com
>420c421,424
><   RegisterPyComCategory()
>---
>>   try:
>>     RegisterPyComCategory()
>>   except win32com.error: # Error with the COM category manager - oh well.
>>     pass

>Mark.

Actually I think I tried something like this, but the registration was
slightly wrong afterwards (I think the localserver was wrong). I'll have
a go on the test NT machine again to check.
--
Robin Becker


Mon, 28 Jun 2004 16:48:15 GMT  
 frozen win32com problem

Quote:

>Actually, I could see how this happens.  I just checked in the following
>patch.

>RCS file: /home/cvsroot/PyWin32/com/win32com/server/register.py,v
>retrieving revision 1.4
>retrieving revision 1.5
>diff -r1.4 -r1.5
>12a13
>> import win32com
>420c421,424
><   RegisterPyComCategory()
>---
>>   try:
>>     RegisterPyComCategory()
>>   except win32com.error: # Error with the COM category manager - oh well.
>>     pass

>Mark.

OK I tries this and got a complaint about win32com.error

I used instead

try:  
  win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT,
                         'Component Categories\\%s' % CATID_PythonCOMServer)
except win32api.error:
  import pywintypes
  try:
    RegisterPyComCategory()
  except pywintypes.com_error:  # Error with the COM category manager - oh well.
    pass

and then things went well. I did
interp.py --register
interp.py --test
and things worked.

so my patch (presumably against 1.4) was,
*** register.py.orig    Fri Aug 04 18:29:16 2000
--- register.py Thu Jan 10 10:29:32 2002
***************
*** 417,421 ****
    win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT,
                           'Component Categories\\%s' % CATID_PythonCOMServer)
  except win32api.error:
!   RegisterPyComCategory()
!
--- 417,424 ----
    win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT,
                           'Component Categories\\%s' % CATID_PythonCOMServer)
  except win32api.error:
!   import pywintypes
!   try:
!     RegisterPyComCategory()
!   except pywintypes.com_error:  # Error with the COM category manager - oh well.
!         pass
--
Robin Becker



Mon, 28 Jun 2004 18:34:20 GMT  
 frozen win32com problem

Quote:



>>Actually, I could see how this happens.  I just checked in the following
>>patch.

>>RCS file: /home/cvsroot/PyWin32/com/win32com/server/register.py,v
>>retrieving revision 1.4
>>retrieving revision 1.5
>>diff -r1.4 -r1.5
>>12a13

>>>import win32com

>>420c421,424
>><   RegisterPyComCategory()
>>---

>>>  try:
>>>    RegisterPyComCategory()
>>>  except win32com.error: # Error with the COM category manager - oh well.
>>>    pass

> OK I tries this and got a complaint about win32com.error

It looks like you missed a line of my patch:

 >>diff -r1.4 -r1.5
 >>12a13
 >>
 >>>import win32com

This should setup win32com correctly so win32com.error can be found.

Mark.



Tue, 29 Jun 2004 07:17:12 GMT  
 frozen win32com problem

...
Quote:
>>>>import win32com

>This should setup win32com correctly so win32com.error can be found.

>Mark.

no I tried directly to import etc and failed

PythonWin 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32.

copyright information.

Quote:
>>> import win32com
>>> raise win32com.error

Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
AttributeError: 'win32com' module has no attribute 'error'
--
Robin Becker


Tue, 29 Jun 2004 07:58:40 GMT  
 frozen win32com problem

Quote:


> ...

>>>>>import win32com

>>This should setup win32com correctly so win32com.error can be found.

>>Mark.

> no I tried directly to import etc and failed

> PythonWin 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32.

> copyright information.

>>>>import win32com
>>>>raise win32com.error

Oops - my mistake :(  I meant 'pythoncom'.  Sorry.

Mark.



Fri, 02 Jul 2004 10:05:37 GMT  
 
 [ 17 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Freezing an app using win32com and wxPython

2. freeze and win32com

3. Help with win32com problem

4. win32com: makepy causes ie problems.

5. problem running win32com.client application from commandline

6. Problem with win32com and Numpy on NT based systems

7. HELP! win32com, COM, Invoke problem

8. win32com problem

9. Win32com and unicode problems - ordinal not in range(128)

10. Problem with win32com

11. McMillan's Installer problem with win32com

12. Problems installing win32com

 

 
Powered by phpBB® Forum Software