Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

AttributeError: 'module' object has no attribute 'AnalyzeParameters' #59

Closed
geoffreywestGIS opened this issue May 19, 2015 · 6 comments
Closed

Comments

@geoffreywestGIS
Copy link

See issue # 53, when using the provided code sample the error returns,
analyzeParams = arcrest.manageorg.AnalyzeParameters()
AttributeError: 'module' object has no attribute 'AnalyzeParameters'

code that I am using;

import arcrest

if name == "main":
username = ""
password = ""
csv_file = r"C:\Users\GeoffreyWest\Desktop\bing_output.csv"

sh = arcrest.AGOLTokenSecurityHandler(username, password)
admin = arcrest.manageorg.Administration(securityHandler=sh)
content = admin.content
usercontent = content.usercontent(username=username)
ip = arcrest.manageorg.ItemParameter()
ip.title = "BingParameterTest"
ip.type = "CSV"
ip.tags = ""
ip.overwrite = True
ip.thumbnailurl = ""
res = usercontent.addItem(itemParameters=ip,
                          filePath=csv_file, overwrite= True)


print res


itemId = res['id']
print itemId
#  Now you need to analyze the item to publish it
#
featureContent = content.featureContent
analyzeParams = arcrest.manageorg.AnalyzeParameters()
analyzeResult = featureContent.analyze(itemId=itemId, analyzeParameters=analyzeParams)
#  Published based off the analyze function
#
if 'publishParameters' in analyzeResult:
    pp = analyzeResult['publishParameters']
    publishParams = arcrest.manageorg.PublishCSVParameters(name=pp['name'],
                                           locationType=pp['locationType'],
                                           layerInfo=pp['layerInfo'],
                                           latitudeFieldName=pp["Y_COR"],
                                           longitudeFieldName=pp['X_COR'])
    print usercontent.publishItem(fileType="csv",
                                  publishParameters=publishParams,
                                  itemId=itemId, overwrite = True)
print 'finished'
@achapkowski
Copy link
Collaborator

Do you have the latest version of ArcREST?

It's in there: https://github.com/Esri/ArcREST/blob/master/src/arcrest/manageorg/parameters.py

@geoffreywestGIS
Copy link
Author

Yes, the error no longer appears, can you provide an example of how ['layerinfo'] should be structured?

@achapkowski
Copy link
Collaborator

See: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Layer/02r30000004q000000/

Andrew Chapkowski | Professional Services
esri | 1325 Morris Drive, Suite 201 | Chesterbrook, PA 19087
Phone: 610-644-3374 ext. 5930 | E-mail: achapkowski@esri.commailto:achapkowski@esri.com

[DevA_EDDA]

From: Geoffrey West [mailto:notifications@github.com]
Sent: Wednesday, May 20, 2015 11:36 AM
To: Esri/ArcREST
Cc: Andrew Chapkowski
Subject: Re: [ArcREST] AttributeError: 'module' object has no attribute 'AnalyzeParameters' (#59)

Yes, the error no longer appears, can you provide an example of how ['layerinfo'] should be structured?


Reply to this email directly or view it on GitHubhttps://github.com//issues/59#issuecomment-103929167.

@geoffreywestGIS
Copy link
Author

Not sure why it's not publishing, I intermittently receive a 500 error from addItem as mentioned in #53. Publishing and addItem appear dependent at this point as an itemAdds without issue when I omit the publish section.

print usercontent.publishItem(fileType="CSV",
publishParameters=publishParams,
itemId=itemId) does not print a result.

my ['layerinfo'] is a json that I am reading from disk as
jsonfile = 'C:\Users\GIS\Desktop\eastvalley.json'

with open(jsonfile, "r") as f:
  data = json.loads(f.read())

if 'publishParameters' in analyzeResult:
pp = analyzeResult['publishParameters']
publishParams = arcrest.manageorg.PublishCSVParameters(name=pp['CSVPublishTest'],
locationType=pp['none'],
layerInfo=pp[jsonfile])
print usercontent.publishItem(fileType="CSV",
publishParameters=publishParams,
itemId=itemId)
print 'finished'

I am using this JSON structure found http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000008q000000

{
"name": "My CSV File Dataset",
"locationType": "none",
"description": "test description",
"maxRecordCount": 500,
"copyrightText": "test copyright",
"layerInfo": {
"name": "Illinois",
"type": "Feature Layer",
"geometryType": "none",
"minScale": 0,
"maxScale": 0,
"hasAttachments": false,
"htmlPopupType": "esriServerHTMLPopupTypeNone",
"objectIdField": "GeographyId",
"globalIdField": "",
"typeIdField": "",
"fields": [
{
"name": "GeographyId",
"type": "esriFieldTypeString",
"alias": "FID",
"sqlType": "sqlTypeInteger",
"nullable": false,
"editable": false,
"domain": null
},
{
"name": "GeographyName",
"type": "esriFieldTypeString",
"alias": "Geog Name",
"nullable": false,
"editable": true,
"domain": null
},
{
"name": "GeographyType",
"type": "esriFieldTypeString",
"alias": "Geog type",
"nullable": false,
"editable": true,
"domain": null
},
{
"name": "StateAbbreviation",
"type": "esriFieldTypeString",
"alias": "State Abbr.",
"nullable": false,
"editable": true,
"domain": null
}
],
"types": [],
"templates": [],
"capabilities": "Query,Editing"
}
}

@MikeMillerGIS
Copy link
Member

I would suggest installing Fiddler and walk through the process using ArcGIS Online or Portal and see what differs from the calls you are making in ArcRest. Can you post the entire scripts and a sample CSV that we can use to repo the issue?

@achapkowski
Copy link
Collaborator

No code posted or fiddler traffic, issue closed. Please feel free to post your issue again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants