From: Maria.Reinhammar on
I have an app using active_directory.py and the std module asyncore in
a Windows Service.
Works perfectly!
That is, until I try to use py2exe to create a standalone (need to
avoid installing the entire Python etc. on the target system).

When I try to start the installed Service, the system tells me it
terminates prematurely
and in the event log I find:
The instance's SvcRun() method failed
File "win32serviceutil.pyc", line 785, in SvcRun
File "XXProxySvc.pyc", line 126, in SvcDoRun
File "XXProxySvc.pyc", line 94, in setup
File "D:\projects\XXProxy\DB.py", line 54, in loadFromAD
File "active_directory.pyc", line 402, in search
File "active_directory.pyc", line 398, in root
File "active_directory.pyc", line 371, in AD
File "active_directory.pyc", line 378, in _root
File "win32com\client\__init__.pyc", line 73, in GetObject
File "win32com\client\__init__.pyc", line 88, in Moniker
pywintypes.com_error: (-2147221020, 'Invalid syntax', None, None)

The offending line is:
import active_directory as AD
....
for item in AD.search ("objectCategory='Person'"):
....

I.e. the call to AD.search() is the entry point to the problem.

The setup.py is (pretty straight forward..):
from distutils.core import setup
import py2exe

class Target:
def __init__(self, **kw):
self.__dict__.update(kw)
# for the versioninfo resources
self.version = "0.9.0"
self.company_name = "My Company"
self.copyright = "My Company (c)"
self.name = "FilterProxy"

################################################################
# a NT service, modules is required
myservice = Target(
# used for the versioninfo resource
description = "AD Driven Mail Filter",
# what to build. For a service, the module name (not the
# filename) must be specified!
modules = ["ProxySvc"]
)

excludes = []
setup(options = {"py2exe": {# create a compressed zip archive
#"compressed": 1,
#"optimize": 2,
"excludes": excludes
}
},
service=[myservice]
)

'elp! Pleeeez!

From: Larry Bates on
Maria.Reinhammar(a)accalon.com wrote:
> I have an app using active_directory.py and the std module asyncore in
> a Windows Service.
> Works perfectly!
> That is, until I try to use py2exe to create a standalone (need to
> avoid installing the entire Python etc. on the target system).
>
> When I try to start the installed Service, the system tells me it
> terminates prematurely
> and in the event log I find:
> The instance's SvcRun() method failed
> File "win32serviceutil.pyc", line 785, in SvcRun
> File "XXProxySvc.pyc", line 126, in SvcDoRun
> File "XXProxySvc.pyc", line 94, in setup
> File "D:\projects\XXProxy\DB.py", line 54, in loadFromAD
> File "active_directory.pyc", line 402, in search
> File "active_directory.pyc", line 398, in root
> File "active_directory.pyc", line 371, in AD
> File "active_directory.pyc", line 378, in _root
> File "win32com\client\__init__.pyc", line 73, in GetObject
> File "win32com\client\__init__.pyc", line 88, in Moniker
> pywintypes.com_error: (-2147221020, 'Invalid syntax', None, None)
>
> The offending line is:
> import active_directory as AD
> ...
> for item in AD.search ("objectCategory='Person'"):
> ...
>
> I.e. the call to AD.search() is the entry point to the problem.
>
> The setup.py is (pretty straight forward..):
> from distutils.core import setup
> import py2exe
>
> class Target:
> def __init__(self, **kw):
> self.__dict__.update(kw)
> # for the versioninfo resources
> self.version = "0.9.0"
> self.company_name = "My Company"
> self.copyright = "My Company (c)"
> self.name = "FilterProxy"
>
> ################################################################
> # a NT service, modules is required
> myservice = Target(
> # used for the versioninfo resource
> description = "AD Driven Mail Filter",
> # what to build. For a service, the module name (not the
> # filename) must be specified!
> modules = ["ProxySvc"]
> )
>
> excludes = []
> setup(options = {"py2exe": {# create a compressed zip archive
> #"compressed": 1,
> #"optimize": 2,
> "excludes": excludes
> }
> },
> service=[myservice]
> )
>
> 'elp! Pleeeez!
>

