I have an application called "SAS Enterprise Guide" which is a process flow development program which is compatible with the SAS platform. In it, I create a process flow to my liking, then I can "schedule" it. This "scheduling" process outputs a vbs script and creates a Task Scheduler object. The vbs script creates a COM object, opens the process flow project, runs it, saves it, and then closes it. That's it, overall it's a very short and simple script.
That process is very inefficient for a number of reasons, so I wrote a python script to iterate over a bunch of EG projects (trying to schedule 30+ scripts this way is not feasible).
import win32com.client, os
os.chdir('EG Scripts')
app = win32com.client.Dispatch("SASEGObjectModel.Application.7.1")
for file in os.listdir()
project = app.Open(file, "")
project.Run()
project.Save()
project.Close()
project = None
app.Quit()
app = None
del app
However, their provided vbs script seems to include some error catching, I'd like to do this as well but I'm not sure how. To test, I've created an EG project that will fail 100% of the time. When I run it through python, it just fails silently. I know that script did not successfully execute but nothing was returned or printed in the console.
Within their provided script I see them running these lines:
Set app = CreateObject("SASEGObjectModel.Application.7.1")
If Checkerror("CreateObject") = True Then
Exit Sub
End If
Function Checkerror(fnName)
Checkerror = False
Dim strmsg
Dim errNum
If Err.Number <> 0 Then
strmsg = "Error #" & Hex(Err.Number) & vbCrLf & "In Function " & fnName & vbCrLf & Err.Description
'MsgBox strmsg 'Uncomment this line if you want to be notified via MessageBox of Errors in the script.
Checkerror = True
End If
End Function
But I can't seem to figure how to replicate that in python. Does anyone have any idea?