Post

3 followers Follow
0
Avatar

License check in Python

Folks,

When I'm using the API and something isn't licensed, I see a license error screen and then get kicked out of Python. It looks like a sys.exit() is being triggered. Is there any way to avoid this and capture the fact that a license is unavailable?

Thanks

Yusuf Siddiqui
Senior Solutions Engineer
i-cubed

Yusuf Siddiqui

Please sign in to leave a comment.

3 comments

0
Avatar

Hi Yusuf,

Usually when a specific algorithm is not licensed you will receive the error "An error has occurred during the processing of your software license key(s)." However, this error may not appear depending on the IDE that you are using. Are you running Python in an IDE, in CMD or through Focus?

Also, which algorithm are you trying to run when you encounter the problem?

Thanks,
Sarah

Sarah Thompson 0 votes
0
Avatar

I am using Python in the Command Prompt. When trying to import a PCI module, it exits Python with an error message like the one you mentioned. The module I am trying to load is any module that is not licensed. For example, yesterday we had no license for the "dn2toa" program (which later got fixed). Another example would be a machine that has PCI Geomatica installed, but does not have a valid license.

I would like to trap this error somehow, like this:

try:
import <module>
except:
print "Can't load PCI module due to license error"

Yusuf Siddiqui 0 votes
0
Avatar

Hi Yusuf,

I agree that it would be better to be able to capture the error message without exiting python. This is not currently possible but I have filed a bug to get the license error reporting changed. The developers will look into this and investigate the options on how to best handle these errors going forward.

Sarah

PCI Geomatics 0 votes