• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python portalpy.Portal类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: find_hostname_references

def find_hostname_references():
    hostname = 'wh94.fltplan.com'
    portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
    hostname_references = []
    url_items = portal.search(['id','type','url'], portalpy.URL_ITEM_FILTER)
    for item in url_items:
        if parse_hostname(item['url']) == hostname:
            hostname_references.append((item['id'], item['type'], item['url']))
    webmaps = portal.webmaps()
    for webmap in webmaps:
        urls = webmap.urls(normalize=True)
        for url in urls:
            if parse_hostname(url) == hostname:
                hostname_references.append((webmap.id, 'Web Map', url))
    pprint(hostname_references, indent=2)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:15,代码来源:recipes.py


示例17: find_public_content_with_weak_descriptions

def find_public_content_with_weak_descriptions():
    portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp')
    public_items = portal.search(q='access:public')
    weak_items = []
    for item in public_items:
        snippet = item.get('snippet')
        description = item.get('description')
        thumbnail = item.get('thumbnail')
        if not snippet or not description or not thumbnail or len(snippet) < 20 \
                       or len(description) < 50:
            weak_items.append(item)
    for weak_item in weak_items:
        owner = weak_item['owner']
        email = portal.user(owner)['email']
        print owner + ', ' + email + ', ' + weak_item['id']
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:15,代码来源:recipes.py


示例18: share_templates

def share_templates(portaladdress, username, password):
    
    # Create portal connection
    portal = Portal(portaladdress, username, password)
    
    print '\nShare web app templates with "AFMI Web Application Templates" group...'
    results = share_default_webapp_templates(portal, portal.logged_in_user()['username'], 'AFMI Web Application Templates')
    if results['success']:
        print '\tDone.'
    else:
        print 'ERROR: {}'.format(results['message'])
    
    print '\nShare web app templates with "AFMI Gallery Templates" group...'
    results = share_default_gallery_templates(portal, portal.logged_in_user()['username'], 'AFMI Gallery Templates')
    if results['success']:
        print '\tDone.'
    else:
        print 'ERROR: {}'.format(results['message'])    
开发者ID:Esri,项目名称:ops-server-config,代码行数:18,代码来源:PortalContentPost.py


示例19: main

def main(argv=None):
    portal = Portal('http://portaldev.esri.com')
    template_name = 'Map Notes'
    file_gdb_path = 'C:/Temp/MapNotes.gdb'

    # Retrieve the layer definitions (schemas) for the specified
    # feature collection template
    template_id = portal.feature_collection_templates(q=template_name)[0]['id']
    template = portal.item_data(template_id, return_json=True)
    template_schemas = [layer['layerDefinition'] for layer in template['layers']]

    # Create the file GDB with feature classes for each schema
    create_file_gdb(file_gdb_path, template_schemas)

    # Get all webmaps, pull out features that match the template schemas, and
    # then load them into the corresponding feature classes in the file GDB
    for webmap in portal.webmaps():
        for template_schema in template_schemas:
            features = webmap.features([template_schema])
            if features:
                load_features(file_gdb_path, template_schema['name'], features)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:21,代码来源:webmap_features_to_fgdb.py


示例20: invite_org_user

def invite_org_user():
    portal = Portal('http://wittakermathot.maps.arcgis.com', 'wmathot', '***')

    # Prepare the invitations
    invitations = [
            {'fullname': 'James Bond', 'username': 'jbond_wittakermathot',
             'email': '[email protected]', 'role': 'account_user'}]

    # Invite users. Log those who werent invited
    not_invited = portal.invite(invitations, 'test1', 'test2')
    if not_invited:
        print 'Not invited: ' + str(not_invited)

    # Accept the invitations and set the user's password to their username
    accepted_count = 0
    for invitation in invitations:
        username = invitation['username']
        for pending_invitation in portal.invitations(['id', 'username']):
            if username == pending_invitation['username']:
                invitation_id = pending_invitation['id']
                new_password = username
                is_reset = portal.reset_user(username, invitation_id, new_password)
                if is_reset:
                    portal_as_user = Portal('http://www.arcgis.com', username, new_password)
                    is_accepted = portal_as_user.accept(invitation_id)
                    if is_accepted:
                        accepted_count += 1

    print 'Invited ' + str(len(invitations)) + ', Accepted ' + str(accepted_count)
开发者ID:VandanaR,项目名称:PortalPy-AddIn,代码行数:29,代码来源:recipes.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python portpicker.pick_unused_port函数代码示例发布时间:2022-05-25
下一篇:
Python portalocker.unlock函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap