import ago?

1436
8
05-27-2020 04:02 PM
JoeBorgione
MVP Emeritus

We downloaded as script from this location: https://survey123.maps.arcgis.com/home/item.html?id=c8411764ea614f208ba2e5a933a068b8 ; it's a data download utility.  At any rate it uses a module I'm not familiar with called 'ago':

import ago
import urllib
import zipfile
import json

I tried to use the ArcGIS Pro package installer and it acts like it installs, but when I try to import I'm told it dosen't exist.  So I tried an anaconda install from the command line and it can't find the package in the in the typical channels.

When I look for it on the Anaconda cloud, it sends me to: Bitbucket   where it is described as 'human readable time deltas' which I can't see how that's going to generate  a token as the script itself has it doing: 

agol_helper = ago.AGOLHelper(portal_url)
print ("...Authenticating against your Portal ")
# login
agol_helper.login(credentials['userName'], credentials['passWord'])

Anybody know what this script is and how to make it work?  Where do I find the ago  we really need?

That should just about do it....
Tags (1)
8 Replies
DanPatterson
MVP Esteemed Contributor

Joe Borgione

ago · PyPI 

You can always try a pip install

Managing packages — conda 4.8.3.post51+2cdd7ab0 documentation 


... sort of retired...
0 Kudos
DanPatterson
MVP Esteemed Contributor

other options apparently according to Dr Google

python 'x days ago' to datetime - Stack Overflow 

https://dateparser.readthedocs.io/en/latest/ 


... sort of retired...
0 Kudos
RandyBurton
MVP Alum

Look at line 52-54 in the script and you will see this note:

# initialize the portal helper class
# ago.py is part of the 10.3 python install
agol_helper = ago.AGOLHelper(portal_url)
‍‍‍‍‍‍‍‍‍‍‍

I was able to import it using desktop 10.5.  So the script is a desktop thing using Python 2.7, apparently.

>>> help(ago)
Help on module ago:

NAME
    ago - ago.py: interact with an ArcGIS Portal instance

FILE
    c:\program files (x86)\arcgis\desktop10.5\arctoolbox\scripts\ago.py

CLASSES
    __builtin__.object
        AGOLHelper
        MultipartFormdataEncoder
    
    class AGOLHelper(__builtin__.object)
     |  Interact with an ArcGIS Portal instance, such as ArcGIS Online. Must be
     |  initialized with either the login() method, or by reusing an existing
     |  OAuth token via token_login(). Covers approximately 1/3 of the complete
     |  API, primarily focused on the common operations around uploading and
     |  managing services and web maps.

... etc.‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
DanPatterson
MVP Esteemed Contributor
DanPatterson
MVP Esteemed Contributor

Well if it agol then there is ago.

But if it about time, then there is ago and other options.

Just figure out which 'ago' you need  but keep the other one handy


... sort of retired...
0 Kudos
JoeBorgione
MVP Emeritus

It's the ago as in AGO  L ...  One of my office mates was confronted with this; I'm strictly ArcGIS Pro, Python 3.x; he's got an install of ArcMap 10.5 (maybe 10.6).  We'll take a look at it together later today.

That should just about do it....
0 Kudos
JoeBorgione
MVP Emeritus

Randy Burton‌ - I see.  My office mate was using Spyder with python 3.x to review the script.  I'll have him spark up a 2.7 - idle on a screen share session and go from there.  Thanks!

That should just about do it....
0 Kudos
JamesKelly4
Occasional Contributor

I am curious if you were able to successfully import ago and run that script on a PC that didn't have ArcGIS for Desktop installed? I am trying to do that now. Any insight is appreciated. Thanks!

0 Kudos