run jasper in debug mode

by default runs with local mic and no speakers (just prints out phrase);
optional command line parameter --log-to-console  prints out all debug
messages to console
file encoding switched to utf-8

removed some unicode prefixex (u'foo'  => 'foo')
added fully qualified logging class

allows to log on certain levels (debug, info, warn, error, panic) to
file or to console, prints out full stack trace for errors
cosmetic fixes

use logger instead print
initiate class members for later use
fixed utf-8
allow to pass command line parameters
addes persistent cache for audio files

In order to spare network bandwidth and processing time audio files
(synthesized by google engine) are stored in static/audio/cache/.
Persistent cache (shelve) stores cache entries in cache_phrases.db. Each
cache entry is a dictioniary, with phrase as key, and following
information: audio file name and sieze in bytes, count of cache hits
(uses), last cache entry hit date and time.
This file can be run stand alone with text console, allowing to list and
sort cache entries, test if audio file exists, play audio file, remove
cache entry, delte cache file. It also shows total space used by cache
and free space on file system.
When jasper starts (and whenever cache list ist called in stand alone)
cache will check if audio files exists - if not, then removes cache
entry.
TODO:
- check free space before adding new cache entries
- continuasly check for unused cache entries (low hits) and/or very
rearly used (old last hit date) and automaticly remove those entries
- add filter to list command (in stand alone mode)
- add bulk remove for certain criteria: with hits < N (in stand alone
mode)
- trim phrases, also with coma or full stop at the end of phrase
dynamicly module reload

all modules can be dynamically reloaded (including adding new ones) with
out restarting the whole jasper. It uses special phrase in
conversation.py. Usefull for debuging - when there is an error, stack
trace is logged, but you can still use old version (if was previously
loaded)
TODO:
- add dir change watch and auto reload
safe and universal string encoding convertion

unicodeToUTF8 accepts unicode strings, dictionaries, lists (including
objects deriving from those types) and any combination of them (complex
objects like dictionary of dictionary of lists.
fixed encoding and syntx bug
added use of audio files cache and phares spliting

audio files synthesised by google api are being cached to spare network
bandwidth and time. Phrases are being splited in smaller parts to make
better use of cache:
- when phrase contains | it will be splited exactly here
- when phrease contains ~ it won't be cached at all
- when phrase is longer than 30 characters (google api won't accep it)
it will be splited by one of given chars: . , : ; new line.
Example:
phrase 'Now it is|~ 8:45 AM' will be splited in two:
'Now it is' - will be cached for futher use
'8:45 AM' - won't be cached at all since it's unlikely to be used
frequently
TODO:
- cache control sings need to be hardcoded in each module and come core
classes - check what influance it has on espaek engine
futher localisatio fixes for polish language

since semantic doesen't support polish language used arrow instead (it
doesn't really covers all areas of semantic).
added support for current conditions
fixed problems with unicode string convertion to utf-8 (preatt nasty -
the whole comples feedparser object is in unicode)
added logging and utf-8
fixed phrases, explicit spliting by | and encoding
phrase fiexes and utf-8 encoding
fixed phrase spliting and encoding to utf-8
fixed spelling error, added logging, encoding to utf-8
make read chunk safe

there is a known random exception when calling stream.read(chunk). This
nasty fix catches exception, loggs stacktrace and continues to run
preventing jasper to crash. Cause remaind unknown and unresolved.
Rate change to meet defaultSampleRate
(audio.get_device_info_by_index(0)['defaultSampleRate']) doesn't seem to
help as uncle google sugests.
Phares splitting moved to speaker class.
prove of concept integration with XBMC

if you don't know XBMC you just need to get to know it, visit:
http://xbmc.org/
now it can make XBMC look for all albums from given artist and quee it
in chronological order in XBMC (using json API).
TODO:
- make it a real jasper module (it works only as stand alone)
- move host, port, user, pass to profile.yml
- make it play given artist, album, song, radio station, movie, show,
slide show, item from favorites and many more...
prelimenary integration with home automation server

This module communicates with my own home automation server running on
raspberry Pi (python Flask). It allows to control TV over HDMI cable
(CEC), ncplus satelite settopbox over Soap, HTPC over json and wall
plugs and window shatter shulter using Z-WAVE.
See:
https://github.com/HubertReX/Flask-Home-Automation
added command line parameters

current command line parameters:
--local or -l use local mic (input from keyboard); useful for debug
--no-speaker or -n do not use speach synthesiser (output to console and
log); useful for debug
--log-to-console or -c log everything to console instead of jasper.log
file
logger class moved to separate file