I'm trying to run the scrip mentioned in this help article to see if my org has any deprecated configurable apps in use. However, I get an error "NameError: name 'display' is not defined".
Any suggestions on how to fix this script?
How To: Identify Deprecated Configurable Apps in ArcGIS Online Using a Python Script
from arcgis.gis import GIS
from getpass import getpass
org_url = "https://<org_short_url>.maps.arcgis.com" #e.g. "https://myorg.maps.arcgis.com" or "https://myportal.domain.com.portal"
#For a built-in user:
username = "<username>" #Provide an Admin user (built-in)
pw = getpass()
gis = GIS(org_url, username, pw)
#for a SAML-based or OIDC-based user (you will need to register a client ID to use to authenticate
#gis = GIS(org_url, client_id=<client_id>)
#Search for all Web Mapping Applications in an organization
apps = gis.content.search(query="",item_type="Web Mapping Application", max_items=10000)
#Define the list of deprecated Configurable Web Apps and other templates
deprecated_portal_apps = [
'apps/3DViz/index.html',
'apps/AttachmentViewer/index.html',
'apps/FilterGallery/index.html ',
'apps/CompareAnalysis/index.html',
'apps/Compare3d/index.html',
'apps/Directions/index.html',
'apps/Editor/index.html ',
'apps/Profile/index.html',
'apps/InteractiveFilter/index.html',
'apps/ImageInterpretation/index.html ',
'apps/ImageryViewer/index.html ',
'apps/ImpactSummary/index.html ',
'apps/InformationLookup/index.html ',
'apps/InteractiveLegend/index.html',
'apps/LayerShowcase/index.html',
'apps/LocalPerspective/index.html ',
'apps/MapCarousel/index.html ',
'apps/Styler/index.html',
'apps/MapTools/index.html ',
'apps/MapAndAppGallery/index.html ',
'apps/Media/index.html',
'apps/MinimalGallery/index.html',
'apps/Minimalist/index.html',
'apps/LocalPerspective/index.html ',
'apps/PublicGallery/index.html ',
'apps/PublicInformation/index.html ',
'apps/Styler/index.html',
'apps/3DInsetMap/index.html ',
'apps/SimpleViewer/index.html',
'apps/3DScene/index.html ',
'apps/StoryMapBasic/index.html',
'apps/Cascade/index.html',
'apps/MapJournal/index.html',
'apps/MapSeries/index.html',
'apps/MapShortlist/index.html',
'apps/StorytellingSwipe/index.html',
'apps/MapTour/index.html',
'apps/SummaryViewer/index.html ',
'apps/TimeAware/index.html',
'apps/ZoneLookup/index.html',
'apps/Viewer/index.html',
'apps/Solutions/s2.html?appid=',
'apps/GeoList/index.html',
'apps/Elevations/index.html',
'apps/View/index.html',
'apps/Compare/index.html',
'apps/CrowdsourceManager/index.html',
'apps/CrowdsourcePolling/index.html',
'apps/CrowdsourceReporter/index.html',
'apps/GeoForm/index.html',
'apps/ImageMask/index.html',
'apps/ImageVisit/index.html',
'apps/Viewer/index.html'
]
# Page through app items to check against list
problem_apps = []
for app in apps:
if app.url is None: continue
try:
if "/apps" in app.url and org_url in app.url:
if any(a in app.url for a in deprecated_portal_apps):
app_data = app.get_data()
if "values" not in app_data:
continue
for key, value in app_data["values"].items():
if key in ["webmap", "group"]:
problem_apps.append([app.title, app.url, app.numViews, app.id, app.owner, key, value])
except Exception as error:
print(f"Issue checking app: {app.title}\nError: {error}")
continue
#Sort apps by URL and Print List
problem_apps_sorted = sorted(problem_apps, key = lambda x: x[2], reverse=True) #To sort by Views descending, change x[1] to x[2]
import pandas as pd
df = pd.DataFrame(problem_apps_sorted, columns=["Title","URL","Views","App ID", "Owner", "App Source", "Source ID "])
left_aligned_df = df.style.set_properties(**{'text-align': 'left'})
with pd.option_context('display.max_rows', None,
'display.max_columns', None,
'display.max_colwidth', 0
):
display(left_aligned_df)