You may want to post this on gmane.comp.python.py2exe also.

I'm going to try to guess what the problem is, but it is a little hard to tell
from here. py2exe does its best to find all the modules required to create the
..exe. Sometimes modules do dynamic imports, etc. of modules that "fool" py2exe.
I'm guessing that this is the case and that you will need to manually include
the missing module. Most such errors seem to fall into this category. Hope
this at least points you in the correct direction.

-Larry Bates
From: Tim Golden on
[Maria.Reinhammar(a)accalon.com]

[... snip ...]

| File "win32com\client\__init__.pyc", line 73, in GetObject
| File "win32com\client\__init__.pyc", line 88, in Moniker
| pywintypes.com_error: (-2147221020, 'Invalid syntax', None, None)
|
| The offending line is:
| import active_directory as AD
| ...
| for item in AD.search ("objectCategory='Person'"):

Not infrequently -- and quite bizarrely -- "Invalid syntax"
errors in COM sometimes come down to a mishandling of threading.
To ask the obvious: do you have a pythoncom.CoInitialize ()
somewhere in your code?

This is a bit invisible, because Services are inherently
threaded, while you were probably running it before
unthreaded.

May not be the answer, but worth a try.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
From: Thomas Heller on
Tim Golden schrieb:
> [Maria.Reinhammar(a)accalon.com]
>
> [... snip ...]
>
> | File "win32com\client\__init__.pyc", line 73, in GetObject
> | File "win32com\client\__init__.pyc", line 88, in Moniker
> | pywintypes.com_error: (-2147221020, 'Invalid syntax', None, None)
> |
> | The offending line is:
> | import active_directory as AD
> | ...
> | for item in AD.search ("objectCategory='Person'"):
>
> Not infrequently -- and quite bizarrely -- "Invalid syntax"
> errors in COM sometimes come down to a mishandling of threading.
> To ask the obvious: do you have a pythoncom.CoInitialize ()
> somewhere in your code?
>
> This is a bit invisible, because Services are inherently
> threaded, while you were probably running it before
> unthreaded.
>
> May not be the answer, but worth a try.

Maybe another possibility is that py2exe fails to include makepy
generated modules. Could that lead to this error?

Thomas

From: Tim Golden on
[Thomas Heller]
| Tim Golden schrieb:
| > [Maria.Reinhammar(a)accalon.com]
| >
| > [... snip ...]
| >
| > | File "win32com\client\__init__.pyc", line 73, in GetObject
| > | File "win32com\client\__init__.pyc", line 88, in Moniker
| > | pywintypes.com_error: (-2147221020, 'Invalid syntax', None, None)
| > |
| > | The offending line is:
| > | import active_directory as AD
| > | ...
| > | for item in AD.search ("objectCategory='Person'"):
| >
| > Not infrequently -- and quite bizarrely -- "Invalid syntax"
| > errors in COM sometimes come down to a mishandling of threading.
| > To ask the obvious: do you have a pythoncom.CoInitialize ()
| > somewhere in your code?
| >
| > This is a bit invisible, because Services are inherently
| > threaded, while you were probably running it before
| > unthreaded.
| >
| > May not be the answer, but worth a try.
|
| Maybe another possibility is that py2exe fails to include makepy
| generated modules. Could that lead to this error?

Could easily be. I vaguely remember some similar problem
with the WMI module, which I worked around by not doing
a dynamic import in the end... or something. Don't think
I've got the option here. (I wrote the active_directory
module, in case it wasn't clear).

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
 |  Next  |  Last
Pages: 1 2 3
Prev: PumpMessages et WM_QUIT
Next: ctypes pointer to pointer