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


Python util.callm函数代码示例

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


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

示例1: list

def list(sandbox_name, results=15, start=0):
    """
    Returns a list of all assets available in this sandbox
    
    Args:
        sandbox_name (str): A string representing the name of the sandbox

    Kwargs:
        results (int): An integer number of results to return
        
        start (int): An integer starting value for the result set
        
    Returns:
        A list of asset dictionaries
    
    Example:

    >>> sandbox.list('bluenote')
    [{}, {}]
    >>> 

    
    """
    result = util.callm("%s/%s" % ('sandbox', 'list'), {'sandbox':sandbox_name, 'results': results, 'start': start})
    assets = result['response']['assets']
    start = result['response']['start']
    total = result['response']['total']

    return ResultList(assets, start, total)
开发者ID:15OlegMasuik,项目名称:pyechonest,代码行数:29,代码来源:sandbox.py

示例2: post_attribute

 def post_attribute(self, method_name, **kwargs):
     if 'data' in kwargs:
         data = kwargs.pop('data')
     else:
         data = {}
     result = util.callm("%s/%s" % (self._object_type, method_name), kwargs, POST=True, data=data)
     return result['response']
开发者ID:CosmoGlenns,项目名称:automaticdj,代码行数:7,代码来源:proxies.py

示例3: list_catalogs

def list_catalogs(results=30, start=0):
    """
    Returns list of all catalogs created on this API key

    Args:

    Kwargs:
        results (int): An integer number of results to return

        start (int): An integer starting value for the result set

    Returns:
        A list of catalog objects

    Example:

    >>> catalog.list_catalogs()
    [<catalog - test_artist_catalog>, <catalog - test_song_catalog>, <catalog - my_songs>]
    >>>

    """
    result = util.callm("%s/%s" % ('catalog', 'list'), {'results': results, 'start': start})
    cats = [Catalog(**util.fix(d)) for d in result['response']['catalogs']]
    start = result['response']['start']
    total = result['response']['total']
    return ResultList(cats, start, total)
开发者ID:NewAmbition,项目名称:pyechonest,代码行数:26,代码来源:catalog.py

示例4: top_terms

def top_terms(results=15):
    """Get a list of the top overall terms
        
    Args:
    
    Kwargs:
        results (int): An integer number of results to return
        
    Returns:
        A list of term document dicts
    
    Example:
    
    >>> terms = artist.top_terms(results=5)
    >>> terms
    [{u'frequency': 1.0, u'name': u'rock'},
     {u'frequency': 0.99054710039307992, u'name': u'electronic'},
     {u'frequency': 0.96131624654034398, u'name': u'hip hop'},
     {u'frequency': 0.94358477322411127, u'name': u'jazz'},
     {u'frequency': 0.94023302416455468, u'name': u'pop rock'}]
    >>> 
    """
    
    kwargs = {}
    if results:
        kwargs['results'] = results
    
    """Get top terms"""
    result = util.callm("%s/%s" % ('artist', 'top_terms'), kwargs)
    return result['response']['terms']
开发者ID:atl,项目名称:pyechonest,代码行数:30,代码来源:artist.py

示例5: profile

def profile(ids=None, track_ids=None, buckets=None, limit=False):
    """get the profiles for multiple songs at once
        
    Args:
        ids (str or list): a song ID or list of song IDs
    
    Kwargs:
        buckets (list): A list of strings specifying which buckets to retrieve

        limit (bool): A boolean indicating whether or not to limit the results to one of the id spaces specified in buckets
    
    Returns:
        A list of term document dicts
    
    Example:

    >>> song_ids = ['SOBSLVH12A8C131F38', 'SOXMSGY1338A5D5873', 'SOJPHZO1376210AFE5', 'SOBHNKR12AB0186218', 'SOSJAHD13770F4D40C']
    >>> songs = song.profile(song_ids, buckets=['audio_summary'])
    [<song - Say It Ain't So>,
     <song - Island In The Sun>,
     <song - My Name Is Jonas>,
     <song - Buddy Holly>]
    >>> songs[0].audio_summary
    {u'analysis_url': u'https://echonest-analysis.s3.amazonaws.com/TR/7VRBNguufpHAQQ4ZjJ0eWsIQWl2S2_lrK-7Bp2azHOvPN4VFV-YnU7uO0dXgYtOKT-MTEa/3/full.json?Signature=hmNghHwfEsA4JKWFXnRi7mVP6T8%3D&Expires=1349809918&AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ',
     u'audio_md5': u'b6079b2b88f8265be8bdd5fe9702e05c',
     u'danceability': 0.64540643050283253,
     u'duration': 255.92117999999999,
     u'energy': 0.30711665772260549,
     u'key': 8,
     u'liveness': 0.088994423525370583,
     u'loudness': -9.7799999999999994,
     u'mode': 1,
     u'speechiness': 0.031970700260699259,
     u'tempo': 76.049999999999997,
     u'time_signature': 4}
    >>> 
    """
    kwargs = {}

    if ids:
        if not isinstance(ids, list):
            ids = [ids]
        kwargs['id'] = ids

    if track_ids:
        if not isinstance(track_ids, list):
            track_ids = [track_ids]
        kwargs['track_id'] = track_ids

    buckets = buckets or []
    if buckets:
        kwargs['bucket'] = buckets

    if limit:
        kwargs['limit'] = 'true'
    
    result = util.callm("%s/%s" % ('song', 'profile'), kwargs)
    return [Song(**util.fix(s_dict)) for s_dict in result['response']['songs']]
