I tried that, but I still get an error.  Here is another example:

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!


I tried 'except win2file.error:' and it was still not handled by the script.
The only way I could get it to work was with 'except:'

-----Original Message-----
From: Mark Hammond [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 25, 2001 5:54 PM
To: Robin Siebler; [EMAIL PROTECTED]
Subject: RE: Exception handling


> def start_service(service, machine):
>     """Start a service"""
>     win32serviceutil.StartService(service, machine)
>     result = 1  #Service started successfully
>
> If I try to start a service and it is already running, I get the following
> error:
> api_error: (1056, 'StartService', 'An instance of the service is already
> running.')
>
> How would I use exception handling to catch this?

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

Mark.
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython

Reply via email to