2016-04-21 04:02:52 +02:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
2016-10-07 20:01:59 +02:00
|
|
|
from twisted.internet import defer
|
2016-10-23 07:17:24 +02:00
|
|
|
|
2016-10-31 22:19:19 +01:00
|
|
|
from lbrynet.conf import settings
|
2016-09-27 20:18:35 +02:00
|
|
|
from lbrynet.lbrynet_daemon.Daemon import Daemon
|
2016-10-07 20:01:59 +02:00
|
|
|
from lbrynet.lbrynet_daemon.Resources import LBRYindex, HostedEncryptedFile, EncryptedFileUpload
|
2016-10-27 21:18:25 +02:00
|
|
|
from lbrynet.conf import settings
|
2016-04-21 04:02:52 +02:00
|
|
|
|
|
|
|
|
2016-05-01 11:17:59 +02:00
|
|
|
log = logging.getLogger(__name__)
|
2016-07-25 20:04:30 +02:00
|
|
|
|
2016-04-21 04:02:52 +02:00
|
|
|
|
2016-09-27 20:18:35 +02:00
|
|
|
class DaemonServer(object):
|
2016-10-26 09:16:33 +02:00
|
|
|
def _setup_server(self):
|
2016-10-31 22:19:19 +01:00
|
|
|
ui_path = os.path.join(settings.ensure_data_dir(), "lbry-ui", "active")
|
2016-10-23 07:17:24 +02:00
|
|
|
self.root = LBRYindex(ui_path)
|
2016-10-26 09:16:33 +02:00
|
|
|
self._api = Daemon(self.root)
|
2016-09-27 20:18:16 +02:00
|
|
|
self.root.putChild("view", HostedEncryptedFile(self._api))
|
|
|
|
self.root.putChild("upload", EncryptedFileUpload(self._api))
|
2016-10-19 06:12:44 +02:00
|
|
|
self.root.putChild(settings.API_ADDRESS, self._api)
|
2016-04-21 04:02:52 +02:00
|
|
|
return defer.succeed(True)
|
|
|
|
|
2016-10-26 09:16:33 +02:00
|
|
|
def start(self):
|
|
|
|
d = self._setup_server()
|
2016-10-19 06:12:44 +02:00
|
|
|
d.addCallback(lambda _: self._api.setup())
|
2016-04-21 04:02:52 +02:00
|
|
|
return d
|