POST
|
Trying to build a definition Query for an ArcGIS Online Feature Service in ArcGIS Pro and I keep getting an error. I was trying to use the information for Standardized SQL functions in ArcGIS Online—ArcGIS Online Help | ArcGIS to write my query. Can anyone help me out??
... View more
08-31-2017
06:49 AM
|
0
|
1
|
476
|
POST
|
It is public URL with a token but don't care to share it to the world. Is it okay to email it to you??
... View more
03-30-2017
11:53 AM
|
0
|
2
|
856
|
POST
|
Can any help me figure out why I am getting a Request failed-HTTP/1.1 503 Service Unavailable when trying to Poll Http Json from an external site? but I am able to see the data when viewing URL through a web browser.
... View more
03-29-2017
10:30 AM
|
0
|
4
|
1916
|
POST
|
Is there a way to pass the URL Parameters with the Crowdsource Polling Web Application? Or away to change the code to allow URL parameters??
... View more
08-05-2016
04:37 AM
|
0
|
1
|
1214
|
POST
|
Is there away to send a link or the attachment connected to the feature with the email output connector??
... View more
07-19-2016
05:58 AM
|
7
|
4
|
1247
|
POST
|
The Python script works within ArcGIS Pro as a script in the toolbox but will not work when trying to run the script in Python 3.4.3 IDLE with ArcGIS Pro opened in the background. My hope is to run this script on a server using task Scheduler as a nightly process. My python 3.4.3 Call to the toolbox. import arcpy arcpy.ImportToolbox(r"C:\Users\agcallis\Documents\ArcGIS\Projects\Permits_Duration\Permits_Duration.tbx", "PermitDuration") arcpy.PermitDuration.PermitDuration(r"http://services.arcgis.com/T2graiaSQnlmwwmp/arcgis/rest/services/Permit_Status/FeatureServer")
... View more
07-18-2016
11:10 AM
|
0
|
0
|
711
|
POST
|
I am trying to run a ArcGIS Pro Model from Model Builder that updates fields within an ArcGIS Feature Layer. i am would like this model to doing multiple field Calculation on a daily basis as the data is updated or added. The model works as long as I running the model in ArcGIS Pro but as soon as I try to call the toolbox through python and I get back "ERROR 000732: Input Table: Dataset Permit_Status\Permit Status does not exist or is not supported Failed to execute (PermitDuration)". Here is the error I receive: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "C:\Python34\lib\idlelib\run.py", line 353, in runcode
exec(code, self.locals)
File "C:\Users\agcallis\Documents\ArcGIS\Projects\Permits_Duration\PermitDuration.py", line 3, in <module>
arcpy.PermitDuration.PermitDuration()
Traceback (most recent call last):
File "C:\Python34\lib\idlelib\run.py", line 353, in runcode
exec(code, self.locals)
File "C:\Users\agcallis\Documents\ArcGIS\Projects\Permits_Duration\PermitDuration.py", line 3, in <module>
arcpy.PermitDuration.PermitDuration()
File "C:\Users\agcallis\Documents\ArcGIS\Projects\Permits_Duration\Permits_Duration.tbx", line 59, in PermitDuration
File "C:\Users\agcallis\Documents\ArcGIS\Projects\Permits_Duration\Permits_Duration.tbx", line 56, in PermitDuration
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 500, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
The value does not exist.
ERROR 000732: Input Table: Dataset Permit_Status\Permit Status does not exist or is not supported
Failed to execute (PermitDuration).
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\tokenize.py", line 374, in find_cookie
line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\idlelib\run.py", line 126, in main
ret = method(*args, **kwargs)
File "C:\Python34\lib\idlelib\run.py", line 365, in runcode
print_exception()
File "C:\Python34\lib\idlelib\run.py", line 216, in print_exception
print_exc(typ, val, tb)
File "C:\Python34\lib\idlelib\run.py", line 206, in print_exc
tbe = traceback.extract_tb(tb)
File "C:\Python34\lib\traceback.py", line 106, in extract_tb
return list(_extract_tb_iter(tb, limit=limit))
File "C:\Python34\lib\traceback.py", line 65, in _extract_tb_or_stack_iter
line = linecache.getline(filename, lineno, f.f_globals)
File "C:\Python34\lib\linecache.py", line 15, in getline
lines = getlines(filename, module_globals)
File "C:\Python34\lib\linecache.py", line 41, in getlines
return updatecache(filename, module_globals)
File "C:\Python34\lib\linecache.py", line 126, in updatecache
with tokenize.open(fullname) as fp:
File "C:\Python34\lib\tokenize.py", line 439, in open
encoding, lines = detect_encoding(buffer.readline)
File "C:\Python34\lib\tokenize.py", line 415, in detect_encoding
encoding = find_cookie(first)
File "C:\Python34\lib\tokenize.py", line 379, in find_cookie
raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for 'C:\\Users\\agcallis\\Documents\\ArcGIS\\Projects\\Permits_Duration\\Permits_Duration.tbx'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\tokenize.py", line 374, in find_cookie
line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\idlelib\run.py", line 138, in main
print_exception()
File "C:\Python34\lib\idlelib\run.py", line 216, in print_exception
print_exc(typ, val, tb)
File "C:\Python34\lib\idlelib\run.py", line 202, in print_exc
print_exc(type(context), context, context.__traceback__)
File "C:\Python34\lib\idlelib\run.py", line 202, in print_exc
print_exc(type(context), context, context.__traceback__)
File "C:\Python34\lib\idlelib\run.py", line 206, in print_exc
tbe = traceback.extract_tb(tb)
File "C:\Python34\lib\traceback.py", line 106, in extract_tb
return list(_extract_tb_iter(tb, limit=limit))
File "C:\Python34\lib\traceback.py", line 65, in _extract_tb_or_stack_iter
line = linecache.getline(filename, lineno, f.f_globals)
File "C:\Python34\lib\linecache.py", line 15, in getline
lines = getlines(filename, module_globals)
File "C:\Python34\lib\linecache.py", line 41, in getlines
return updatecache(filename, module_globals)
File "C:\Python34\lib\linecache.py", line 126, in updatecache
with tokenize.open(fullname) as fp:
File "C:\Python34\lib\tokenize.py", line 439, in open
encoding, lines = detect_encoding(buffer.readline)
File "C:\Python34\lib\tokenize.py", line 415, in detect_encoding
encoding = find_cookie(first)
File "C:\Python34\lib\tokenize.py", line 379, in find_cookie
raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for 'C:\\Users\\agcallis\\Documents\\ArcGIS\\Projects\\Permits_Duration\\Permits_Duration.tbx'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\tokenize.py", line 374, in find_cookie
line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid continuation byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python34\lib\idlelib\run.py", line 142, in main
traceback.print_exception(type, value, tb, file=sys.__stderr__)
File "C:\Python34\lib\traceback.py", line 169, in print_exception
for line in _format_exception_iter(etype, value, tb, limit, chain):
File "C:\Python34\lib\traceback.py", line 153, in _format_exception_iter
yield from _format_list_iter(_extract_tb_iter(tb, limit=limit))
File "C:\Python34\lib\traceback.py", line 18, in _format_list_iter
for filename, lineno, name, line in extracted_list:
File "C:\Python34\lib\traceback.py", line 65, in _extract_tb_or_stack_iter
line = linecache.getline(filename, lineno, f.f_globals)
File "C:\Python34\lib\linecache.py", line 15, in getline
lines = getlines(filename, module_globals)
File "C:\Python34\lib\linecache.py", line 41, in getlines
return updatecache(filename, module_globals)
File "C:\Python34\lib\linecache.py", line 126, in updatecache
with tokenize.open(fullname) as fp:
File "C:\Python34\lib\tokenize.py", line 439, in open
encoding, lines = detect_encoding(buffer.readline)
File "C:\Python34\lib\tokenize.py", line 415, in detect_encoding
encoding = find_cookie(first)
File "C:\Python34\lib\tokenize.py", line 379, in find_cookie
raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for 'C:\\Users\\agcallis\\Documents\\ArcGIS\\Projects\\Permits_Duration\\Permits_Duration.tbx' Any help or suggest will be greatly appreciated. The main goal is to do daily field calculation on updated features inside an ArcGIS.com Feature layer using Task Scheduler.
... View more
07-15-2016
05:39 AM
|
0
|
3
|
2203
|
POST
|
Upgraded to ArcGIS Server 10.4.1 with geoevents extension. On 10.3.1, I wasn't getting an error after the upgrade getting a 'Failed to create a GeoEvent from incoming JSON feature. Unexpected error occurred. java.lang.ArrayIndexOutOfBoundsException' on one of the Inputs Connectors. Error Log- I have the Feature service on on the same server. Data is coming from a ArcSDE Layer from Oracle 11g. Any Suggestions or Ideas why I would get this? Thanks, Drew
... View more
06-07-2016
01:11 PM
|
0
|
1
|
2616
|
POST
|
Is there away to to hide web maps from the Collector that are not meant to be used with collector?
... View more
05-04-2016
06:48 AM
|
0
|
8
|
3742
|
POST
|
I'm getting the attached error message when trying to run a Silverlight application. The applications appears to get this error every time it tries to access a web service from an ArcGIS Server 10.4 install. I have a ArcGIS Server 10.3.1 and ArcGIS Server 10.0 install and accessing web services from those instances work fine, but if I include a web service from the ArcGIS Server 10.4 install I get the attached error message. I have followed the instructions for including the crossdomain.xml and clientaccesspolicy.xml files in the root of the web server, but I still get the error message. Thanks for any help! Troy
... View more
03-08-2016
05:07 AM
|
1
|
9
|
9082
|
POST
|
I am trying to use the Jewelry Box Theme with the edit widget. When I search to a location then try to add a feature to the map the attributes from the search are added to the pop-up instead of the feature attribute pop-up. Is there a way to fix this? It should look like this:
... View more
08-19-2015
06:18 AM
|
0
|
8
|
4093
|
POST
|
I am trying to build python script to run with task scheduler but the server it will be running on currently only has ArcMap 10.0 with Python 2.6.5 or ArcGIS Pro. I thought it would be easier to convert the script to Python 3.x then try to make it work with Python 2.6. Any help would be greatly appreciated.
... View more
08-08-2015
09:09 AM
|
0
|
1
|
579
|
POST
|
Thank's Ian Murray for the link. I am using Python34 so I had to convert the script using 2to3.py. Now I am getting this error belo import arcpy, urllib.request, urllib.parse, urllib.error, urllib.request, urllib.error, urllib.parse, json, os, math, sys
from arcpy import env
env.overwriteOutput = 1
env.workspace = env.scratchGDB
hostedFeatureService = arcpy.GetParameterAsText(0)
agsService = arcpy.GetParameterAsText(1)
baseURL = arcpy.GetParameterAsText(2) + "/query"
agsFeatures = arcpy.GetParameterAsText(3)
agsTable = arcpy.GetParameterAsText(4)
username = arcpy.GetParameterAsText(5)
password = arcpy.GetParameterAsText(6)
# Generate token for hosted feature service
if hostedFeatureService == 'true':
try:
arcpy.AddMessage('\nGenerating Token\n')
tokenURL = 'https://www.arcgis.com/sharing/rest/generateToken'
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'http://www.arcgis.com'}
req = urllib.request.Request(tokenURL, urllib.parse.urlencode(params))
response = urllib.request.urlopen(req)
data = json.load(response).encode("utf-8")
token = data['token']
except:
token = ''
# Genereate token for AGS feature service
if agsService == 'true':
try:
arcpy.AddMessage('\nGenerating Token\n')
server = baseURL.split("//")[1].split("/")[0]
tokenURL = 'http://' + server + '/arcgis/tokens/?username=' + username + '&password=' + password + '&referer=http%3A%2F%2F' + server + '&f=json'
req = urllib.request.Request(tokenURL)
response = urllib.request.urlopen(req)
data = json.load(response).encode("utf-8")
token = data['token']
except:
token = ''
pass
# Return largest ObjectID
params = {'where': '1=1', 'returnIdsOnly': 'true', 'token': token, 'f': 'json'}
req = urllib.request.Request(baseURL, urllib.parse.urlencode(params))
response = urllib.request.urlopen(req)
data = json.load(response).encode("utf-8")
try:
data['objectIds'].sort()
except:
arcpy.AddWarning("\nURL is incorrect. Or, Service is secure, please enter username and password.\n")
iteration = int(data['objectIds'][-1])
minOID = int(data['objectIds'][0]) - 1
OID = data['objectIdFieldName']
# Code for downloading hosted feature service
if hostedFeatureService == 'true':
if iteration < 1000:
x = iteration
y = minOID
where = OID + '>' + str(y) + 'AND ' + OID + '<=' + str(x)
fields ='*'
query = "?where={}&outFields={}&returnGeometry=true&f=json&token={}".format(where, fields, token)
fsURL = baseURL + query
fs = arcpy.FeatureSet()
fs.load(fsURL)
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
outputFC = arcpy.GetParameterAsText(7)
desc = arcpy.Describe(os.path.dirname(outputFC))
if desc.workspaceFactoryProgID == 'esriDataSourcesGDB.SdeWorkspaceFactory.1':
outputFC2 = outputFC.split(".")[-1]
arcpy.FeatureClassToFeatureClass_conversion(fs, os.path.dirname(outputFC), outputFC2)
else:
arcpy.FeatureClassToFeatureClass_conversion(fs, os.path.dirname(outputFC), os.path.basename(outputFC))
else:
newIteration = (math.ceil(iteration/1000.0) * 1000)
x = minOID + 1000
y = minOID
firstTime = 'True'
while x <= newIteration:
where = OID + '>' + str(y) + 'AND ' + OID + '<=' + str(x)
fields ='*'
query = "?where={}&outFields={}&returnGeometry=true&f=json&token={}".format(where, fields, token)
fsURL = baseURL + query
fs = arcpy.FeatureSet()
fs.load(fsURL)
if firstTime == 'True':
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
outputFC = arcpy.GetParameterAsText(7)
desc = arcpy.Describe(os.path.dirname(outputFC))
if desc.workspaceFactoryProgID == 'esriDataSourcesGDB.SdeWorkspaceFactory.1':
outputFC2 = outputFC.split(".")[-1]
arcpy.FeatureClassToFeatureClass_conversion(fs, os.path.dirname(outputFC), outputFC2)
else:
arcpy.FeatureClassToFeatureClass_conversion(fs, os.path.dirname(outputFC), os.path.basename(outputFC))
firstTime = 'False'
else:
desc = arcpy.Describe(os.path.dirname(outputFC))
if desc.workspaceFactoryProgID == 'esriDataSourcesGDB.SdeWorkspaceFactory.1':
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
insertRows = arcpy.da.InsertCursor(outputFC, ["*","SHAPE@"])
searchRows = arcpy.da.SearchCursor(fs, ["*","SHAPE@"])
for searchRow in searchRows:
fieldList = list(searchRow)
insertRows.insertRow(fieldList)
elif desc.workspaceFactoryProgID == '':
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
arcpy.Append_management(fs, outputFC, "NO_TEST")
else:
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
arcpy.Append_management(fs, outputFC)
x += 1000
y += 1000
try:
del searchRow, searchRows, insertRows
except:
pass
# Check to see if downloading a feature or tabular data from a ArcGIS Server service
if agsService == 'true':
if agsFeatures != 'true' and agsTable != 'true':
arcpy.AddError("\nPlease check 'Downloading Feature Data' or 'Downloading Tabular Data'\n")
# Code for downloading feature data
if agsFeatures == 'true':
if iteration < 1000:
x = iteration
y = minOID
where = OID + '>' + str(y) + 'AND ' + OID + '<=' + str(x)
fields ='*'
query = "?where={}&outFields={}&returnGeometry=true&f=json&token={}".format(where, fields, token)
fsURL = baseURL + query
fs = arcpy.FeatureSet()
fs.load(fsURL)
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
outputFC = arcpy.GetParameterAsText(7)
desc = arcpy.Describe(os.path.dirname(outputFC))
if desc.workspaceFactoryProgID == 'esriDataSourcesGDB.SdeWorkspaceFactory.1':
outputFC2 = outputFC.split(".")[-1]
arcpy.FeatureClassToFeatureClass_conversion(fs, os.path.dirname(outputFC), outputFC2)
else:
arcpy.FeatureClassToFeatureClass_conversion(fs, os.path.dirname(outputFC), os.path.basename(outputFC))
else:
newIteration = (math.ceil(iteration/1000.0) * 1000)
x = minOID + 1000
y = minOID
firstTime = 'True'
while x <= newIteration:
where = OID + '>' + str(y) + 'AND ' + OID + '<=' + str(x)
fields ='*'
query = "?where={}&outFields={}&returnGeometry=true&f=json&token={}".format(where, fields, token)
fsURL = baseURL + query
fs = arcpy.FeatureSet()
fs.load(fsURL)
if firstTime == 'True':
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
outputFC = arcpy.GetParameterAsText(7)
desc = arcpy.Describe(os.path.dirname(outputFC))
if desc.workspaceFactoryProgID == 'esriDataSourcesGDB.SdeWorkspaceFactory.1':
outputFC2 = outputFC.split(".")[-1]
arcpy.FeatureClassToFeatureClass_conversion(fs, os.path.dirname(outputFC), outputFC2)
else:
arcpy.FeatureClassToFeatureClass_conversion(fs, os.path.dirname(outputFC), os.path.basename(outputFC))
firstTime = 'False'
else:
desc = arcpy.Describe(os.path.dirname(outputFC))
if desc.workspaceFactoryProgID == 'esriDataSourcesGDB.SdeWorkspaceFactory.1':
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
insertRows = arcpy.da.InsertCursor(outputFC, ["*","SHAPE@"])
searchRows = arcpy.da.SearchCursor(fs, ["*","SHAPE@"])
for searchRow in searchRows:
fieldList = list(searchRow)
insertRows.insertRow(fieldList)
elif desc.workspaceFactoryProgID == '':
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
arcpy.Append_management(fs, outputFC, "NO_TEST")
else:
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
arcpy.Append_management(fs, outputFC)
x += 1000
y += 1000
try:
del searchRow, searchRows, insertRows
except:
pass
# Code for downloading tabular data
if agsTable == 'true':
if iteration < 1000:
x = iteration
y = minOID
where = OID + '>' + str(y) + 'AND ' + OID + '<=' + str(x)
fields ='*'
query = "?where={}&outFields={}&returnGeometry=true&f=json&token={}".format(where, fields, token)
fsURL = baseURL + query
fs = arcpy.RecordSet()
fs.load(fsURL)
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
outputFC = arcpy.GetParameterAsText(7)
desc = arcpy.Describe(os.path.dirname(outputFC))
if desc.workspaceFactoryProgID == 'esriDataSourcesGDB.SdeWorkspaceFactory.1':
outputFC2 = outputFC.split(".")[-1]
arcpy.TableToTable_conversion(fs, os.path.dirname(outputFC), outputFC2)
else:
arcpy.TableToTable_conversion(fs, os.path.dirname(outputFC), os.path.basename(outputFC))
else:
newIteration = (math.ceil(iteration/1000.0) * 1000)
x = minOID + 1000
y = minOID
firstTime = 'True'
while x <= newIteration:
where = OID + '>' + str(y) + 'AND ' + OID + '<=' + str(x)
fields ='*'
query = "?where={}&outFields={}&f=json&token={}".format(where, fields, token)
fsURL = baseURL + query
fs = arcpy.RecordSet()
fs.load(fsURL)
if firstTime == 'True':
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
outputFC = arcpy.GetParameterAsText(7)
desc = arcpy.Describe(os.path.dirname(outputFC))
if desc.workspaceFactoryProgID == 'esriDataSourcesGDB.SdeWorkspaceFactory.1':
outputFC2 = outputFC.split(".")[-1]
arcpy.TableToTable_conversion(fs, os.path.dirname(outputFC), outputFC2)
else:
arcpy.TableToTable_conversion(fs, os.path.dirname(outputFC), os.path.basename(outputFC))
firstTime = 'False'
else:
desc = arcpy.Describe(os.path.dirname(outputFC))
arcpy.AddMessage('Copying features with ObjectIDs from ' + str(y) + ' to ' + str(x))
arcpy.Append_management(fs, outputFC)
x += 1000
y += 1000
try:
del searchRow, searchRows, insertRows
except:
pass
# Code for retrieving attachments
getAttachments = arcpy.GetParameterAsText(8)
if getAttachments == 'true':
# Create Replica to retrieve attachments
arcpy.AddMessage("\nRetrieving Attachments\n")
cwd = arcpy.GetParameterAsText(9)
crUrl = baseURL[0:-7] + 'createReplica'
crValues = {'f' : 'json',
'layers' : '0',
'returnAttachments' : 'true',
'token' : token }
crData = urllib.parse.urlencode(crValues)
crRequest = urllib.request.Request(crUrl, crData)
crResponse = urllib.request.urlopen(crRequest)
crJson = json.load(crResponse)
try:
replicaUrl = crJson['URL']
except KeyError:
arcpy.AddWarning("\nService does not have 'Sync' operation enabled\n")
urllib.request.urlretrieve(replicaUrl, cwd + os.sep + 'myLayer.json')
f = open(cwd + os.sep + 'myLayer.json')
lines = f.readlines()
f.close()
for line in lines:
if not 'attachments' in line:
arcpy.AddWarning("\nService does not contain attachments\n")
os.remove(cwd + os.sep + 'myLayer.json')
sys.exit()
# Get Attachment
with open(cwd + os.sep + 'myLayer.json') as data_file:
data = json.load(data_file)
dict = {}
x = 0
while x <= iteration:
try:
dict[data['layers'][0]['features'] ['attributes'][OID]] = data['layers'][0]['features'] ['attributes']['GlobalID']
x += 1
except IndexError:
x += 1
pass
fc = arcpy.GetParameterAsText(7)
arcpy.AddField_management(fc, "GlobalID_Str", "TEXT")
for key in dict:
with arcpy.da.UpdateCursor(fc, [OID, "GlobalID_Str"], OID + " = " + str(key)) as cursor:
for row in cursor:
row[1] = dict[key]
cursor.updateRow(row)
arcpy.EnableAttachments_management(fc)
arcpy.AddField_management(fc + "__ATTACH", "GlobalID_Str", "TEXT")
arcpy.AddField_management(fc + "__ATTACH", "PhotoPath", "TEXT")
# Add Attachments
# Create Match Table
try:
for x in data['layers'][0]['attachments']:
gaUrl = x['url']
gaFolder = cwd + os.sep + x['parentGlobalId']
if not os.path.exists(gaFolder):
os.makedirs(gaFolder)
gaName = x['name']
gaValues = {'token' : token }
gaData = urllib.parse.urlencode(gaValues)
urllib.request.urlretrieve(url=gaUrl + '/' + gaName, filename=os.path.join(gaFolder, gaName),data=gaData)
rows = arcpy.InsertCursor(fc + "__ATTACH")
hasrow = False
for cmtX in data['layers'][0]['attachments']:
row = rows.newRow()
hasrow = True
row.setValue('GlobalID_Str', cmtX['parentGlobalId'])
row.setValue('PhotoPath', cwd + os.sep +cmtX['parentGlobalId'] + os.sep + cmtX['name'])
rows.insertRow(row)
if hasrow == True:
del row
del rows
arcpy.AddAttachments_management(fc, 'GlobalID_Str', fc + '__ATTACH', 'GlobalID_Str', 'PhotoPath')
try:
arcpy.MakeTableView_management(fc + '__ATTACH', "tblView")
arcpy.SelectLayerByAttribute_management("tblView", "NEW_SELECTION", "DATA_SIZE = 0")
arcpy.DeleteRows_management("tblView")
arcpy.DeleteField_management(fc + '__ATTACH', 'GlobalID_Str')
arcpy.DeleteField_management(fc + '__ATTACH', 'PhotoPath')
except:
pass
except KeyError:
pass
os.remove(cwd + os.sep + 'myLayer.json')
ERROR: Traceback (most recent call last): File "C:\Users\agcallis\Desktop\CopyFS_Pro.py", line 47, in <module> response = urllib.request.urlopen(req) File "c:\program files\arcgis pro\bin\Python\lib\urllib\request.py", line 153, in urlopen return opener.open(url, data, timeout) File "c:\program files\arcgis pro\bin\Python\lib\urllib\request.py", line 453, in open req = meth(req) File "c:\program files\arcgis pro\bin\Python\lib\urllib\request.py", line 1120, in do_request_ raise TypeError(msg) TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str. Failed to execute (DownloadService). Can you or Jake Skinner help me out? Thanks
... View more
08-07-2015
08:08 AM
|
0
|
3
|
579
|
Title | Kudos | Posted |
---|---|---|
7 | 07-19-2016 05:58 AM | |
3 | 08-04-2015 12:17 PM | |
1 | 03-08-2016 05:07 AM | |
1 | 07-08-2015 01:40 PM |
Online Status |
Offline
|
Date Last Visited |
3 weeks ago
|