[request] want an exit handler for running scripts, that is executed when the script terminates for whatever reason
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SikuliX |
In Progress
|
Medium
|
RaiMan |
Bug Description
Hey, I've been trying to find out how to do this for a while.
I have a program which is step-based.
I want to be able to execute some code if and when my Sikuli script stops running. And it needs to be for ANY reason (invalid image found/user stops the program (shift+alt+c)/user quits the program when being prompted) except for reasons like invalid Python code.
Basically what I need to do if and when the program quits due to either user input or an error is I need to open up a file and write a step number to it. It's just the error handling that I'm a bit stumped about.
Some exploration has led me to believe that I'd need to do something with a try... except... statement. But I don't know how exactly to go about it.
Any help is appreciated. Thanks in advance.
P.S. There is a workaround I can easily use, which is to write the number of the step to the file as the user begins the step, but I feel that it's inefficient and bad practice to do it every single step rather than when it really needs to be done. But if there is no better way to do it then I'll have to fallback on that.
summary: |
- [request] want an exit handler for running scripts, that is executed if - the script terminates for whatever reason + [request] want an exit handler for running scripts, that is executed + when the script terminates for whatever reason |
Changed in sikuli: | |
status: | New → In Progress |
importance: | Undecided → Low |
assignee: | nobody → RaiMan (raimund-hocke) |
milestone: | none → 1.1.0 |
milestone: | 1.1.0 → 1.2.0 |
Changed in sikuli: | |
milestone: | 2.0.0 → 2.1.0 |
Changed in sikuli: | |
importance: | Low → Medium |
Hello,
Python like Java works with exception.
try:
# Your code
except :
# Your action where there is some problem.
Regards