Esri / ArcREST

python package for REST API (AGS, AGOL, webmap JSON, etc..)
Apache License 2.0
192 stars 155 forks source link

3.5.1 breaks fs.createReplica #150

Closed tpcolson closed 8 years ago

tpcolson commented 8 years ago

With version 3.01. on Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32, the following:

import arcpy, sys, traceback from arcpy import env import time, os from subprocess import call from arcrest.security import AGOLTokenSecurityHandler from arcrest.agol import FeatureService from arcrest.common.filters import LayerDefinitionFilter

if name == "main": username = "me" password = "you" url = "https://services1.arcgis.com/fBc8EJBxQRMcHlei/ArcGIS/rest/services/GRSM_CREEL_SURVEY/FeatureServer" proxy_port = None proxy_url = None agolSH = AGOLTokenSecurityHandler(username=username, password=password) fs = FeatureService( url=url, securityHandler=agolSH, proxy_port=proxy_port, proxy_url=proxy_url, initialize=True) result = fs.createReplica(replicaName='Demo', layers='0', keep_replica=False, layerQueries=None, geometryFilter=None, returnAttachments=True, returnAttachmentDatabyURL=False, returnAsFeatureClass=True, out_path='\inpgrsms05vm\COMMON\RMS\Fisheries_Management\Angler_Creel\Data\Tabular\Archive\'+time.strftime("%Y%m%d%H%M%S"))

print result
# should see something like : {'layers': [{'count': 4, 'id': 0}]}

works successfully, however, with the latest version of ArcRest returns the following error:

Traceback (most recent call last): File "C:\Temp\create_replica_fs.py", line 31, in out_path='c:\temp') TypeError: createReplica() got an unexpected keyword argument 'returnAsFeatureClass'

achapkowski commented 8 years ago

Check out:

https://github.com/Esri/ArcREST/blob/master/samples/create_replica_fs.py

The createReplice function changed @ 3.5.x: Here is a list of the allowed inputs and the default values: createReplica(replicaName, layers, layerQueries=None, geometryFilter=None, replicaSR=None, transportType="esriTransportTypeUrl", returnAttachments=False, returnAttachmentsDatabyURL=False, async=False, attachmentsSyncDirection="none", syncModel="none", dataFormat="json", replicaOptions=None, wait=False, out_path=None)

tpcolson commented 8 years ago

hmmm, now I get

Traceback (most recent call last): File "C:\Temp\create_replica_fs.py", line 31, in out_path='\inpgrsms05vm\COMMON\RMS\Fisheries_Management\Angler_Creel\Data\Tabular\Archive\'+time.strftime("%Y%m%d%H%M%S")) TypeError: createReplica() got an unexpected keyword argument 'dataFormat'

but if I remove dataFormat="filegdb", it works (defaults to JSON). Is there another legal value to use so it outputs to FGDB?

Is the KeepReplica option (e.g. to "false") no longer working?

tpcolson commented 8 years ago

I was able to get it working with: result = fs.createReplica(replicaName='Demo', layers=[0], returnAsFeatureClass=True, out_path='C:\temp')