Checking if ArcGIS extension has already been checked out manually using ArcPy

519
0
11-06-2020 07:28 AM
LuizaCintra_Fernandes
New Contributor

Hello,
I have to map if a user uses some ArcMap extention in the day. I figured out a script that checks if the extention is working or not, by testing each one and reading the error message. These script works fine if I run it inside arcmap, but as standalone script it isn't working. 
Is there anyway that I can do it as standalone script? Or any other way to checked if these extensions are checked out? 
Or I can schedule a script inside arcmap to run everytime users started it or close?

My script is bellow:

!

#class to check extentions
class lista_ext():
#initialize the list
def __init__(self):
self.l=[]

#get list values
def getlist(self):
return self.l
'''
Test if the extension is turned on.
If there error given is different from '000824',
this mean that the extension is on and tried to exceute
'''
def testarextension(self,e,name):
if str(e).find('000824') ==-1:
self.l.append(name)
return self.l

def testarfuncoes(self):
'''
Test one function from each extension.
The function chosen it's not supposed to work and will show an error message anyway
'''
try:
arcpy.Idw_3d(1)
except Exception:
e = sys.exc_info()[1]
self.testarextension(e,'3D Analyst')
try:
arcpy.IDW_ga(1)
except Exception:
e = sys.exc_info()[1]
self.testarextension(e,'Geostatistical Analyst')
try:
arcpy.Solve_na(1)
except Exception:
e = sys.exc_info()[1]
self.testarextension(e,'Network Analyst')
try:
arcpy.UpdateDiagram_schematics(1)
except Exception:
e = sys.exc_info()[1]
self.testarextension(e,'Schematics')
try:
arcpy.sa.Int('1.1')
except Exception:
e = sys.exc_info()[1]
self.testarextension(e,'Spatial Analyst')
try:
arcpy.TrackIntervalsToFeature_ta(1)
except Exception:
e = sys.exc_info()[1]
self.testarextension(e,'Tracking Analyst')
return self.l

0 Kudos
0 Replies