|
POST
|
No, I did not. We have sort of moved on since we ran into this roadblock but I'll try that trick if we get back to it. Thanks!
... View more
01-17-2023
02:28 PM
|
0
|
0
|
3336
|
|
POST
|
Over the years, I have created a logger component that I copy into each of my python projects and it has worked quite well for me. It is built on top of the standard Python logging support. "info" messages go to both the console and a log file. "debug" messages go only to the log file. It also deletes old log files. The logger is created with this code in logger.py (you can see how you can control which subfolder that logs are stored in and the prefix for the log file name, and the retention time for old log files). I use iPython for debugging so you could ignore/remove that code if it isn't applicable. import os
import sys
import arcpy
import time
import glob
import logging
import logging.handlers
LOG_FILE = os.path.join(arcpy.env.scratchFolder, 'logs', 'fs', 'fs_log_%i.txt' % os.getpid())
# Log handler that forwards messages to ArcGIS
class ArcGisHandler(logging.Handler):
try:
get_ipython()
is_run_from_ipython = True
except NameError:
is_run_from_ipython = False
is_run_from_cmd_line = sys.stdin is not None and sys.stdin.isatty()
def emit(self, record):
if not self.is_run_from_cmd_line and not self.is_run_from_ipython:
arcpy.AddMessage(self.format(record))
# Set up logging
def get(log_name):
# Compute the full path for this process and make sure the directory exists
if not os.path.exists(os.path.dirname(LOG_FILE)):
os.makedirs(os.path.dirname(LOG_FILE))
# Clean up old log files
if not os.path.exists(LOG_FILE):
for file in glob.glob(os.path.join(arcpy.env.scratchFolder, 'logs', 'fs', 'fs_log_*.txt')):
if time.time() - os.path.getmtime(file) > 2 * 60 * 60 * 24:
try:
os.remove(file)
except:
pass
logger = logging.getLogger(log_name)
logger.disabled = False
logger.setLevel(logging.DEBUG)
if len(logger.handlers) == 0:
# File handler for detailed tracing
try:
formatter1 = logging.Formatter('%(asctime)s - %(levelname)s - %(module)s - %(message)s')
fh1 = logging.FileHandler(LOG_FILE)
fh1.setFormatter(formatter1)
fh1.setLevel(logging.DEBUG)
logger.addHandler(fh1)
except:
pass
# Standard out handler
try:
formatter2 = logging.Formatter('%(levelname)s - %(message)s')
fh2 = logging.StreamHandler(sys.stdout)
fh2.setFormatter(formatter2)
fh2.setLevel(logging.INFO)
logger.addHandler(fh2)
except:
pass
# Custom handler to send messages to ArcGIS
try:
if sys.version_info.major > 2:
formatter4 = logging.Formatter('%(asctime)s - %(message)s', '%H:%M:%S')
fh4 = ArcGisHandler()
fh4.setFormatter(formatter4)
fh4.setLevel(logging.INFO)
logger.addHandler(fh4)
except:
pass
return logger In every module I include these two lines: import logger
my_logger = logger.get('fs_log') At my main entry point I spit out where the log file is: my_logger.info ("Logging to %s" % logger.LOG_FILE)
... View more
01-17-2023
02:19 PM
|
0
|
1
|
4412
|
|
POST
|
Maybe you (or somebody else) has the project open in ArcGIS Pro?
... View more
12-23-2022
05:44 AM
|
0
|
0
|
922
|
|
POST
|
I tried this trick of creating a map from a feature layer and only sharing the map with the Hub group and it appears to work well. One caveat is that initially I had identical names for the feature layer item and the web map item and this resulted in the hub displaying the feature layer (with the download button) which is exactly what I'm trying to prevent. I looked at the network trace and could see the Hub doing some some sort of search by name and getting both the map and feature layer returned. Altering the name of one of the items fixed it in that the search only returned the map item. This is the search that returned both the map and the feature layer https://opendata.arcgis.com/api/v3/datasets?fields%5Bdatasets%5D=slug%2Cboundary%2Cextent%2CrecordCount%2CsearchDescription%2Cstatistics&filter%5Bslug%5D=fieldmuseum%3A%3Atest-no-download-1-layer-fm-2022
... View more
12-20-2022
08:18 PM
|
0
|
0
|
1285
|
|
IDEA
|
Thanks Duncan, but I'm still not seeing how to use the Package toolset to code the equivalent of "Share as Web Map".. I ran "Package Map" followed by "Share Package" but I ended up with the .mpkx file being upload to ArcGIS Online as a Map Package item. What I want to is end up with a Web Map item in ArcGIS Online (and a related Feature Layer if needed). BTW - I did figure out how to accomplish thi using a combination of arcpy, REST APIs, and the Python for ArcGIS API, but it was quite a bit of relatively complicated code.
... View more
12-19-2022
12:51 PM
|
0
|
0
|
3818
|
|
IDEA
|
I have a map in ArcGIS pro that I can upload to ArcGIS online using the "Share as Web Map" dialog, which gives me various options for how I want the data copied (in my case it creates an ArcGIS Online web map and a feature layer). I'd like to automate that in Python but having some trouble figuring out how to do it. BTW - I first raised this a a question so there is more discussion there
... View more
12-16-2022
10:14 AM
|
24
|
11
|
4368
|
|
POST
|
Right - I have read through that and have coded it in Python but sharing the web layers is not what I need to do. I need to upload the complete map to ArcGIS online - just like it is done with "Share as Web Map"
... View more
12-15-2022
04:29 PM
|
0
|
0
|
3416
|
|
POST
|
I have a map in ArcGIS pro that I can upload to ArcGIS online using the "Share as Web Map" dialog, which gives me various options for how I want the data copied (in my case it creates an ArcGIS Online web map and a feature layer). I'd like to automate that in Python but having some trouble figuring out how to do it. This question was asked previously but the answer seems to imply that I have to build the web map from scratch using the ArcGIS Api for Python WebMap object, then call the save() method. Even if I do that, I suspect that does not handle all of the options available on the ArcGIS Pro Share as Web Map dialog. I was hoping I could do it with more simply with arcpy objects. Has anybody been able to do this? I'm on ArcGIS Pro 2.9.5
... View more
12-15-2022
03:13 PM
|
0
|
5
|
3452
|
|
POST
|
I think in our case, making it inconvenient would be good enough. For layers coming from the ArcGIS Server, I removed the 'Extract' capabilities. With this I no longer get the Data->Export option is ArcGIS Pro. As you point out, I could still write a Python program to query the layer and build a local copy of the data. I see no way to remove the "Download" button in Hub. The download request are going to https://opendata.arcgis.com which I'm not familiar with.....
... View more
12-02-2022
04:19 PM
|
0
|
0
|
3252
|
|
POST
|
I have a set of quite large SQL Server database tables that contain the required foreign keys to form a many to many relationship. I'd like to create an ArcGIS relationship on those tables but it appears the TableToRelationshipClass tool actually creates a new intermediate table by copying the data. Of course this means any updates by my app are not included in the relationship (unless I modify the app). Is there any way to create a many to many relationship on the existing tables?
... View more
12-01-2022
10:17 AM
|
0
|
0
|
556
|
|
POST
|
Thanks Josh. This article appears to confirm your comment. However, even the layer in the article that ESRI's PatrickHammons1 says is not downloadable is indeed exportable from ArcGIS Pro. I know that I've seen layers in ArcGIS Pro that have export disabled but I suspect that those came from ArcGIS Server REST services and not ArcGIS Online.
... View more
11-29-2022
07:18 AM
|
0
|
2
|
3276
|
|
POST
|
I have a hosted feature layer and I want to prevent users from doing any kind of export or download. I thought unclicking the checkbox "Allow others to export to different formats" on the item's Settings tab would do the trick. It does remove the remove the "Export Data" option from the item's Overview tab, but it seems there are many other ways to export the data that are still enabled. For instance: In ArcGIS Hub - search for the item -> Download Options In ArcGIS Pro - add the item to a map, then right click -> Data -> Export Features Is there any way to really lock down an ArcGIS Online hosted feature layer?
... View more
11-28-2022
03:24 PM
|
0
|
4
|
3331
|
|
POST
|
Perhaps it doesn't work on a layer? Try to run it against the layer's datasource. Something like this: flds = [fld.name for fld in arcpy.ListFields(line_lyr.dataSource) if fld.editable]
... View more
11-01-2022
03:06 PM
|
1
|
0
|
1082
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-18-2025 03:42 PM | |
| 1 | 11-19-2025 02:36 PM | |
| 1 | 08-11-2025 09:19 PM | |
| 2 | 08-07-2025 11:47 AM | |
| 1 | 01-18-2022 07:15 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-28-2025
04:52 AM
|