Sys.exit but without traceback.....

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
Jupiter
Posts: 24
Joined: Mon Nov 01, 2021 4:56 pm

Sys.exit but without traceback.....

#1

Post by Jupiter »

First, thanks for a great program! I am starting to use the scripting capability. Also, I am brand new to Python.

My goal is to generate a script that would automate the star alignment for an Onstep scope. I have able to run an Onstep python program that uses a Onstep python API after dealing with a few minor language incompatibility (Ironpython vs. "official" Python). I am running on a Windows 10 system.

The Onstep python program now runs on both the "official" Python terminal and on the Sharpcap terminal with no apparent erros....except at the very end of execution the Sharpcap/Iron Python terminal displays a traceback whereas the Python terminal does not display the traceback. My limited understanding is that sys.exit should not inherently generate a traceback.

The traceback appears to be connected with the last line of code in the program which is sys.exit. I searched on this forum and someone recommends using 'return' . I tried that but then the program loops indefinitely.

Is there a way to execute and have the program end without a traceback? TIA.
User avatar
admin
Site Admin
Posts: 13344
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Sys.exit but without traceback.....

#2

Post by admin »

Hi,

you can use

Code: Select all

SharpCap.ExitApplication()
to cause SharpCap to exit cleanly from within scripting.

I'm impressed by the complexity of some of the scripts for various tasks that are now being designed. Please do continue to request things that you would like to be able to do from scripting - sometimes (not every time) they are easy to add and have little risk of breaking other features.

cheers,

Robin
Jean-Francois
Posts: 402
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: Sys.exit but without traceback.....

#3

Post by Jean-Francois »

Hello Robin,

"Please do continue to request things that you would like to be able to do from scripting"

OK, I will do :-)

Regards,
Jean-Francois
Jupiter
Posts: 24
Joined: Mon Nov 01, 2021 4:56 pm

Re: Sys.exit but without traceback.....

#4

Post by Jupiter »

Robin,

Thanks for the prompt reply. I plugged your suggestion in and it didn't work however I have the feeling this has something to do with the program I am trying to run or more specifically, the fact that I am completely new to Python. Please don't invest any more of your time in trying to figure this out. I need to slow down and start with some simple programs and see if I can get those to run cleanly.
Jupiter
Posts: 24
Joined: Mon Nov 01, 2021 4:56 pm

Re: Sys.exit but without traceback.....

#5

Post by Jupiter »

As I thought, it was a problem with the program I was trying to run (improper use of sys.exit in a funciton). The interesting thing that confused me for a while was that it ran without traceback using Python (3.12.0) but gave a traceback on the Ironphython in Sharpcap. Now, with the program corrected, it runs the same in both i.e. no traceback. Thanks again for your help.
User avatar
admin
Site Admin
Posts: 13344
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Sys.exit but without traceback.....

#6

Post by admin »

Hi,

glad to hear it is sorted now. I saw problems when trying to use sys.exit() in a test script here, so I think it is not really well supported by the embedded IronPython in SharpCap - I suspect it tries to shutdown things that are still being used by other parts of the scripting code, but I'm not intending to try to work out what or why.

cheers,

Robin
Post Reply