473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using py2exe to wrap a service?

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!

Sep 20 '06 #1
2 4127
Ma**************@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
Sep 20 '06 #2
MaR
Thanks guys! :o)

It seems that no module is missing since the Service starts and the
error message seem to indicate an error in the COM call to the AD.
I would expect some other exception..

I do have a separate thread for the asyncore.loop() as I otherwise
would risk a lockup.

I do not call pythoncom.CoInitialize () as I tend to expect a module
wrapping COM stuff to do that. Since I am not really into Windows, I
have to ask you, do I make a wrong assumption here?

Some further info that may be of interest:
python 2.4.3
active_directory 0.4
py2exe 0.6.5
pywin32 208
The Service code is taken from MyService.py supplied with py2exe as a
sample.

Rgrds//M

Sep 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Thomas Heller | last post by:
I'm currently working on a new version of py2exe, which will require Python 2.3 and later, because it uses the zipimport mechanism. Since py2exe is a distutils extension, and since C compilers...
0
by: Brad Clements | last post by:
I'm trying to get a simple service to work with py2exe and python 2.3 I get this error when I start it (after registering it) The description for Event ID ( 240 ) in Source ( UMXWIN32SVC )...
10
by: Thomas Heller | last post by:
**py2exe 0.5.0** (finally) released =================================== py2exe is a Python distutils extension which converts python scripts into executable windows programs, able to run without...
1
by: Peter Teniz | last post by:
hi, i'm trying to generate a service for win XP / win 2k with python2.3.3 + win32all-163 + py2exe0.5.0 (also tried with pywin32-200.win32-py2.3) running the console-script "FBxmlserv.py" with...
2
by: Bryan | last post by:
just for fun and my own experience, i wanted to use py2exe to wrap the wxpython demo. i put the setup script in the demo directory which is the following: from distutils.core import setup...
0
by: Thomas Heller | last post by:
**py2exe 0.5.2** released ========================= py2exe is a Python distutils extension which converts python scripts into executable windows programs, able to run without requiring a python...
4
by: D | last post by:
I have a simple client/server file server app that I would like to convert to a single .exe. The client is just uses Tkinter and displays a simple GUI. The server has no GUI and just listens for...
2
by: K.S.Wong | last post by:
Hi all, I am trying to find out what tools (platform-independent if possible) that I can use to package a goup (few) of installers to become an exe application. I have heard of Py2exe but have...
5
by: DarkPearl | last post by:
Bonjour à tous, apres avoir créer un service windows avec py2exe, j'ai ce probleme quand je lance le service : voici ce que je trouve dans le journal d'evenement : The instance's SvcRun()...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.