By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,814 Members | 1,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,814 IT Pros & Developers. It's quick & easy.

service windows avec py2exe

P: n/a
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',
None, None)

je n'arrive pas du tout à trouver le probleme.

Peut etre que quelqu'un d'entre vous sais...

Merci

Nov 10 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Sorry for language, i wanted post in FR.comp.lang.python.

But...

hello with all, after having to create a Windows service with py2exe, I
have this problem when I launch the service: here what I find in the
eventLog:

The instance's SvcRun() method failed
<Error getting traceback - traceback.print_tb() failed
<class 'pywintypes.com_error'>: (-2147221020, 'Syntaxe incorrecte',
None, None)

I don't find a the problem.

If you can help me, thank's

Nov 10 '06 #2

P: n/a
At Friday 10/11/2006 08:15, DarkPearl wrote:
>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',
None, None)
Try with a small sample application then adding
more functions, to see where it fails.
(Pardonnez moi, je ne sais pas assez pour répondre en française)
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
Nov 10 '06 #3

P: n/a
I found the function which starts the error

**********************************
class Win32ProcessUsage:
def __init__(self):
self.lstProcess=[]
self.WMIService =
win32com.client.GetObject(r"winmgmts:{impersonatio nLevel=impersonate}!\\.\root\cimv2")
self.reset()
def reset(self):
self.lstProcess=[]
lstTmp = self.WMIService.ExecQuery('Select * from
Win32_Process')
for item in lstTmp:

self.lstProcess.append(tuple([item.Name,item.CommandLine,item.Status,item.Proces sId,item.ParentProcessId]))

def get_usage(self):
return self.lstProcess
**********************************

it is a class which allows to obtain the list of the processes who run.

With python interpreter, this class functions very well but , when it
turns in service, it starts the error :

The instance's SvcRun() method failed
<Error getting traceback - traceback.print_tb() failed
<class 'pywintypes.com_error'>: (-2147221020, 'Syntaxe incorrecte',
None, None)

Why ???

Nov 11 '06 #4

P: n/a
ok,

It's this line who crash the service :

self.WMIService
=win32com.client.GetObject(r"winmgmts:{impersonati onLevel=impersonate}!\\.\root\cimv2")
why this function goes when it is not a service?

with IDLE -ok
with py2exe executable (no windows service) -ok
with py2exe service option true (windows service) -CRASH....

Nov 12 '06 #5

P: n/a

DarkPearl wrote:
ok,

It's this line who crash the service :

self.WMIService
=win32com.client.GetObject(r"winmgmts:{impersonati onLevel=impersonate}!\\.\root\cimv2")
why this function goes when it is not a service?

with IDLE -ok
with py2exe executable (no windows service) -ok
with py2exe service option true (windows service) -CRASH....
OK. I think I can help here. WMI is a COM/DCOM-based technology.
Windows services are inherently multithreaded. Therefore you need to
Initialize a COM threading model specifically even though you're not
really using threads yourself.

Try putting:

import pythoncom
pythoncom.CoInitialize ()

somewhere before the line which instantiates the WMI
object (the one you quoted above).

I have no idea why this usually manifests itself as a
"Syntax Error" but it does!

TJG

Nov 12 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.