|
POST
|
I recently had to change a script to point to a different directory to find my SDE connections. When I try to republish the service so the paths are updated on the server, it says that my script contains a broken project data source and then lists the old path, even though the script no longer contains any references to the old path. How do I fix this? This is not the only GP service I've changed the path for; all the other ones I've changed have been able to overwrite the old services without error. Current code with new path: #Get MonitoringPoint, Patches, and PC layers from database.
fa_db_con = r'C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.7\ArcCatalog\FocalAreas_HabitatWriter.sde'
hbw_db_con = r'C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.7\ArcCatalog\HabitatMonitoring_HabitatWriter.sde'
mpFC = fa_db_con + '\FocalAreas.dbo.MonitoringPoint'
patchesFC = hbw_db_con + '\HabitatMonitoring.DBO.Patches'
pcFC = hbw_db_con + '\HabitatMonitoring.DBO.ProtectiveCover' Errors I get when analyzing the service for overwriting: 00068 Script PrintHabitatMap contains broken project data source: C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\HabitatMonitoring_nbcidb_HabitatWriter.sde 00068 Script PrintHabitatMap contains broken project data source: C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\FocalAreas_nbcidb_HabitatWriter.sde 00178 Data: C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\HabitatMonitoring_nbcidb_HabitatWriter.sde, used by Script PrintHabitatMap cannot be copied to the server 00178 Data: C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\FocalAreas_nbcidb_HabitatWriter.sde, used by Script PrintHabitatMap cannot be copied to the server The folder "...Desktop10.6\ArcCatalog\..." doesn't even exist on my computer. Regardless, I ran this code anyway to see if it would do anything (it didn't): #(I typed out the full old path)
arcpy.env.workspace = 'C:\Users...\HabitatMonitoring_nbcidb_HabitatWriter.sde'
arcpy.ClearWorkspaceCache() Next, I validated all my connections: I have tried to see if changing the names of the connections listed in the Data Store to match that of the new paths in the script makes it publishable, but no luck (e.g. FocalAreas_nbcidb_HabitatWriter gets changed to the new name which is FocalAreas_HabitatWriter). I have made sure no draft services exist in the "Staging" folder that are caching that path. I have even deleted the PrintHabitatMap geoprocessing service altogether to see if I could just publish a fresh one and it still won't let me. The PrintHabitatMap geoprocessing service takes some MXDs out of a registered folder and alters them according to user input. I have since checked the option in the MXDs for storing relative paths on and I have reset the data sources for all the data in the MXDs to be sure they are pointing to the right locations. I then copied those MXDs into the appropriate folder on the server machine (the registered folder is in a different location on each machine, hence the copying). I cannot find ANYWHERE with that old path in it. I don't get where that old path is being stored or how the server keeps finding it.
... View more
06-05-2020
01:24 PM
|
0
|
1
|
1279
|
|
POST
|
Thanks, I was able to implement two solutions and both work equally well. I went with keyring because it seems more secure than just creating a separate python module to import into the script to get the username/password from. I'll document exactly what I did for the sake of clarity when others come across this question. Option #1: Create a separate python module Basically, you have two scripts. One .py file with your code doing whatever you want upon login, the other .py file with your username and password: #credentials.py
username = MyUserName
password = MyPassword Then import that module into your code that's running whatever you want: import arcpy
from credentials import username, password
#Log into whatever with username and password variables to do stuff
Option #2: Use keyring Pip install keyring into the ArcGIS python interpreter. Open Credentials Manager (windows) on your computer from the control panel. Go to Windows Credentials > Add Generic Credential. Fill out the internet or network address with any name (you'll reference it as a service name in your python script). Fill out the username and password with the appropriate credentials for whatever application you want your python script to login to. In your python script that utilizes these credentials: import arcpy, keyring
#The username should be what you entered as a username in the credentials manager
username = 'MyUserName'
#The first argument is whatever you entered as the internet/network address in credentials manager
password = keyring.get_password('AGSServicesStatus', username)
... View more
06-01-2020
05:43 AM
|
4
|
0
|
7585
|
|
POST
|
I'm trying to automate a process of checking to see if my server services are running every morning. I'm following this example script, but I need to store my credentials in the script as I will be running it in the early morning hours and will not be sitting there to input my credentials every time it runs. Hard-coding my username and password into the script seems like a bad idea since it will be connecting to the internet by making web requests, so how do I go about obscuring or encrypting it? This will be a standalone python script run using windows task scheduler. Working with ArcMap and Enterprise 10.7, python 2.7.
... View more
05-28-2020
06:15 AM
|
0
|
3
|
7678
|
|
POST
|
I was reading through the documentation a little more closely and I think I figured out that the start/stop operation is about undoing edits. So if you do all your edits in one operation, if you script "undo operation" because you hit an exception or something, it will undo everything enclosed in the matching start/stop operation lines. If this is true, it behooves you to use multiple start/stop operations, so if you edit something without hitting an exception, and then you switch to a different feature class to edit and hit an exception there, you can undo the edit on just the last section that hit the exception rather than undoing the "successful" edits too. Like this (disclaimer: I don't know if the order of the editing operations is syntactically correct in this script): editor.startEditing(False, False)
editor.startOperation()
try:
#edits on first feature class
#This was successful
except:
#do something
editor.stopOperation()
editor.startOperation()
try:
#insert rows in second feature class
#When inserting a row, an exception is thrown or something goes wrong
except:
editor.stopOperation()
editor.undoOperation()
#This will undo just the last attempted edits in the previous try statement, but will not undo the edits that succeeded in the first try statement
editor.stopOperation()
editor.stopEditing(True)
del editor
... View more
05-28-2020
06:10 AM
|
1
|
1
|
1416
|
|
POST
|
I'm trying to understand the editor in arcpy and I notice there is a startEditing method and a startOperation method. I'm wondering what the cadence is to using the startOperation method, I don't really get what it's purpose is. Right now, this is essentially how I do my edits: collector_db_con = r"Database Connections\CollectorSpatialData_CollectorWriter.sde"
editor = arcpy.da.Editor(collector_db_con)
editor.startEditing(False, False)
editor.startOperation()
#Create cursor one
#Do insert/update
#Delete cursor one
#Create cursor two
#Do insert/update
#Delete cursor two
#Create cursor three
#do insert/update
#Delete cursor three
editor.stopOperation()
editor.stopEditing(True)
del editor Are you supposed to be using start/stop operation more like this, or like if you were switching between editing different feature classes in the same geodatabase? collector_db_con = r"Database Connections\CollectorSpatialData_CollectorWriter.sde"
editor = arcpy.da.Editor(collector_db_con)
editor.startEditing(False, False)
editor.startOperation()
#Create cursor one
#Do insert/update
#Delete cursor one
editor.stopOperation()
editor.startOperation()
#Create cursor two
#Do insert/update
#Delete cursor two
editor.stopOperation()
editor.startOperation()
#Create cursor three
#do insert/update
#Delete cursor three
editor.stopOperation()
editor.stopEditing(True)
del editor
... View more
05-22-2020
08:47 AM
|
0
|
3
|
1476
|
|
POST
|
Hey Matt...this is pretty funny but I’m betting I went to grad school with you at NCSU . I too am wondering this very same thing. I am using a filter on a string field that gets updated overnight to filter out the features, but the only way you can get downloaded maps to “show” (which is really hiding) the filtered features is to delete it and re-download it. It does not update after syncing and setting a refresh interval on the layer only works for live maps. I'm restricted to using Classic though, so it may be that that's a problem in itself.
... View more
04-24-2020
03:41 AM
|
0
|
0
|
1288
|
|
POST
|
I have a layer that has a filter on it. Overnight I run a script that alters the attribute this filter acts on. Here is the scenario I'm working with: Filter (display all features that match): EditingPhase field is "Editable" Overnight, the script changes the EditingPhase field value to "Not Editable", thus the feature would be filtered out on the web map and no longer displayed. The downloaded map still shows the features that should have been filtered out after refreshing/re-syncing the map. Does that mean the only solution is to re-download the map to get the filter to work correctly?
... View more
04-23-2020
03:40 PM
|
0
|
1
|
1258
|
|
POST
|
Answer: countNumQuery = "DatePart(year, created_date) = {0} AND MonitoringPointID = '{1}'".format(countYear, MPID) The only documentation on DatePart() I could find from ESRI was this page about using it in Field Calculator; How To: Extract a portion of the Date field, thus the documentation is incomplete. I assume it wasn't working because it was an extraction format of VB, but there's no documentation that I could find that gave examples of python. I found my answer on another GeoNet thread that was tangentially related to my question.
... View more
04-23-2020
08:55 AM
|
1
|
0
|
1211
|
|
POST
|
I have a created_date field in my (SDE) feature class. This selection by attributes statement works in ArcMap but I get an "Invalid Expression" error when trying to run it in arcpy. I have printed out the query and it looks to be probably formatted regarding quotations, but obviously I'm not typing it right and I wonder if I need to alter the "DatePart()" part of the formula. countNumQuery = "DatePart(''"'yyyy'"'', created_date) = {0} AND MonitoringPointID = '{1}'".format(countYear, MPID) Prints like this: DatePart("yyyy", created_date) = 2020 AND MonitoringPointID = '{4FE9BDAB-9EBB-4947-93E5-244170084B54}' I've also tried this with no luck "EXTRACT(YEAR FROM created_date) = {0} AND MonitoringPointID = '{1}'".format(countYear, MPID) countYear is a integer. MonitoringPointID is a GUID. This works in ArcMap:
... View more
04-23-2020
08:40 AM
|
0
|
1
|
1252
|
|
POST
|
That's not really what we're looking for though. It's a 1-M relationship between points. The "many" part of that has to start off as a blank slate. It's really a problem of the slowness of placing the points, not filling out the fields.
... View more
04-22-2020
08:46 AM
|
0
|
0
|
2361
|
|
POST
|
I haven't investigated it very thoroughly, but at cursory glance it doesn't appear that it supports related data so unfortunately it wouldn't work for our purposes. I would love to be proven wrong though.
... View more
04-22-2020
08:44 AM
|
0
|
0
|
2361
|
|
POST
|
I have a scenario that I want to use in Collector, but I'm thinking it's probably not how the "filter" arcade expression is intended to be used in Collector and won't work. I would test it, but I'm just not adept enough at arcade to figure out if I'm doing it right or not. Arcade expressions are only applied to fields correct? Not the actual features themselves? That's why I'm thinking this might not work. Scenario: A bird survey is done twice at the same monitoring points each season. The first survey gets completed so there's a bunch of data around the monitoring point. When they go out for the second survey, I don't want to see that data anymore; essentially I want to start with a "clean" monitoring point (while still having the first survey stored in the database obviously). Is this possible with a filter arcade expression? If it is possible, will the first survey data still be inaccessible to edit by them down the line? I can hide the data using a filter when I set up the web map online, but then it makes that first set of survey data inaccessible to them on collector which I'd like to avoid. Basically, I need to be able to show/hide individual pieces of data dynamically in Collector. Ideas welcome.
... View more
04-22-2020
08:29 AM
|
0
|
0
|
787
|
|
POST
|
Classic allows you to place a point by just tapping on the screen. With Collector you have to click and drag the crosshairs making data collection MUCH slower. We are doing surveys where birds call rapidly, thus speed of collection is important.
... View more
04-22-2020
08:21 AM
|
0
|
2
|
2361
|
|
POST
|
I don't have an answer to my question, but I'm just going to use append which is probably a more proper way to do it anyway.
... View more
04-17-2020
03:26 PM
|
0
|
0
|
1370
|
|
POST
|
This is collector classic so no troubleshooting logs available. Device is iPhone 11 Pro with lastest software updates. Version of Collector is 19.0.2
... View more
04-17-2020
02:10 PM
|
0
|
4
|
2361
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-18-2020 10:31 AM | |
| 2 | 09-16-2025 02:17 PM | |
| 3 | 09-12-2025 09:26 AM | |
| 1 | 08-16-2023 05:11 PM | |
| 1 | 02-27-2024 06:48 AM |
| Online Status |
Offline
|
| Date Last Visited |
09-16-2025
02:16 PM
|