From 0f1c4c1dff1cd364285c6fcff6fec478e308418a Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 1 Apr 2013 15:06:14 +0200 Subject: [PATCH] http: Define extension --- mopidy/frontends/http/__init__.py | 38 +++++++++++++++++++++++++++++-- setup.py | 1 + 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/mopidy/frontends/http/__init__.py b/mopidy/frontends/http/__init__.py index e81ddf3f..fb354c09 100644 --- a/mopidy/frontends/http/__init__.py +++ b/mopidy/frontends/http/__init__.py @@ -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] diff --git a/setup.py b/setup.py index 3672e2f2..db2b1932 100644 --- a/setup.py +++ b/setup.py @@ -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',