I have an existing project that has a few media files. I have frequent updates to these media files as well as occasional form updates. I need a python script that I can run via scheduler that will publish this project nightly. I have read a bunch of posts but cant find anything clearly stated that shows how to do this. Is there anyone out there that can help provide a solution?
Hi @JamesKelly4 @jaykapalczynski @DougBrowning ,
Note that @ZacharySutherby has provided an updated copy of the script using Python 3 and some other improvements. See this comment here: https://community.esri.com/t5/arcgis-survey123-questions/updating-csvs-in-agol-for-select-one-from-f...
Regards,
Phil.
What zip file? I have to create a Zip file everytime?
Hi @jaykapalczynski,
If you are using either of the python scripts that are linked to the above comments to update CSV files or other media files, it downloads the Form item (which is a zip file), extracts it, you then update the items, and the script then re-creates the zip file again, and uploads its.
Note that this process does not update the XLSForm itself, the only way to do that is via publishing the survey again via Connect, as the xlsx file has to be converted to xml and other form item information updated. The script can only be used to update media files without publishing.
Regards,
Phil.
Im confused....I know I have the correct Credentials but keep getting coming up with a NULL for the token I am trying to get via the script.
This returns NULL...any thoughts
print "token: " + json.dumps(agol_helper.token)
NOTE: I have ArcMap 10.8.1 installed. I have python 2.7 and python 3.4 on my machine. Could this be causing the issue? If so is there a way that I can specify to use python 2.7?
It appears I am using 2.7.18
print ("...Starting")
# initialize the portal helper class
# ago.py is part of the 10.3 python install
agol_helper = ago.AGOLHelper(portal_url)
print portal_url
print ("...Authenticating")
# login
print credentials['userName']
print credentials['passWord']
agol_helper.login(credentials['userName'], credentials['passWord'])
print "token: " + json.dumps(agol_helper.token)
print ("...Querying")
# get the name of the zip file
serviceInfo = getServiceDefinition(agol_helper.token, itemID)
Noting that I updated the "portal_url" parameter for my AGOL online account....line 11
# User Parameters
# ItemID of the Form item you want to update
itemID = "00da9adCr45f4f15b3443ecadd81vfgh"
# Local folder where the Form data will be downloaded (include a / at end of path)
download_folder = "C:/Users/tjv34534/Desktop/CWD_Project/Update_Media_Folder/"
# Updated file name (ie MyList.csv)
updated_file = "CheckQuery.csv"
# Folder path of the updated file (include a / at end of path)
source_loc = "C:/Users/tjv34534/Desktop/CWD_Project/Update_Media_Folder/UpdatedMediaFiles/"
# Address of your ArcGIS portal
portal_url = r"https://xxxxxx.maps.arcgis.com/"
# ArcGIS user credentials to authenicate against the portal (case sensitive)
credentials = {'userName' : 'xxxxx', 'passWord' : 'xxxxx'}
# ArcGIS portal security type (LDAP, NTLM, OAuth, Portal, PKI)
security_type = "Portal"
Hi @jaykapalczynski,
As @ZacharySutherby points out in this post here and I mentioned in one of my comments above, the original update media folder script is now outdated and contains modules that have been superseded by the ArcGIS API for Python.
We have updated this script to use the ArcGIS API for python and the updated script is present in our Survey123-tools github repo.
Regards,
Phil.
OK I think I have this working from ArcGIS Pro on my Laptop....it appears to be updating and uploading this to AGOL.
Most Important
How do I automate it to run when I want it to. I am new to using Pro and it appears to be baked into an ArcGIS Pro project?????
Just stick this line in there and it will grab the credentials from Pro for you.
gis = GIS('pro')
Pro does not even have to be open. Pro retains the token for 2 weeks.
But again as stated you should really switch gears to the new way and let this old way go. Way easier.
Thanks Doug
So if I have the code baked into an ArcGIS Pro project in a "New Notebook" tab how do I automate it to run nightly.
It appears I can no longer use a .py file and use Task Scheduler to run it nightly.
No you can schedule. I run this as a standalone script on schedule no problem. It just goes and grabs the Pro credentials for you.