473,563 Members | 2,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using py2exe to wrap a service?

I have an app using active_director y.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 "win32serviceut il.pyc", line 785, in SvcRun
File "XXProxySvc.pyc ", line 126, in SvcDoRun
File "XXProxySvc.pyc ", line 94, in setup
File "D:\projects\XX Proxy\DB.py", line 54, in loadFromAD
File "active_directo ry.pyc", line 402, in search
File "active_directo ry.pyc", line 398, in root
File "active_directo ry.pyc", line 371, in AD
File "active_directo ry.pyc", line 378, in _root
File "win32com\clien t\__init__.pyc" , line 73, in GetObject
File "win32com\clien t\__init__.pyc" , line 88, in Moniker
pywintypes.com_ error: (-2147221020, 'Invalid syntax', None, None)

The offending line is:
import active_director y as AD
....
for item in AD.search ("objectCategor y='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__.u pdate(kw)
# for the versioninfo resources
self.version = "0.9.0"
self.company_na me = "My Company"
self.copyright = "My Company (c)"
self.name = "FilterProx y"

############### ############### ############### ############### ####
# 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 4134
Ma************* *@accalon.com wrote:
I have an app using active_director y.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 "win32serviceut il.pyc", line 785, in SvcRun
File "XXProxySvc.pyc ", line 126, in SvcDoRun
File "XXProxySvc.pyc ", line 94, in setup
File "D:\projects\XX Proxy\DB.py", line 54, in loadFromAD
File "active_directo ry.pyc", line 402, in search
File "active_directo ry.pyc", line 398, in root
File "active_directo ry.pyc", line 371, in AD
File "active_directo ry.pyc", line 378, in _root
File "win32com\clien t\__init__.pyc" , line 73, in GetObject
File "win32com\clien t\__init__.pyc" , line 88, in Moniker
pywintypes.com_ error: (-2147221020, 'Invalid syntax', None, None)

The offending line is:
import active_director y as AD
...
for item in AD.search ("objectCategor y='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__.u pdate(kw)
# for the versioninfo resources
self.version = "0.9.0"
self.company_na me = "My Company"
self.copyright = "My Company (c)"
self.name = "FilterProx y"

############### ############### ############### ############### ####
# 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.pyth on.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.CoIni tialize () 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_director y 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
3672
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 are commonly available on most platforms except Windows, it would be fairly easy to let py2exe generate a C source file installing this import hook,...
0
5222
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 ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. The...
10
2246
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 requiring a python installation. News Python 2.3 is required, because the new zipimport feature is used.
1
3744
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 python-interpreter and as EXE-prog goes well. running the service-module "FBservice.py" with python-interpreter also works fine but after comiling...
2
2008
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 import glob import py2exe setup(windows=, data_files=,
0
1304
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 installation. Console and Windows (GUI) applications, windows NT services, exe and dll COM servers are supported. This is a bugfix release.
4
1560
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 and processes connections. How can I convert these 2 files to an .exe, while enabling the server app to register as a Windows service? Thanks. ...
2
1373
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 not use it before. Could it be used to wrap different installers (for example Python and Leo, python-based application) together? Does the...
5
2605
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() method failed <Error getting traceback - traceback.print_tb() failed <class 'pywintypes.com_error'>: (-2147221020, 'Syntaxe incorrecte',
0
7664
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.