Ok, that worked.  Thanks!  I've played around with the first example, but I
still can't get it to work.  Here is my code snippet and the error message:

import win32serviceutil

def start_service(service, machine):
    """Start a service"""
    try:
        win32serviceutil.StartService(service, machine)
        result = 1  #Service started successfully
    except win32serviceutil.error:
        print "Service already running!"

Here is the error message:

Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "winsvc.py", line 42, in start_service
    win32serviceutil.StartService(service, machine)
  File "d:\python21\win32\lib\win32serviceutil.py", line 310, in
StartService
    win32service.StartService(hs, args)
api_error: (1056, 'StartService', 'An instance of the service is already
running.')


BTW:  I have been using/evaluating Python for about 2 weeks.  Today I gave a
demo using Python as part of an automated testing solution.  Everyone was
quite impressed!  So now there is one more company out there using Python...


-----Original Message-----
From: Mark Hammond [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 27, 2001 3:57 PM
To: Robin Siebler; [EMAIL PROTECTED]
Subject: RE: Exception handling


> def execute(testpath):
>
>     try:
>         win32file.CopyFile(os.path.join(testpath, 'test.log'),
> os.path.join('d:\\', 'iTest', 'iDir Simple Test', 'OutputData',
> 'test.log'),
> 1)
>     except:
>         return 0 #File already exists!


This works for me.

>>> try:
...     win32file.CopyFile(os.path.join(testpath,
'test.log'),os.path.join('d:\\', 'iTest', 'iDir Simple Test', 'OutputData',
'test.log'),1)
...     print "worked"
... except win32file.error:
...     print "failed"
...
failed
>>>
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython

Reply via email to