Esempio n. 1
0
def setUpModule():
    """
       Try to put as little as possible in the setUpModule or you potentially break
       test isolation.  
       
       CAUTION:
       A few test methods need to modify a test user and so a pre-created
       user in the portal can't be used.  That means the user must be created when the tests
       are run. Creating users is an action that is appropriate for a setup method.  However
       we don't want to create a test user on every setup method because that slows down the
       running of the tests considerably since most test methods don't need a custom user.
       To maintain test isolation while getting high performance, we create test users for
       the particular methods that need them when the test module starts and clean up those
       users when the module stops.
       
       TIP:
       To create a user for your test method, all you need to do is add a a name to the 
       users global list above and it will create a user for your method named test_user[your_user]
       and create a connection for that user called test_user_conn[your_user] and clean them up 
       for you at the end.
         
        
    """

    portal = portalpy.Portal(portalUrl)

    for user in users:
        test_user[user] = utility_create_random_user(portal)
        test_user_conn[user] = portalpy.Portal(portalUrl, test_user[user],
                                               test_user[user])

    for owner in group_owners:
        test_group[owner] = utility_create_random_group(test_user_conn[owner])
Esempio n. 2
0
 def setUp(self):
     self.portalAdmin = portalpy.Portal(self.portalUrl,
                                        self.portalAdminName,
                                        self.portalAdminPassword)
     self.portalUser = portalpy.Portal(self.portalUrl, self.portalUserName,
                                       self.portalUserPassword)
     self.portalAnon = portalpy.Portal(self.portalUrl)
Esempio n. 3
0
    def setUp(self):
        self.portalAdmin = portalpy.Portal(portalUrl, portalAdminName,
                                           portalAdminPassword)
        self.portalUser = portalpy.Portal(portalUrl, portalUserName,
                                          portalUserPassword)
        self.portalAnon = portalpy.Portal(portalUrl)

        self.test_group_id = utility_create_random_group(self.portalAdmin)
Esempio n. 4
0
    def __init__(self):

        portalUrl = "https://samdrummonddev.maps.arcgis.com"  #"https://portalpy.esri.com/arcgis"
        portalAdminName = raw_input('Username: ')  #"portaladmin"
        portalAdminPassword = getpass.getpass()  #"portaladmin"

        self._portal = portalpy.Portal(portalUrl, portalAdminName,
                                       portalAdminPassword)
Esempio n. 5
0
def tearDownModule():
    portal = portalpy.Portal(portalUrl, portalAdminName, portalAdminPassword)

    for owner in group_owners:
        portal.delete_group(test_group[owner])

    for user in users:
        portal.delete_user(test_user[user])
Esempio n. 6
0
def main():
    # Get the parameters for the tool
    URL = arcpy.GetParameterAsText(0)
    user = arcpy.GetParameterAsText(1)
    password = arcpy.GetParameterAsText(2)
    # Instantiate the portal object
    portalObject = portalpy.Portal(URL, user, password)
    #print portalObject
    import test_addin
    test_addin.portalLogin = portalObject
    test_addin.portalID = user
Esempio n. 7
0
def main():

    
    # Get the parameters for the tool
    URL = r"http://www.arcgis.com/"
    user = arcpy.GetParameterAsText(0)
    password = arcpy.GetParameterAsText(1)
    # Instantiate the portal object
    try:
        portalObject = portalpy.Portal(URL, user, password)
        return portalObject
    except:
        portalObject = "False"
    if portalObject.is_logged_in == "True":
        return "True"
    else:
        return "False"
Esempio n. 8
0
    def onClick(self):

        URL = r"http://www.arcgis.com/"
        user = '******'
        password = '******'

        portalLogin = portalpy.Portal(URL, user, password)

        fs = portalLogin.search(q='type:Feature Service',
                                sort_field='title',
                                sort_order='asc')

        FILE = open(output, "w")

        for i in fs:
            FILE.write(i.get('title') + "\n")

        FILE.close()
        print 'Woot.'
    def onClick(self):

        #pythonaddins.GPToolDialog(tbxpath + "\\Toolbox.tbx", "SignIn")

        URL = r"http://www.arcgis.com/"
        user = '******'
        password = '******'

        portalLogin = portalpy.Portal(URL, user, password)
        org_ID = portalLogin.info().properties['id']

        FILE = open(output, "w")

        filehandle = urllib.urlopen(list_services_path1 + org_ID +
                                    list_services_path2)
        for lines in filehandle.readlines():
            #[16:-5]      "name" : "
            if '"name"' in lines:
                FILE.write(lines[16:-5])
                FILE.write('\n')

        FILE.close()
        print 'Woot.'
Esempio n. 10
0
"""
    This example script lists the names and roles of all users who are publishers or administrators.  
    
    To invoke this script simply type python list_admins.py.  This will run the script against
    the portalpy.esri.com portal.  To run it against your Portal, change the values in 
    portalUrl, portalAdminUser, and portalAdminPassword.

"""
# disable ssl certificate validation
try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    # Legacy Python that doesn't verify HTTPS certificates by default
    pass
else:
    # Handle target environment that doesn't support HTTPS verification
    ssl._create_default_https_context = _create_unverified_https_context

portalUrl           = "https://portalpy.esri.com/arcgis"
portalAdminUser     = "******"
portalAdminPassword = "******"

    
portal = portalpy.Portal(portalUrl, portalAdminUser, portalAdminPassword)
users = portal.search_users('(role:account_admin OR role:account_publisher)')

for user in users :
    userResp = portal.get_user(user['username'])
    print user['username'] + ":  " + userResp['role']