http: Define extension

This commit is contained in:
Stein Magnus Jodal 2013-04-01 15:06:14 +02:00
parent 5b6fc25cf8
commit 0f1c4c1dff
2 changed files with 37 additions and 2 deletions

View File

@ -1,4 +1,11 @@
"""
from __future__ import unicode_literals
import mopidy
from mopidy import ext
from mopidy.exceptions import ExtensionError
__doc__ = """
The HTTP frontends lets you control Mopidy through HTTP and WebSockets, e.g.
from a web based client.
@ -477,5 +484,32 @@ Example to get started with
and all events that are emitted.
"""
# flake8: noqa
# TODO Move import into method when FRONTENDS setting is removed
from .actor import HttpFrontend
class Extension(ext.Extension):
name = 'Mopidy-HTTP'
version = mopidy.__version__
def get_default_config(self):
return '[http]'
def validate_config(self, config):
pass
def validate_environment(self):
try:
import cherrypy # noqa
except ImportError as e:
raise ExtensionError('Library cherrypy not found', e)
try:
import ws4py # noqa
except ImportError as e:
raise ExtensionError('Library ws4py not found', e)
def get_frontend_classes(self):
return [HttpFrontend]

View File

@ -45,6 +45,7 @@ setup(
'mopidy-scan = mopidy.scanner:main',
],
b'mopidy.extension': [
'http = mopidy.frontends.http:Extension',
'local = mopidy.backends.local:Extension',
'mpd = mopidy.frontends.mpd:Extension',
'mpris = mopidy.frontends.mpris:Extension',