开发者ID:Eun,项目名称:pyechonest,代码行数:58,代码来源:song.py

示例6: suggest

def suggest(q='', results=15, buckets=None, limit=False, max_familiarity=None, min_familiarity=None,
                max_hotttnesss=None, min_hotttnesss=None):
    """Suggest artists based upon partial names.

    Args:

    Kwargs:
        q (str): The text to suggest artists from

        results (int): An integer number of results to return

        buckets (list): A list of strings specifying which buckets to retrieve

        limit (bool): A boolean indicating whether or not to limit the results to one of the id spaces specified in buckets

        max_familiarity (float): A float specifying the max familiarity of artists to search for

        min_familiarity (float): A float specifying the min familiarity of artists to search for

        max_hotttnesss (float): A float specifying the max hotttnesss of artists to search for

        min_hotttnesss (float): A float specifying the max hotttnesss of artists to search for

    Returns:
        A list of Artist objects

    Example:

    >>> results = artist.suggest(text='rad')
    >>> results

    >>> 

    """

    buckets = buckets or []
    kwargs = {}

    kwargs['q'] = q

    if max_familiarity is not None:
        kwargs['max_familiarity'] = max_familiarity
    if min_familiarity is not None:
        kwargs['min_familiarity'] = min_familiarity
    if max_hotttnesss is not None:
        kwargs['max_hotttnesss'] = max_hotttnesss
    if min_hotttnesss is not None:
        kwargs['min_hotttnesss'] = min_hotttnesss
    if results:
        kwargs['results'] = results
    if buckets:
        kwargs['bucket'] = buckets
    if limit:
        kwargs['limit'] = 'true'

    result = util.callm("%s/%s" % ('artist', 'suggest'), kwargs)

    return [Artist(**util.fix(a_dict)) for a_dict in result['response']['artists']]
开发者ID:atl,项目名称:pyechonest,代码行数:58,代码来源:artist.py

示例7: profile

def profile(ids=None, track_ids=None, buckets=None, limit=False):
    """get the profiles for multiple songs at once
        
    Args:
        ids (str or list): a song ID or list of song IDs
    
    Kwargs:
        buckets (list): A list of strings specifying which buckets to retrieve

        limit (bool): A boolean indicating whether or not to limit the results to one of the id spaces specified in buckets
    
    Returns:
        A list of term document dicts
    
    Example:

    >>> song_ids = [u'SOGNMKX12B0B806320', u'SOLUHKP129F0698D49', u'SOOLGAZ127F3E1B87C', u'SOQKVPH12A58A7AF4D', u'SOHKEEM1288D3ED9F5']
    >>> songs = song.profile(song_ids, buckets=['audio_summary'])
    [<song - chickfactor>,
     <song - One Step Closer>,
     <song - And I Am Telling You I'm Not Going (Glee Cast Version)>,
     <song - In This Temple As In The Hearts Of Man For Whom He Saved The Earth>,
     <song - Octet>]
    >>> songs[0].audio_summary
    {u'analysis_url': u'https://echonest-analysis.s3.amazonaws.com:443/TR/TRKHTDL123E858AC4B/3/full.json?Signature=sE6OwAzg6UvrtiX6nJJW1t7E6YI%3D&Expires=1287585351&AWSAccessKeyId=AKIAIAFEHLM3KJ2XMHRA',
     u'danceability': None,
     u'duration': 211.90485000000001,
     u'energy': None,
     u'key': 7,
     u'loudness': -16.736999999999998,
     u'mode': 1,
     u'tempo': 94.957999999999998,
     u'time_signature': 4}
    >>> 
    
    """
    kwargs = {}

    if ids:
        if not isinstance(ids, list):
            ids = [ids]
        kwargs['id'] = ids

    if track_ids:
        if not isinstance(track_ids, list):
            track_ids = [track_ids]
        kwargs['track_id'] = track_ids

    buckets = buckets or []
    if buckets:
        kwargs['bucket'] = buckets

    if limit:
        kwargs['limit'] = 'true'
    
    result = util.callm("%s/%s" % ('song', 'profile'), kwargs)
    return [Song(**util.fix(s_dict)) for s_dict in result['response']['songs']]
