Merge pull request #24 from lbryio/development

fix daemon directories for linux
This commit is contained in:
Jack Robison 2016-03-28 14:58:15 -04:00
commit f4fd4245be
3 changed files with 37 additions and 20 deletions

View file

@ -51,9 +51,9 @@ class LBRYURIHandler(object):
try: try:
status = json.loads(self.daemon.is_running())['result'] status = json.loads(self.daemon.is_running())['result']
except: except:
pass status = None
if lbry_process: if lbry_process or status:
self.check_status() self.check_status()
started = False started = False
else: else:

View file

@ -121,11 +121,16 @@ class LBRYDaemon(jsonrpc.JSONRPC):
self.wallet_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbrycrd") self.wallet_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbrycrd")
elif sys.platform == "darwin": elif sys.platform == "darwin":
self.download_directory = os.path.join(os.path.expanduser("~"), 'Downloads') self.download_directory = os.path.join(os.path.expanduser("~"), 'Downloads')
# self.wallet_dir = os.path.join(os.path.expanduser("~"), "Library/Application Support/lbrycrd") if wallet_type == "lbrycrd":
self.wallet_dir = user_data_dir("lbrycrd")
else:
self.wallet_dir = user_data_dir("LBRY") self.wallet_dir = user_data_dir("LBRY")
else: else:
if wallet_type == "lbrycrd":
self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd") self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
self.download_directory = os.path.join(os.path.expanduser("~"), 'Downloads') else:
self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbryum")
self.download_directory = os.getcwd()
self.daemon_conf = os.path.join(self.wallet_dir, 'daemon_settings.conf') self.daemon_conf = os.path.join(self.wallet_dir, 'daemon_settings.conf')
self.wallet_conf = os.path.join(self.wallet_dir, "lbrycrd.conf") self.wallet_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
self.wallet_user = None self.wallet_user = None

View file

@ -42,29 +42,41 @@ def start():
help="True or false, default true", help="True or false, default true",
type=str, type=str,
default="True") default="True")
parser.add_argument("--ui",
help="temp or path, default temp, path is the path of the dist folder",
default="temp")
log.info("Starting lbrynet-daemon from command line") log.info("Starting lbrynet-daemon from command line")
tmpdir = tempfile.mkdtemp() args = parser.parse_args()
download_ui = True
if args.ui != "temp" and os.path.isdir(args.ui):
download_ui = False
ui_dir = args.ui
log.info("Using user specified UI directory: " + str(ui_dir))
if args.ui == "temp" or download_ui:
log.info("Downloading current web ui to temp directory")
ui_dir = tempfile.mkdtemp()
url = urlopen("https://rawgit.com/lbryio/lbry-web-ui/master/dist.zip") url = urlopen("https://rawgit.com/lbryio/lbry-web-ui/master/dist.zip")
z = ZipFile(StringIO(url.read())) z = ZipFile(StringIO(url.read()))
z.extractall(tmpdir) z.extractall(ui_dir)
args = parser.parse_args()
daemon = LBRYDaemon() daemon = LBRYDaemon()
daemon.setup(args.wallet, args.update) daemon.setup(args.wallet, args.update)
root = LBRYindex(tmpdir) root = LBRYindex(ui_dir)
root.putChild("css", static.File(os.path.join(tmpdir, "css"))) root.putChild("css", static.File(os.path.join(ui_dir, "css")))
root.putChild("font", static.File(os.path.join(tmpdir, "font"))) root.putChild("font", static.File(os.path.join(ui_dir, "font")))
root.putChild("img", static.File(os.path.join(tmpdir, "img"))) root.putChild("img", static.File(os.path.join(ui_dir, "img")))
root.putChild("js", static.File(os.path.join(tmpdir, "js"))) root.putChild("js", static.File(os.path.join(ui_dir, "js")))
root.putChild(API_ADDRESS, daemon) root.putChild(API_ADDRESS, daemon)
root.putChild("webapi", LBRYDaemonWeb()) root.putChild("webapi", LBRYDaemonWeb())
root.putChild("view", LBRYFileRender()) root.putChild("view", LBRYFileRender())
reactor.listenTCP(API_PORT, server.Site(root), interface=API_INTERFACE)
reactor.listenTCP(API_PORT, server.Site(root), interface=API_INTERFACE)
reactor.run() reactor.run()
shutil.rmtree(tmpdir) if download_ui:
shutil.rmtree(ui_dir)