Esri / ArcREST

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

Trouble with append_fc_toservice.py sample #225

Closed gEYEzer closed 8 years ago

gEYEzer commented 8 years ago

Greetings,

I'm having trouble with the append_fc_to_service.py sample.

I'm not sure if I need to provide more parameters in the securityinfo dictionary than I am. Here are the items I have populated:

securityinfo['security_type'] = 'Portal' securityinfo['username'] = "" securityinfo['password'] = "" securityinfo['org_url'] = "http://.maps.arcgis.com"

I am hoping that 'Portal' works for ArcGIS Online? Do I need a referer url? A token url? No proxy urls or ports needed to get to the internet.

Here's the error I am getting: traceback gives me this line - fst = featureservicetools.featureservicetools(securityinfo) The error text is - TypeError: init() takes at least 3 arguments (2 given)

Any help would be appreciated.

Thanks,

MikeMillerGIS commented 8 years ago

You org url should be securityinfo['org_url'] = "http://www.arcgis.com"

gEYEzer commented 8 years ago

Ah, Thanks Mike. I thought org_url meant the url for the organization, and I took the organization name out of the url in my original post..

I changed it to http://www.arcgis.com and I am still getting the same error for the same line.

gEYEzer commented 8 years ago

So I have passed each part of the securityinfo dictionary to the featureservicetools constructor and it gets past that line. Now I am getting an error saying

AttributeError: 'featureservicetools' object has no attribute '_valid'

MikeMillerGIS commented 8 years ago

it is hard to tell with looking at your entire script and the entire error message you are getting.

gEYEzer commented 8 years ago

`""" This sample shows how to append a featureclass to a feature service using ArcRest and ArcRestHelper version 3.0.1 Python 2 """ import arcrest, json from arcresthelper import featureservicetools from arcresthelper import common def trace(): """ trace finds the line, the filename and error message and returns it to the user """ import traceback, inspect tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] filename = inspect.getfile(inspect.currentframe())

script name + line number

line = tbinfo.split(", ")[1]
# Get Python syntax error
#
synerror = traceback.format_exc().splitlines()[-1]
return line, filename, synerror

if name == "main":

proxy_port = None
proxy_url = None

securityinfo = {}
securityinfo['security_type'] = 'Portal'#LDAP, NTLM, OAuth, Portal, PKI
securityinfo['username'] = "<myusername>"#<UserName>
securityinfo['password'] = "<mypassword>"#<Password>
securityinfo['org_url'] = "http://www.arcgis.com"
securityinfo['proxy_url'] = proxy_url
securityinfo['proxy_port'] = proxy_port
securityinfo['referer_url'] = None
securityinfo['token_url'] = None
securityinfo['certificatefile'] = None
securityinfo['keyfile'] = None
securityinfo['client_id'] = None
securityinfo['secret_id'] = None

itemId = "<myItemID>"#<Item ID>
layerName='Archived Notice Points'#Name of layer in the service
fc=r'<myFCpath>'#Path to Feature Class
atTable=None
try:
    fst = featureservicetools.featureservicetools(securityinfo['username'], securityinfo['password'], securityinfo['org_url'])
    if fst.valid == False:
        print fst.message
    else:

        fs = fst.GetFeatureService(itemId=itemId,returnURLOnly=False)
        if not fs is None:

            fl = fst.GetLayerFromFeatureService(fs=fs,layerName=layerName,returnURLOnly=False)
            if not fl is None:
                results = fl.addFeatures(fc=fc,attachmentTable=atTable)
                print json.dumps(results)
            else:
                print "Layer %s was not found, please check your credentials and layer name" % layerName
        else:
            print "Feature Service with id %s was not found" % fsId

except:
    line, filename, synerror = trace()
    print "error on line: %s" % line
    print "error in file name: %s" % filename
    print "with error message: %s" % synerror`
gEYEzer commented 8 years ago

Error message:

error on line: line 53 error in file name: AppendNoticedPoints.py with error message: AttributeError: 'featureservicetools' object has no attribute '_valid'

MikeMillerGIS commented 8 years ago

which version of ArcRest are you using? We changed the input to featureservicetools a long time ago, passing in the username should not work with 3.5 and master.

gEYEzer commented 8 years ago

I assume I am using 3.5.4. I just used the Download ZIP button here on GitHub.

MikeMillerGIS commented 8 years ago

Did you have a previous version on your machine, can you see what is in your python 2.7 folder. You may have an old version hanging around.

gEYEzer commented 8 years ago

Is there a way to tell what version I have? How do I start fresh?

gEYEzer commented 8 years ago

I just found my version by typing help(arcrest) - it says it is version 2.0.1. Can I just delete the arcrest folder out of the site-packages folder?

MikeMillerGIS commented 8 years ago

yes

gEYEzer commented 8 years ago

That was my problem. I deleted the arcrest folder and the arcresthelper folder from the site-packages folder, then reinstalled the latest version.

Thanks, Mike - and sorry for the bother.