Automate Publishing of Survey123 Project

3192
23
08-30-2021 11:49 AM
jaykapalczynski
Frequent Contributor

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?

0 Kudos
23 Replies
jaykapalczynski
Frequent Contributor

Yea I get the gis='pro' thing....

How do you automate a script that is embedded inside the ArcPro project?  Are you using Windows Task Scheduler?

Have you used ArcGIS Notebook Server before?

0 Kudos
DougBrowning
MVP Esteemed Contributor

Its not inside of a Pro project.  Does not need to be, it will still find the Pro login.  I use PyScripter for all editing.  Yes I use task scheduler.

Batch file looks like

"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" "\\some file path\Cert code 2021.py"

0 Kudos
jaykapalczynski
Frequent Contributor

Thanks for your reply's....very appreciated...

I think we are talking about two different approaches....I was trying to use an older .py file but was told that its out of date (see below). 

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

 

Then was told that I should use ArcPro Notebook and the github repo below...because the other one was out of date.

These extended blog posts are so confusing with X amount of potential solutions in them.  I am so confused.  

I am running my code from ArcPRO and from a Notebook Tab...

The Notebook script starts like this and DOES NOT run in a .py file...There is no .py file....

So what does the start of your .py file look like and how does it authenticate....

import arcgis
from arcgis.gis import GIS
import tempfile
import zipfile
import shutil
import os

# Script Parameteres
portalURL = r'https://www.arcgis.com'
username = 'xxxxx'
password = 'xxxxx'
itemID = '00da9adxxxxxxxxxxdd81d290'
updated_files = ['GameCheckQuery.csv']
source_loc = r'C:/Users/Desktop/Project/Update_Media_Folder/Update/'
download_folder = r'C:/Users/Desktop/Project/Update_Media_Folder/Download/'

#----------------------------------------------------------
# Connect to GIS
gis = GIS(portalURL, username, password, verify_cert=False)
#------------------------------------------------
survey_manager = arcgis.apps.survey123.SurveyManager(gis)
surveyId = survey_manager.get(itemID)
surveyProp = surveyId.properties
print(surveyProp)

 

 

 

0 Kudos
ZacharySutherby
Esri Regular Contributor

Hello @jaykapalczynski

Let's schedule a call to discuss the workflow and get it set up and running. Please feel free to email me at ZSutherby@esri.com and we can schedule a call to clear it up. 

Thank you, 

Zach

Thank you,
Zach