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


Python bottle.abort方法代码示例

本文整理汇总了Python中bottle.abort方法的典型用法代码示例。如果您正苦于以下问题:Python bottle.abort方法的具体用法?Python bottle.abort怎么用?Python bottle.abort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bottle的用法示例。


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

示例1: parse_form

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def parse_form():
    categories = request.forms.get("categories")
    categories = (set(categories.split(',')) if categories else set())
    source = request.forms.get("source")
    if not source:
        utils.LOGGER.critical("source is mandatory")
        abort(400, "ERROR: source is mandatory\n")
    files = request.files.getall("result")
    if config.WEB_PUBLIC_SRV:
        if webutils.get_user() is None:
            utils.LOGGER.critical("username is mandatory on public instances")
            abort(400, "ERROR: username is mandatory on public instances")
        if request.forms.get('public') == 'on':
            categories.add('Shared')
        user = webutils.get_anonymized_user()
        categories.add(user)
        source = "%s-%s" % (user, source)
    return (request.forms.get('referer'), source, categories, files) 
开发者ID:cea-sec,项目名称:ivre,代码行数:20,代码来源:app.py

示例2: http_get_hosts

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_get_hosts():
    select_,where_,limit_ = filter_query_string(bottle.request.query, http2db_host,
            ('id','name','description','status','admin_state_up') )
    
    myself = config_dic['http_threads'][ threading.current_thread().name ]
    result, content = myself.db.get_table(FROM='hosts', SELECT=select_, WHERE=where_, LIMIT=limit_)
    if result < 0:
        print "http_get_hosts Error", content
        bottle.abort(-result, content)
    else:
        convert_boolean(content, ('admin_state_up',) )
        change_keys_http2db(content, http2db_host, reverse=True)
        for row in content:
            row['links'] = ( {'href': myself.url_preffix + '/hosts/' + str(row['id']), 'rel': 'bookmark'}, )
        data={'hosts' : content}
        return format_out(data) 
开发者ID:nfvlabs,项目名称:openmano,代码行数:18,代码来源:httpserver.py

示例3: http_post_tenants

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_post_tenants():
    '''insert a tenant into the database.'''
    my = config_dic['http_threads'][ threading.current_thread().name ]
    #parse input data
    http_content = format_in( tenant_new_schema )
    r = remove_extra_items(http_content, tenant_new_schema)
    if r is not None: print "http_post_tenants: Warning: remove extra items ", r
    change_keys_http2db(http_content['tenant'], http2db_tenant)

    #insert in data base
    result, content = my.db.new_tenant(http_content['tenant'])
            
    if result >= 0:
        return http_get_tenant_id(content)
    else:
        bottle.abort(-result, content)
        return 
开发者ID:nfvlabs,项目名称:openmano,代码行数:19,代码来源:httpserver.py

示例4: http_put_tenant_id

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_put_tenant_id(tenant_id):
    '''update a tenant into the database.'''
    my = config_dic['http_threads'][ threading.current_thread().name ]
    #parse input data
    http_content = format_in( tenant_edit_schema )
    r = remove_extra_items(http_content, tenant_edit_schema)
    if r is not None: print "http_put_tenant_id: Warning: remove extra items ", r
    change_keys_http2db(http_content['tenant'], http2db_tenant)

    #insert in data base
    result, content = my.db.update_rows('tenants', http_content['tenant'], WHERE={'uuid': tenant_id}, log=True )
    if result >= 0:
        return http_get_tenant_id(tenant_id)
    else:
        bottle.abort(-result, content)
        return 
开发者ID:nfvlabs,项目名称:openmano,代码行数:18,代码来源:httpserver.py

示例5: http_delete_flavor_id

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_delete_flavor_id(tenant_id, flavor_id):
    '''Deletes the flavor_id of a tenant. IT removes from tenants_flavors table.'''
    my = config_dic['http_threads'][ threading.current_thread().name ]
    #check valid tenant_id
    result,content = check_valid_tenant(my, tenant_id)
    if result != 0:
        bottle.abort(result, content)
        return
    result, content = my.db.delete_image_flavor('flavor', flavor_id, tenant_id)
    if result == 0:
        bottle.abort(HTTP_Not_Found, content)
    elif result >0:
        data={'result' : content}
        return format_out(data)
    else:
        print "http_delete_flavor_id error",result, content
        bottle.abort(-result, content)
        return 
开发者ID:nfvlabs,项目名称:openmano,代码行数:20,代码来源:httpserver.py

