This repository has been archived by the owner on Jan 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy path__init__.py.tmpl
69 lines (50 loc) · 1.98 KB
/
__init__.py.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from __future__ import unicode_literals
import logging
import os
import tornado.web
from . import mem
from .services.sync import sync
from .services.autoupdate import update
from .services.queuemanager import core as QueueManagerCore
from .services.queuemanager import frontend
from .services.queuemanager import requesthandler as QueueManagerRequestHandler
from mopidy import config, ext
__version__ = '<%= version %>'
__ext_name__ = 'mopify'
__verbosemode__ = False
logger = logging.getLogger(__ext_name__)
class MopifyExtension(ext.Extension):
dist_name = 'Mopidy-Mopify'
ext_name = __ext_name__
version = __version__
def get_default_config(self):
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
return config.read(conf_file)
def get_config_schema(self):
schema = super(MopifyExtension, self).get_config_schema()
schema['debug'] = config.Boolean()
return schema
def setup(self, registry):
sync.Sync();
# Create instances
mem.queuemanager = QueueManagerCore.QueueManager()
# Add Queuemanager Frontend class
registry.add('frontend', frontend.QueueManagerFrontend)
# Add web extension
registry.add('http:app', {
'name': self.ext_name,
'factory': mopify_client_factory
})
logger.info('Setup Mopify')
def mopify_client_factory(config, core):
directory = 'debug' if config.get(__ext_name__)['debug'] is True else 'min'
mopifypath = os.path.join(os.path.dirname(__file__), 'static', directory)
return [
('/sync/(.*)', sync.RootRequestHandler, {'core': core, 'config': config}),
('/queuemanager/(.*)', QueueManagerRequestHandler.RequestHandler, {'core': core, 'config': config}),
('/update', update.UpdateRequestHandler, {'core': core, 'config': config}),
(r'/(.*)', tornado.web.StaticFileHandler, {
"path": mopifypath,
"default_filename": "index.html"
})
]