← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #678681]: Sikuli 1.1.3: Is it possible to trap syntax errors?

 

Question #678681 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/678681

    Status: Needs information => Open

Ron Turrentine gave more information on the question:
RaiMan,

Thanks for replying!

Here are the relevant lines from my script.
This is a FOR loop which loops through the scripts that are returned by my database query.
Each script is executed by the "execfile" line.
This is ran within a try-except block.  If an exception is through, it logs the error and exits the script.
If you need to see the rest of the script, too, please just let me know!

-----------------------------------------------------------------------------------------------------------

    # iterate through scripts in array and run each one in succession
    for sn in range(len(scriptnames)):
        
        
        if os.path.exists(scriptnames[sn]):
            # Point to where the scripts images are stored
            setBundlePath(scriptnames[sn])
        
            # Grab base Sikuli filename
            basename = os.path.splitext(os.path.basename(scriptnames[sn]))[0]

            #Write line to log file
            line = str(datetime.datetime.now()) +  ": Processing script = " + scriptnames[sn] + "\n"
            WriteToPDALog(pda_errorlog, line)
    
            # Get name of relative Python script in Sikuli folder
            pyname = basename + ".py"

            joinedname = os.path.join(scriptnames[sn], pyname)

            #Execute the current script:
            retcode = execfile(joinedname)

            #Write metrics & "completed" info to log file
            line  = str(datetime.datetime.now()) +  ": Captured " + str(myPDA.Screenshots) + " screenshots; recorded " + str(myPDA.Errors) + " errors; downloaded " + str(myPDA.DLFiles) + " files; split " + str(myPDA.WSSplit) + " worksheets.\n"
            line += str(datetime.datetime.now()) +  ": Completed processing " + basename + "script.\n"
            line += str(datetime.datetime.now()) +  ": **********************************************************************************\n"
            
            WriteToPDALog(pda_errorlog, line)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.