示例6: http_post_images

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_post_images(tenant_id):
    '''insert a image into the database, and attach to tenant.'''
    my = config_dic['http_threads'][ threading.current_thread().name ]
    #check valid tenant_id
    result,content = check_valid_tenant(my, tenant_id)
    if result != 0:
        bottle.abort(result, content)
    http_content = format_in(image_new_schema)
    r = remove_extra_items(http_content, image_new_schema)
    if r is not None: print "http_post_images: Warning: remove extra items ", r
    change_keys_http2db(http_content['image'], http2db_image)
    metadata_dict = http_content['image'].pop('metadata', None)
    if metadata_dict is not None: 
        http_content['image']['metadata'] = json.dumps(metadata_dict)
    #insert in data base
    result, content = my.db.new_image(http_content['image'], tenant_id)
    if result >= 0:
        return http_get_image_id(tenant_id, content)
    else:
        print "http_post_images error %d %s" % (result, content)
        bottle.abort(-result, content)
        return 
开发者ID:nfvlabs,项目名称:openmano,代码行数:24,代码来源:httpserver.py

示例7: http_delete_image_id

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_delete_image_id(tenant_id, image_id):
    '''Deletes the image_id of a tenant. IT removes from tenants_images table.'''
    my = config_dic['http_threads'][ threading.current_thread().name ]
    #check valid tenant_id
    result,content = check_valid_tenant(my, tenant_id)
    if result != 0:
        bottle.abort(result, content)
    result, content = my.db.delete_image_flavor('image', image_id, tenant_id)
    if result == 0:
        bottle.abort(HTTP_Not_Found, content)
    elif result >0:
        data={'result' : content}
        return format_out(data)
    else:
        print "http_delete_image_id error",result, content
        bottle.abort(-result, content)
        return 
开发者ID:nfvlabs,项目名称:openmano,代码行数:19,代码来源:httpserver.py

示例8: http_post_server_action

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_post_server_action(tenant_id, server_id):
    '''take an action over a server'''
    my = config_dic['http_threads'][ threading.current_thread().name ]
    #check valid tenant_id
    result,content = check_valid_tenant(my, tenant_id)
    if result != 0:
        bottle.abort(result, content)
        return
    http_content = format_in( server_action_schema )
    #r = remove_extra_items(http_content, server_action_schema)
    #if r is not None: print "http_post_server_action: Warning: remove extra items ", r
    
    return http_server_action(server_id, tenant_id, http_content)

#
# NETWORKS
# 
开发者ID:nfvlabs,项目名称:openmano,代码行数:19,代码来源:httpserver.py

示例9: http_get_networks

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_get_networks():
    my = config_dic['http_threads'][ threading.current_thread().name ]
    #obtain data
    select_,where_,limit_ = filter_query_string(bottle.request.query, http2db_network,
            ('id','name','tenant_id','type',
             'shared','provider:vlan','status','last_error','admin_state_up','provider:physical') )
    #TODO temporally remove tenant_id
    if "tenant_id" in where_:
        del where_["tenant_id"]
    result, content = my.db.get_table(SELECT=select_, FROM='nets', WHERE=where_, LIMIT=limit_)
    if result < 0:
        print "http_get_networks error %d %s" % (result, content)
        bottle.abort(-result, content)
    else:
        convert_boolean(content, ('shared', 'admin_state_up', 'enable_dhcp') )
        delete_nulls(content)      
        change_keys_http2db(content, http2db_network, reverse=True)  
        data={'networks' : content}
        return format_out(data) 
开发者ID:nfvlabs,项目名称:openmano,代码行数:21,代码来源:httpserver.py

示例10: http_get_network_id

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_get_network_id(network_id):
    my = config_dic['http_threads'][ threading.current_thread().name ]
    #obtain data
    where_ = bottle.request.query
    where_['uuid'] = network_id
    result, content = my.db.get_table(FROM='nets', WHERE=where_, LIMIT=100)

    if result < 0:
        print "http_get_networks_id error %d %s" % (result, content)
        bottle.abort(-result, content)
    elif result==0:
        print "http_get_networks_id network '%s' not found" % network_id
        bottle.abort(HTTP_Not_Found, 'network %s not found' % network_id)
    else:
        convert_boolean(content, ('shared', 'admin_state_up', 'enale_dhcp') )
        change_keys_http2db(content, http2db_network, reverse=True)        
        #get ports
        result, ports = my.db.get_table(FROM='ports', SELECT=('uuid as port_id',), 
                                              WHERE={'net_id': network_id}, LIMIT=100)
        if len(ports) > 0:
            content[0]['ports'] = ports
        delete_nulls(content[0])      
        data={'network' : content[0]}
        return format_out(data) 
开发者ID:nfvlabs,项目名称:openmano,代码行数:26,代码来源:httpserver.py

