当前位置: 首页>>代码示例>>Python>>正文


Python portalpy.Portal类代码示例

本文整理汇总了Python中portalpy.Portal的典型用法代码示例。如果您正苦于以下问题:Python Portal类的具体用法?Python Portal怎么用?Python Portal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Portal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: count_tags

def count_tags():
    portal = Portal('http://www.geoplatform.gov')
    results = portal.search(['tags'])
    tags = unpack(results, flatten=True)
    counts = dict((tag, tags.count(tag)) for tag in tags)
    sorted_counts = sorted(counts.iteritems(), key=itemgetter(1), reverse=True)
    pprint(sorted_counts, indent=2)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:7,代码来源:recipes.py

示例2: count_item_types

def count_item_types():
    portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
    counts = portal.search(properties=['type', 'count(type)'],
                           group_fields=['type'],\
                           sort_field='count(type)',\
                           sort_order='desc')
    pprint(counts, indent=2)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:7,代码来源:recipes.py

示例3: daily_item_stats

def daily_item_stats():
    portal = Portal('http://www.arcgis.com')
    today = datetime.utcnow()
    weekago = today - timedelta(days=1)
    q = 'modified:[' + portal_time(weekago) + ' TO ' + portal_time(today) + ']'
    results = portal.search(['type', 'count(type)'], q, group_fields=['type'], num=5000)
    pprint(results, indent=2)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:7,代码来源:recipes.py

示例4: count_webmap_url_references

def count_webmap_url_references():
    portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
    urls = []
    for webmap in portal.webmaps():
        urls.extend(webmap.urls(normalize=True))
    url_counts = dict((url, urls.count(url)) for url in urls)
    pprint(url_counts, indent=2)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:7,代码来源:recipes.py

示例5: export_import_content

def export_import_content():
    source = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
    target = Portal('http://wittm.esri.com', 'admin', 'esri.agp')
    file_path = 'C:\\temp\\export'
    web_content = source.search(q=portalpy.WEB_ITEM_FILTER)
    save_items(source, web_content, file_path, indent=4)
    load_items(target, file_path)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:7,代码来源:recipes.py

示例6: count_webmap_item_references

def count_webmap_item_references():
    portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
    item_ids = []
    for webmap in portal.webmaps():
        item_ids.extend(webmap.item_ids())
    item_id_counts = dict((id, item_ids.count(id)) for id in item_ids)
    pprint(item_id_counts, indent=2)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:7,代码来源:recipes.py

示例7: print_webmap

def print_webmap():
    portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
    try:
        webmap = portal.webmap('cb769438c687478e9ccdb8377116ed02')
        pprint(webmap.json(), indent=2, width=120)
    except Exception as e:
        logging.error(e)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:7,代码来源:recipes.py

示例8: copy_groups_sample

def copy_groups_sample():
    source = Portal('http://portaldev.arcgis.com', 'wmathot', 'wmathot')
    target = Portal('http://wittm.esri.com', 'admin', 'esri.agp')
    groups = source.groups(q='Administration')
    copied_groups = copy_groups(groups, source, target, 'wmathot')
    for sourceid in copied_groups.keys():
        print 'Copied ' + sourceid + ' to ' + copied_groups[sourceid]
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:7,代码来源:recipes.py

示例9: copy_items_query

def copy_items_query():
    source = Portal('http://www.arcgis.com')
    target = Portal('http://wittm.esri.com', 'wmathot', 'wmathot')
    items = source.search(q='h1n1')
    copied_items = copy_items(items, source, target, 'wmathot', 'Copied Items (h1n1)')
    for sourceid in copied_items.keys():
        print 'Copied ' + sourceid + ' to ' + copied_items[sourceid]
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:7,代码来源:recipes.py

示例10: create_user_group_item_reports

