Check for 'http' key and return None if not found. Also removed some redundancies and improved readability.
Resolves #282: Mysterious "'http'" printed for unknown reason
Details
When running my program, the message 'http' appears in the output with no apparent source at first. After debugging, I found it was an exception being caught on line 336 of arcresthelper.securityhandlerhelper.securityhandlerhelper.__init__(). Commenting out this except block, I found that this exception was being thrown:
Line 298 contains a call to arcrest.manageorg._portals.Portal.featureServers(), which on line 992 of that file, attempts to access the 'http' key without checking for it first:
res = urls['urls']['features']['http']
The code in Portal.featureServers() is only called by securityhandlerhelper.__init__(), which checks to see whether the return value is None before using it. A safe way to prevent the exception is to check for the 'http' key with a conditional before using it and return None if that fails.
I also removed some repeated code, since that's a common place for mistakes to appear later, and reorganized and reformatted this method to improve readability.
TL;DR
Check for
'http'
key and returnNone
if not found. Also removed some redundancies and improved readability.Resolves #282: Mysterious "'http'" printed for unknown reason
Details
When running my program, the message
'http'
appears in the output with no apparent source at first. After debugging, I found it was an exception being caught on line 336 ofarcresthelper.securityhandlerhelper.securityhandlerhelper.__init__()
. Commenting out thisexcept
block, I found that this exception was being thrown:Line 298 contains a call to
arcrest.manageorg._portals.Portal.featureServers()
, which on line 992 of that file, attempts to access the'http'
key without checking for it first:The code in
Portal.featureServers()
is only called bysecurityhandlerhelper.__init__()
, which checks to see whether the return value isNone
before using it. A safe way to prevent the exception is to check for the'http'
key with a conditional before using it and returnNone
if that fails.I also removed some repeated code, since that's a common place for mistakes to appear later, and reorganized and reformatted this method to improve readability.