示例11: http_get_openflow_id

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_get_openflow_id(network_id):
    '''To obtain the list of openflow rules of a network
    '''
    my = config_dic['http_threads'][ threading.current_thread().name ]
    #ignore input data
    if network_id=='all':
        where_={}
    else:
        where_={"net_id": network_id}
    result, content = my.db.get_table(SELECT=("name","net_id","priority","vlan_id","ingress_port","src_mac","dst_mac","actions"),
            WHERE=where_, FROM='of_flows')
    if result < 0:
        bottle.abort(-result, content)
        return
    data={'openflow-rules' : content}
    return format_out(data) 
开发者ID:nfvlabs,项目名称:openmano,代码行数:18,代码来源:httpserver.py

示例12: http_clear_openflow_rules

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_clear_openflow_rules():
    '''To make actions over the net. The action is to delete ALL openflow rules
    '''
    my = config_dic['http_threads'][ threading.current_thread().name ]
    if not my.admin:
        bottle.abort(HTTP_Unauthorized, "Needed admin privileges")
        return
    #ignore input data
    r,c = config_dic['of_thread'].insert_task("clear-all")
    if r  < 0:
        print "http_delete_openflow_id error while launching openflow rules"
        bottle.abort(HTTP_Internal_Server_Error, c)
        return

    data={'result' : " Clearing openflow rules in process"}
    return format_out(data) 
开发者ID:nfvlabs,项目名称:openmano,代码行数:18,代码来源:httpserver.py

示例13: http_get_ports

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_get_ports():
    #obtain data
    my = config_dic['http_threads'][ threading.current_thread().name ]
    select_,where_,limit_ = filter_query_string(bottle.request.query, http2db_port,
            ('id','name','tenant_id','network_id','vpci','mac_address','device_owner','device_id',
             'binding:switch_port','binding:vlan','bandwidth','status','admin_state_up','ip_address') )
    #result, content = my.db.get_ports(where_)
    result, content = my.db.get_table(SELECT=select_, WHERE=where_, FROM='ports',LIMIT=limit_)
    if result < 0:
        print "http_get_ports Error", result, content
        bottle.abort(-result, content)
        return
    else:
        convert_boolean(content, ('admin_state_up',) )
        delete_nulls(content)      
        change_keys_http2db(content, http2db_port, reverse=True)
        data={'ports' : content}
        return format_out(data) 
开发者ID:nfvlabs,项目名称:openmano,代码行数:20,代码来源:httpserver.py

示例14: http_get_port_id

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_get_port_id(port_id):
    my = config_dic['http_threads'][ threading.current_thread().name ]
    #obtain data
    result, content = my.db.get_table(WHERE={'uuid': port_id}, FROM='ports')
    if result < 0:
        print "http_get_ports error", result, content
        bottle.abort(-result, content)
    elif result==0:
        print "http_get_ports port '%s' not found" % str(port_id)
        bottle.abort(HTTP_Not_Found, 'port %s not found' % port_id)
    else:
        convert_boolean(content, ('admin_state_up',) )
        delete_nulls(content)      
        change_keys_http2db(content, http2db_port, reverse=True)
        data={'port' : content[0]}
        return format_out(data) 
开发者ID:nfvlabs,项目名称:openmano,代码行数:18,代码来源:httpserver.py

示例15: http_delnetmap_datacenter_id

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import abort [as 别名]
def http_delnetmap_datacenter_id(tenant_id, datacenter_id, netmap_id=None):
    '''get datacenter networks, can use both uuid or name'''
    #obtain data
    result, datacenter_dict = mydb.get_table_by_uuid_name('datacenters', datacenter_id, "datacenter") 
    if result < 0:
        print "http_delnetmap_datacenter_id error %d %s" % (result, datacenter_dict)
        bottle.abort(-result, datacenter_dict)
    where_= {"datacenter_id":datacenter_dict['uuid']}
    if netmap_id:
        if utils.check_valid_uuid(netmap_id):
            where_["uuid"] = netmap_id
        else:
            where_["name"] = netmap_id
    #change_keys_http2db(content, http2db_tenant, reverse=True)
    result, content =mydb.delete_row_by_dict(FROM='datacenter_nets', WHERE= where_) 
    if result < 0:
        print "http_delnetmap_datacenter_id error %d %s" % (result, content)
        bottle.abort(-result, content)
    elif result == 0 and netmap_id :
        bottle.abort(HTTP_Not_Found, "No netmap found with " + " and ".join(map(lambda x: str(x[0])+": "+str(x[1]), where_.iteritems())) )
    if netmap_id:
        return format_out({"result": "netmap %s deleted" % netmap_id})
    else:
        return format_out({"result": "%d netmap deleted" % result}) 
开发者ID:nfvlabs,项目名称:openmano,代码行数:26,代码来源:httpserver.py


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