def create_user_group_item_reports():
    portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')

    item_fields = ['id', 'title', 'owner', 'numViews']
    items = portal.search(item_fields, sort_field='numViews', sort_order='desc')
    csvfile = csv.writer(open('items-report.csv', 'wb'))
    csvfile.writerow(item_fields)
    for item in items:
        row = [item[field] for field in item_fields]
        csvfile.writerow(row)

    groups_fields = ['id', 'title', 'owner']
    groups = portal.groups(groups_fields)
    csvfile = csv.writer(open('groups-report.csv', 'wb'))
    csvfile.writerow(groups_fields)
    for group in groups:
        row = [group[field] for field in groups_fields]
        csvfile.writerow(row)

    user_fields = ['username', 'fullName', 'email', 'role']
    users = portal.org_users(user_fields)
    csvfile = csv.writer(open('users-report.csv', 'wb'))
    csvfile.writerow(user_fields)
    for user in users:
        row = [user[field] for field in user_fields]
        csvfile.writerow(row)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:26,代码来源:recipes.py

示例11: copy_items_with_related

def copy_items_with_related():
    source = Portal('http://dev.arcgis.com')
    target = Portal('http://wittm.esri.com', 'wmathot', 'wmathot')
    items = source.search(q='type:"Web Mapping Application"', num=5)
    copied_items = copy_items(items, source, target, 'wmathot', 'Web Apps 5',  \
                              relationships=['WMA2Code', 'MobileApp2Code'])
    for sourceid in copied_items.keys():
        print 'Copied ' + sourceid + ' to ' + copied_items[sourceid]
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:8,代码来源:recipes.py

示例12: set_home_page_banner

def set_home_page_banner():
    portal = Portal('http://wittm.esri.com', 'admin', 'esri.agp')
    portal.add_resource('custom-banner.jpg',\
                        data='http://www.myterradesic.com/images/header-globe.jpg')
    portal.update_property('rotatorPanels', \
        [{"id":"banner-custom", "innerHTML": "<img src='http://" + portal.hostname +\
        "/sharing/accounts/self/resources/custom-banner.jpg?token=SECURITY_TOKEN' " +\
        "style='-webkit-border-radius:0 0 10px 10px; -moz-border-radius:0 0 10px 10px; " +\
        "-o-border-radius:0 0 10px 10px; border-radius:0 0 10px 10px; margin-top:0; " +\
        "width:960px; height:180px;'/>"}])
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:10,代码来源:recipes.py

示例13: hide_user

def hide_user():
    portal = Portal('http://portaldev.arcgis.com', 'admin', 'esri.agp')
    user_to_hide = 'wmathot'
    portal.update_user(user_to_hide, {'access': 'private'})
    groups = portal.groups(['id'], 'owner:' + user_to_hide)
    for group in groups:
        portal.update_group(group['id'], {'access': 'private'})
    items = portal.search(['id'], 'owner:' + user_to_hide)
    portal.share_items(user_to_hide, items, None, False, False)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:9,代码来源:recipes.py

示例14: average_coverage_by_item_type

def average_coverage_by_item_type():
    portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
    def avg_area(extents):
        extents = filter(None, extents)
        if extents:
            areas = []
            for e in extents:
                if e: areas.append((e[1][0] - e[0][0]) * (e[1][1] - e[0][1]))
            return sum(area for area in areas) / len(areas)
        return 0
    portal.aggregate_functions['avg_area'] = avg_area
    results = portal.search(['type', 'avg_area(extent)'], group_fields=['type'])
    pprint(results, indent=2)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:13,代码来源:recipes.py

示例15: copy_user_with_groups_and_items

def copy_user_with_groups_and_items():
    source = Portal('http://portaldev.arcgis.com', 'wmathot', 'wmathot')
    target = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
    source_owner = source.logged_in_user()['username']
    target_owner = target.logged_in_user()['username']

    # Copy the groups
    groups = source.groups(q='owner:' + source_owner)
    copied_groups = copy_groups(groups, source, target)
    print 'Copied ' + str(len(copied_groups)) + ' groups'

    # Copy the items
    copied_items = copy_user_contents(source, source_owner, target, target_owner)
    print 'Copied ' + str(len(copied_items)) + ' items'

    # Share the items in the target portal
    for item_id in copied_items.keys():
        sharing = source.user_item(item_id)[1]
        if sharing['access'] != 'private':
            target_item_id = copied_items[item_id]
            target_group_ids = [copied_groups[id] for id in sharing['groups']\
                                if id in copied_groups]
            target.share_items(target_owner, [target_item_id], target_group_ids,\
                               sharing['access'] == 'org',\
                               sharing['access'] == 'public')
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:25,代码来源:recipes.py


注:本文中的portalpy.Portal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。