|
POST
|
I've got a number of python scripts that download copies of ArcOnline feature services as part of a nightly backup routine (in lieu of anything simpler). At present, the python script logs into ArcOnline, accesses the hosted feature service and exports a copy of the data to a feature class in a GDB on our server. This python script is then called by Task Scheduler on a nightly basis (user logged off with highest privledges). Last month (while I was on leave), the server was moved from physical on-premises to cloud based, and we started getting the below Error: Exception: 'LOCALAPPDATA' I can't find anything online that really points out what the error is or how to fix it. I assume it's an issue accessing the temporary data environments. When I log in and run the script manually (even through Task Scheduler), it works without any problems. It only happens once logged off. I tried running the following script in IDLE, but that also didn't yield any positive results. import arcpy
# Reset geoprocessing environment settings
arcpy.ResetEnvironments() I've tried finding inbuilt environment settings in IDLE (for ArcGIS Pro) but couldn't so don't know where else to look. I've included my script below so that you can analyse it more in depth. from datetime import datetime, timedelta, date
# *****Update the below 6 lines*****
name = "FS Name" #Name of dataset for use in error email notification
url_fl = "https://services3.arcgis.com/#X#X#X#X#X#X#X#X#X/arcgis/rest/services/FSName/FeatureServer/0" # Service URL for feature layer to download as feature class
destGDB = r"\\server\ArcGIS Online\AGOL Backups\Backups.gdb" #The GDB where the backup feature class will be created
destFC = "FC Name" #The backup feature class name (no spaces - user _ or CamelCase)
monthlimit = datetime.today() - timedelta(days=30) # number of days to keep daily backups
yearlimit = datetime.today() - timedelta(days=365) # number of days to keep monthly backups (1st day of month only) - everything older will be deleted
while True: #If something fails in the main script under "try", the "except" section emails a notification to the GIS Inbox
try:
import arcpy
from arcpy import env
from arcgis import gis
from arcgis.gis import GIS
from arcgis.features import FeatureLayer
import getpass
import json
import requests
from time import strftime
import datetime
def getSecrets():
# Secrets from file stored outside of revison control
with open(r"\\server\file.json") as f:
secrets = json.load(f)
return secrets
secrets = getSecrets()
# Get login credentials # http://docs.python-requests.org/en/latest/user/advanced/
s = requests.Session()
url_gis="https://org.maps.arcgis.com"
s.user = (secrets["username"])
s.pw = (secrets["password"])
#SIGNING INTO ARCGIS ONLINE
print ("Signing into ArcGIS Online")
source = gis.GIS(url_gis, s.user, s.pw) #signing in
print ("Signed into ArcGIS Online")
# CREATING BACKUP OF FEATURE SERVICE # https://community.esri.com/t5/python-questions/using-arcpy-to-copy-a-portal-feature-service-to-a-fgdb-feature/m-p/4285#M394
fl = FeatureLayer(url_fl)
fs = fl.query()
print ("Exporting backup of feature service")
Outputfs = destFC + "_" + strftime("%Y%m%d_%H%M%S")
fs.save(destGDB, Outputfs)
time.sleep(10) #add 10 seconds delay to allow export to complete
print (name + " feature service exported to backup GDB: " + destGDB + "\\" + Outputfs)
print ("Filtering past backups")
arcpy.env.workspace = r"\\server\ArcGIS Online\AGOL Backups\Backups.gdb"
FClist = arcpy.ListFeatureClasses(destFC + "*")
for fc in FClist:
datestamp = datetime.strptime(('{}'.format(fc))[-15:], "%Y%m%d_%H%M%S")
day = (datestamp.day)
print (fc + "..........Backup date:" + str(datestamp))
if datestamp < yearlimit: #data more than 365 days old
print (" Older than 12 months: delete backup")
arcpy.management.Delete(fc)
print ("Deleted")
elif datestamp < monthlimit: #fc more than 90 days old
if day == 1:
print (" 1st of month & 4-12 months old: retain as monthly backup") #fc from 1st of Month and more than 90 days old
else:
print (" Older than 3 months and not the 1st of the month: delete backup")
arcpy.management.Delete(fc) #fc NOT from 1st of Month and more than 90 days old
print ("Deleted")
else:
print (" Less than 3 months old: retain backup")
print ("Script finished")
break # Stops script here
except Exception as e:
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
fromaddr = "us@org.com.au"
toaddr = "us@org.com.au"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = name + " backup process failed"
# Enter email body text below
body = "There has been an error backing up the feature service. Please check the script to troubleshoot any problems. Exception: " + str(e)
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('smtp.org.com.au')
#No login required so this section is commented out
#server.login("youremailusername", "password")
server.sendmail(fromaddr, toaddr, str(msg))
print ("Script failed - email notification sent")
print ("Exception: " + str(e))
break # Stops script here
... View more
01-10-2022
06:45 PM
|
1
|
7
|
3589
|
|
POST
|
Looking into this issue with Paul, could anyone confirm what this setting in the ArcOnline JSON editor might be? I can't find anything through the Googs. We know the layer already supports splitting, and I'm unaware of how/where these settings are relevant.
... View more
01-10-2022
05:38 PM
|
0
|
0
|
6326
|
|
POST
|
Looking into this issue, could anyone confirm what this setting in the ArcOnline JSON editor might be? I can't find anything through the Googs. We know the layer already supports splitting, and I'm unaware of how/where these settings are relevant.
... View more
01-10-2022
04:22 PM
|
0
|
0
|
4927
|
|
IDEA
|
When you open ArcGIS Pro, the notification pops up saying there is an update to install. So I start the process and it downloads 2GB+ of install files then asks for administrator credentials to continue. I enter some credentials and hit enter - except they're the wrong ones. Instead of getting an option to try again (i.e. call our IT department and get their credentials), it just exits the update process. This means that next time I attempt to run the update, if the install files have been cleared, it downloads all the files from scratch. It's also annoying have to open ArcGIS Pro from scratch. It would be good if instead of exiting the update process, it came up with the Options to either Exit, Retry or return to the existing version of ArcGIS Pro.
... View more
01-04-2022
09:02 PM
|
3
|
0
|
507
|
|
IDEA
|
Not that I've figured out or that ESRI support has shown me. Not really satisfied with the explanation I got from them on this one.
... View more
11-20-2021
01:16 AM
|
0
|
0
|
11092
|
|
POST
|
A bit of info for those who are interested. We had a meeting with our ESRI reps earlier this week regarding this topic to see what the options are. Available Now (and has only been available for a few weeks so is still a new offering): @GordonO touched on it above, but you can get offline geofencing capacity through a custom built app that can include any or all of Field Maps functionality plus additional functionality. The catch is you need to engage ESRI to custom build the app (2 - 4 (ish) weeks over a 3 month(ish) period of back and forth work). You have a couple of deployment options (sideload or pursue App Store options at additional cost). This app can draw on your ArcGIS Online services for mapping and geofence designations (using geo-triggers) just like Field Maps can. The app build is a one off cost and then runs inside of your existing ArcGIS Online subscription. In the future: The roadmap includes developing this functionality as a standard offering in Field Maps, but will take time (18 months?). Both of the above scenarios DO NOT require GeoEvent Server (Enterprise) or Velocity (ArcGIS Online). These options instead provide the office-side geofencing notifications and analytics (at a cost - ongoing maintenance) using location feeds (can be any source really - not just Tracker).
... View more
09-07-2021
05:56 PM
|
2
|
1
|
860
|
|
IDEA
|
@MarcelSt-Germain it's been a looooong time since our organisation used XTools. Might need to look into them again.
... View more
09-02-2021
11:56 PM
|
0
|
0
|
1510
|
|
POST
|
I just stumbled on this post which is timely. I spent some time a few days ago trying to find documentation on whether Field Maps had geofencing capabilities, and whether they work in an offline environment. If someone could point me to further documentation that would be great! We're considering the use of geofencing on timber harvesting machines. Currently staff physically mark in the forest what can be harvested or needs to be retained (a LOT of work). We'd like to see a product that not only allows us to geofence no-go areas, but that also alerts both the operator when approaching/crossing a no-go zone boundary, as well as potentially recording that incursion and notifying a manager/supervisor (when sync'd??). We don't yet thave Velocity or GeoEvent Server, so a long way to go, but good to know what is possible.
... View more
08-24-2021
05:29 PM
|
1
|
0
|
4305
|
|
POST
|
In short, what I want to know is can custom basemaps be enabled for offline use? I've followed the guide in this blog post to create and share Custom Basemaps with my org, but I don't seem to be able to use them in a webmap and have that map enabled for offline use in Field Maps. Extra info: my custom basemaps either use the ESRI Terrain or ESRI Imagery basemaps with a Custom Vector Tile Package overlaid within the basemap group of the webmap share to the Custom Basemap Gallery group. The Vector Tile Package is enabled for offline use, as are the webmaps.
... View more
08-23-2021
11:05 PM
|
3
|
8
|
2951
|
|
IDEA
|
Snapping to lines without the need for vertices along the line would be handy - though I would like to think you could adjust the tolerance or disable the function as it is not always desirable.
... View more
08-18-2021
05:52 PM
|
0
|
0
|
1434
|
|
IDEA
|
@RussellBrennan Thanks for the extra info - saved me some trouble with testing.
... View more
07-28-2021
05:47 PM
|
0
|
0
|
5938
|
|
IDEA
|
Hi @RussellBrennan. Thanks for the info - thats welcome news. The workaround you listed is also good to know, though won't help in most cases for me we're using this in Model Builder, so no Undo/Save option. The truncate tool though should do the trick when updated (I and my Team are admins so will work fine) - though unless you can confirm for me, I'll need to test to see if it honours Make Feature Layere to only delete a subset of rows and now the whole table??? I've already swapped Delete Rows out for the Truncate Table tool in some models where all rows are the target and it's a Feature Class, but the killers are those Feature Services, so looking forward to seeing that release.
... View more
07-27-2021
05:05 PM
|
0
|
0
|
5963
|
|
IDEA
|
Thanks for the suggestion @SarahAmbrose1 . I had not previously looked at this tool. Unfortunately, reading through the documentation at the link you provided, this doesn't look like it will work for this problem; This tool does not support a feature service layer as input. Though, I may start implementing it in other models that are modifying Feature Classes in place of the Delete Rows tool. I'll also test to see if it honours Definition Queries and Make Feature Layer for removing only a subset of rows in a table.
... View more
07-26-2021
05:30 PM
|
0
|
0
|
5988
|
|
IDEA
|
@DougMorgenthaler This is unfortunately part of me not getting out of the office enough - for some reason I completely forgot that this can already be done. I still stand by my comments regarding audible alerts though for when streaming stops due to poor accuracy, etc.
... View more
07-25-2021
05:25 PM
|
0
|
0
|
2788
|
|
POST
|
Thanks - a simple solution to an annoying problem. Worked a treat.
... View more
07-22-2021
10:05 PM
|
0
|
0
|
3062
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a week ago | |
| 1 | 08-24-2025 06:11 PM | |
| 1 | 3 weeks ago | |
| 1 | 10-08-2024 09:01 PM | |
| 1 | 06-05-2025 12:17 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|