Esri / ArcREST

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

Need Help With Query AGOL Service Sample #220

Closed RandySincoular closed 8 years ago

RandySincoular commented 8 years ago

I am trying to get this sample to run. I added a URL, USERNAME and PASSWORD and this script errors out. I have a feature service in AGOL I am trying to test with. I am not sure if I need to populate some additional 'securityinfo' parameters or not.

The error I receive is: URLError: <urlopen error [errno 10060] a connection attempt failed because the party did not properly respond after a period of time...

Any thoughts would be appreciated.

Thanks,

Randy

""" Query agol service Python 2.x ArcREST 3.0.1 """

from future import print_function from arcresthelper import securityhandlerhelper from arcrest.agol import FeatureService from arcrest.common.filters import LayerDefinitionFilter

if name == "main": url = 'http://services3.arcgis.com/sqVn1QnQEPnGQy9r/arcgis/rest/services/outage_event/FeatureServer/0/query' proxy_port = None proxy_url = None

securityinfo = {}
securityinfo['security_type'] = 'Portal'#LDAP, NTLM, OAuth, Portal, PKI
securityinfo['username'] = "RandySincoular"
securityinfo['password'] = "xxxxxx"
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
MikeMillerGIS commented 8 years ago

Do you require a proxy to access the internet on your network?

RandySincoular commented 8 years ago

Hi Mike – thanks for the quick response. We have one defined in IE.

Thanks,

Randy

MikeMillerGIS commented 8 years ago

You need to define the them on the proxy port and URL in the script

RandySincoular commented 8 years ago

Hi Mike – ok, I got it. I added a proxy server and port 80. I also modified the URL of the feature service to: url = 'http://services3.arcgis.com/sqVn1QnQEPnGQy9r/arcgis/rest/services/outage_event/FeatureServer'

That did the job. I appreciate your help. It’s kind of hard trouble shooting this when you are not sure what parameters to include.

Thanks again.

Randy

MikeMillerGIS commented 8 years ago

Glad you figured it out. I cleaned up the communication as one of the post had an password in it.

RandySincoular commented 8 years ago

Hi Mike – two questions:

  1. What does the ‘u’ mean in the output?

* Remote Interpreter Reinitialized *

{u'layers': [{u'count': 16, u'id': 0}]}

  1. For any future support questions, is it best to post a question on the ArcREST Github site?

Thanks again,

Randy

From: Michael Miller [mailto:notifications@github.com] Sent: Monday, April 18, 2016 3:29 PM To: Esri/ArcREST Cc: Sincoular, Randy Subject: Re: [Esri/ArcREST] Need Help With Query AGOL Service Sample (#220)

Glad you figured it out. I cleaned up the communication as one of the post had an password in it.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Esri_ArcREST_issues_220-23issuecomment-2D211563382&d=CwMCaQ&c=GUDVeAVg1gjs_GJkmwL1m3gEzDND7NeJG5BIAX_2yRE&r=VPwuEa_rNmp_UVm0od-YvdtKnlNWqqwbpxa2Pz1fNVE&m=OwddILGUQEug8lxT5Ml2iT06bzCrz2f9ylnqi4yEjKM&s=H8iARtaAJjw_EdLwkhpP-E4wt4Mo2oK9M1tjZy71cnU&e=

pLeBlanc93 commented 8 years ago

The u you see before strings makes Python treat the string as Unicode. There's other prefixes as well, most commonly r, for making strings raw.

For example, try to print złoty in python 2.x:

>>> print('złoty')
Unsupported characters in input

>>> print(u'z\u0142oty')
złoty
>>> 
RandySincoular commented 8 years ago

Thanks Paul

From: Paul LeBlanc [mailto:notifications@github.com] Sent: Monday, April 18, 2016 3:55 PM To: Esri/ArcREST Cc: Sincoular, Randy Subject: Re: [Esri/ArcREST] Need Help With Query AGOL Service Sample (#220)

The u you see before strings makes Python treat the string as Unicodehttps://urldefense.proofpoint.com/v2/url?u=https-3A__docs.python.org_2_howto_unicode.html&d=CwMFaQ&c=GUDVeAVg1gjs_GJkmwL1m3gEzDND7NeJG5BIAX_2yRE&r=VPwuEa_rNmp_UVm0od-YvdtKnlNWqqwbpxa2Pz1fNVE&m=hx_UHiL_hGJ2x-N0C_v32FmJvDI5rhA_9Ugtk902-jg&s=UHae3G5wkwZ0F3P2fTio7PKVXGhhtLKR5kv6wWjw3lk&e=. There's other prefixes as wellhttps://urldefense.proofpoint.com/v2/url?u=https-3A__docs.python.org_2_reference_lexical-5Fanalysis.html-23string-2Dliterals&d=CwMFaQ&c=GUDVeAVg1gjs_GJkmwL1m3gEzDND7NeJG5BIAX_2yRE&r=VPwuEa_rNmp_UVm0od-YvdtKnlNWqqwbpxa2Pz1fNVE&m=hx_UHiL_hGJ2x-N0C_v32FmJvDI5rhA_9Ugtk902-jg&s=FZ0nv83RmD6KU15dwa7jA8oVl55-xs-2HE_Uq3cgxdQ&e=, most commonly r, for making strings raw.

For example, try to print złotyhttps://urldefense.proofpoint.com/v2/url?u=https-3A__en.wikipedia.org_wiki_Polish-5Fz-25C5-2582oty&d=CwMFaQ&c=GUDVeAVg1gjs_GJkmwL1m3gEzDND7NeJG5BIAX_2yRE&r=VPwuEa_rNmp_UVm0od-YvdtKnlNWqqwbpxa2Pz1fNVE&m=hx_UHiL_hGJ2x-N0C_v32FmJvDI5rhA_9Ugtk902-jg&s=97KcrBnZpaATQ2lWFqVhbTyoCiL2KzDlNJeTqW6KUKo&e= in python 2.x:

print('złoty')

Unsupported characters in input

print(u'z\u0142oty')

złoty

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Esri_ArcREST_issues_220-23issuecomment-2D211571090&d=CwMFaQ&c=GUDVeAVg1gjs_GJkmwL1m3gEzDND7NeJG5BIAX_2yRE&r=VPwuEa_rNmp_UVm0od-YvdtKnlNWqqwbpxa2Pz1fNVE&m=hx_UHiL_hGJ2x-N0C_v32FmJvDI5rhA_9Ugtk902-jg&s=q2P7P1nuGNMpyA1vQi1_TiBxOiG2D5hGTQdvYtXgADI&e=