Util – utility functions

Copyright (c) 2010 The Echo Nest. All rights reserved. Created by Tyler Williams on 2010-04-25.

Utility functions to support the Echo Nest web API interface.

exception pyechonest.util.EchoNestAPIError(code, message, headers)

API Specific Errors.

__init__(code, message, headers)
exception pyechonest.util.EchoNestException(code, message, headers)

Parent exception class. Catches API and URL/HTTP errors.

__init__(code, message, headers)
exception pyechonest.util.EchoNestIOError(code=None, error=None, headers=[('User-Agent', 'Pyechonest 7.2.1')])

URL and HTTP errors.

__init__(code=None, error=None, headers=[('User-Agent', 'Pyechonest 7.2.1')])
class pyechonest.util.MyBaseHandler
default_open(request)
class pyechonest.util.MyErrorProcessor
http_response(request, response)
pyechonest.util.callm(method, param_dict, POST=False, socket_timeout=None, data=None)

Call the api! Param_dict is a regular python dictionary so if you want to have multi-valued params put them in a list.

** note, if we require 2.6, we can get rid of this timeout munging.

pyechonest.util.codegen(filename, start=0, duration=30)
pyechonest.util.fix(x)
pyechonest.util.get_successful_response(raw_json)
pyechonest.util.oauthgetm(method, param_dict, socket_timeout=None)
pyechonest.util.postChunked(host, selector, fields, files)

Attempt to replace postMultipart() with nearly-identical interface. (The files tuple no longer requires the filename, and we only return the response body.) Uses the urllib2_file.py originally from http://fabien.seisen.org which was also drawn heavily from http://code.activestate.com/recipes/146306/ .

This urllib2_file.py is more desirable because of the chunked uploading from a file pointer (no need to read entire file into memory) and the ability to work from behind a proxy (due to its basis on urllib2).

pyechonest.util.reallyUTF8(s)
pyechonest.util.reallyunicode(s, encoding='utf-8')

Previous topic

Catalog – catalog methods

Next topic

Config – configuration file

This Page