Script tool fails after first execution

255
1
11-03-2020 03:29 PM
FredSpataro
Occasional Contributor III

Hi All, 

Got an odd one... I feel like I've come across something similar before but it's got me stumped right now.  

Quick Summary:

  • The script tool runs successfully outside of ArcMap/Catalog via python CLI
  • The script tool runs successfully the FIRST time run from the toolbox inside ArcMap/ArcCatalog
  • The script tool FAILS every time after the first until ArcMap/ArcCatalog is closed and restarted
  • The function in the script tool runs successfully if called multiple times from a second script tool during the same execution but then fails with the same pattern when run consecutively. 
  • The failure is a critical level exception exiting the script:

Traceback (most recent call last):
File "D:\support\arcgis\msal\doauth.py", line 21, in <module>
result = get_token()
File "D:\support\arcgis\msal\doauth.py", line 14, in get_token
client_credential=""
File "C:\Python27\ArcGIS10.6\lib\site-packages\msal\application.py", line 239, in __init__
self.http_client, validate_authority=validate_authority)
File "C:\Python27\ArcGIS10.6\lib\site-packages\msal\authority.py", line 85, in __init__
self.http_client)
File "C:\Python27\ArcGIS10.6\lib\site-packages\msal\authority.py", line 142, in tenant_discovery
resp = http_client.get(tenant_discovery_endpoint, **kwargs)
File "C:\Python27\ArcGIS10.6\lib\site-packages\requests\sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "C:\Python27\ArcGIS10.6\lib\site-packages\requests\sessions.py", line 516, in request
prep = self.prepare_request(req)
File "C:\Python27\ArcGIS10.6\lib\site-packages\requests\sessions.py", line 455, in prepare_request
headers=merge_setting(request.headers, self.headers, dict_class=CaseInsensitiveDict),
File "C:\Python27\ArcGIS10.6\lib\site-packages\requests\sessions.py", line 69, in merge_setting
merged_setting = dict_class(to_key_val_list(session_setting))
File "C:\Python27\ArcGIS10.6\lib\site-packages\requests\structures.py", line 46, in __init__
self.update(data, **kwargs)
File "C:\Python27\ArcGIS10.6\Lib\_abcoll.py", line 564, in update
if isinstance(other, Mapping):
File "C:\Python27\ArcGIS10.6\Lib\abc.py", line 144, in __instancecheck__
return cls.__subclasscheck__(subtype)
File "C:\Python27\ArcGIS10.6\Lib\abc.py", line 180, in __subclasscheck__
if issubclass(subclass, scls):
File "C:\Python27\ArcGIS10.6\Lib\abc.py", line 180, in __subclasscheck__
if issubclass(subclass, scls):
File "C:\Python27\ArcGIS10.6\lib\site-packages\typing.py", line 1410, in __subclasscheck__
return super(GenericMeta, self).__subclasscheck__(cls)
TypeError: super() argument 1 must be type, not None

Details:

The script tool integrates data between a feature class and an external API behind an AzureAD authentication. 

I've installed the official Microsoft library

c:\Python27\ArcGIS10.6\Scripts\pip.exe install msal

The failure is not in the actual call for an authorization token but simply in the init constructor of the 'AD App' class so I'm able to strip it down to a very basic example which is attached in the zip file:

1. doauth.py - script file with function that initializes the 'AD App' and returns a true/false if the app class is created

2. doauth2.py - script file that calls the 'create app' function inside doauth.py twice in a row 

   This was an attempt to see if it's something with multiple instances of the app class being created or if it's something specific with how ArcMap/Catalog are running the script itself.... appears to be the latter

3. toolbox.tbx - toolbox with both scripts attached as tools

To repo:

1. install msal (see above) 

2. CLI tests (execution is successful, no exceptions throw, simple text output returned)

   c:\Python27\ArcGIS10.6\Scripts\python.exe doauth.py

   c:\Python27\ArcGIS10.6\Scripts\python.exe doauth2.py

3. Open ArcCatalog

   Browse to toolbox

   Execute DoAuth tool - success, close window

   Execute DoAuth tool - fail 

   Close ArcCatalog 

   Repeat 

 

Any thoughts? 

Thanks in advance 

Tags (1)
0 Kudos
1 Reply
PugazhendhiNatarajan
New Contributor

Hi Fred,

i am also getting similar error, did you find any workaround for this?

Thanks

0 Kudos