开发者ID:MechanisM,项目名称:pyechonest,代码行数:57,代码来源:song.py

示例8: _upload

def _upload(param_dict, timeout, data):
    """
    Calls upload either with a local audio file,
    or a url. Returns a track object.
    """
    param_dict['format'] = 'json'
    param_dict['wait'] = 'true'
    param_dict['bucket'] = 'audio_summary'
    result = util.callm('track/upload', param_dict, POST = True, socket_timeout = 300,  data = data)
    return _track_from_response(result, timeout)
开发者ID:15OlegMasuik,项目名称:pyechonest,代码行数:10,代码来源:track.py

示例9: create_catalog_by_name

def create_catalog_by_name(name, T="general"):
    """
    Creates a catalog object, with a given name. Does not check to see if the catalog already exists.

    Create a catalog object like
    """
    result = util.callm("catalog/create", {}, POST=True, 
                            data={"name":name, "type":T})
    result = result['response']
    return Catalog(result['id'], **dict( (k,result[k]) for k in ('name', 'type')))
开发者ID:15OlegMasuik,项目名称:pyechonest,代码行数:10,代码来源:catalog.py

示例10: _upload

def _upload(param_dict, timeout, data=None):
    """
    Calls upload either with a local audio file,
    or a url. Returns a track object.
    """
    param_dict["format"] = "json"
    param_dict["wait"] = "true"
    param_dict["bucket"] = "audio_summary"
    result = util.callm("track/upload", param_dict, POST=True, socket_timeout=300, data=data)
    return _track_from_response(result, timeout)
开发者ID:rufman,项目名称:pyechonest,代码行数:10,代码来源:track.py

示例11: get_catalog_by_name

def get_catalog_by_name(name):
    """
    Grabs a catalog by name, if its there on the api key.
    Otherwise, an error is thrown (mirroring the API)
    """
    kwargs = {
            'name' : name,
        }
    result = util.callm("%s/%s" % ('catalog', 'profile'), kwargs)
    return Catalog(**util.fix(result['response']['catalog']))
开发者ID:NewAmbition,项目名称:pyechonest,代码行数:10,代码来源:catalog.py

示例12: _wait_for_pending_track

def _wait_for_pending_track(trid, timeout):
    status = 'pending'
    start_time = time.time()
    while status == 'pending' and time.time() - start_time < timeout:
        time.sleep(1)
        param_dict = {'id': trid} # dict(id = identifier)
        param_dict['format'] = 'json'
        param_dict['bucket'] = 'audio_summary'
        result = util.callm('track/profile', param_dict)
        status = result['response']['track']['status'].lower()
    return result
开发者ID:andreasjansson,项目名称:pyechonest,代码行数:11,代码来源:track.py

示例13: _wait_for_pending_track

def _wait_for_pending_track(trid, timeout):
    # timeout is ignored for now
    status = 'pending'
    while status == 'pending':
        time.sleep(1)
        param_dict = {'id': trid}  # dict(id = identifier)
        param_dict['format'] = 'json'
        param_dict['bucket'] = 'audio_summary'
        result = util.callm('track/profile', param_dict)
        status = result['response']['track']['status'].lower()
        # TODO: timeout if necessary
    return result
开发者ID:davidpope,项目名称:pyechonest,代码行数:12,代码来源:track.py

示例14: _wait_for_pending_track

def _wait_for_pending_track(trid, timeout):
    end = time.time() + timeout
    status = 'pending'
    while status == 'pending':
        if time.time() > end:
            raise Exception('analysis timed out after %2.2f seconds' % timeout)
        time.sleep(1)
        if time.time() > end:
            raise Exception('the operation didn\'t complete before the timeout (%d secs)' % timeout)
        param_dict = {'id': trid}  # dict(id = identifier)
        param_dict['format'] = 'json'
        param_dict['bucket'] = 'audio_summary'
        result = util.callm('track/profile', param_dict)
        status = result['response']['track']['status'].lower()
    return result
开发者ID:psobot,项目名称:pyechonest,代码行数:15,代码来源:track.py

示例15: _wait_for_pending_track

def _wait_for_pending_track(trid, timeout):
    status = 'pending'
    param_dict = {'id': trid}
    param_dict['format'] = 'json'
    param_dict['bucket'] = 'audio_summary'
    start_time = time.time()
    end_time = start_time + timeout
    # counter for seconds to wait before checking track profile again.
    timeout_counter = 3
    while status == 'pending' and time.time() < end_time:
        time.sleep(timeout_counter)
        result = util.callm('track/profile', param_dict)
        status = result['response']['track']['status'].lower()
        # Slowly increment to wait longer each time.
        timeout_counter += timeout_counter / 2
    return result
开发者ID:15OlegMasuik,项目名称:pyechonest,代码行数:16,代码来源:track.py


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