From fa1d4dae0ffa5a4ad1ceef051faa898588ab3c9a Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 25 Mar 2016 21:03:58 -0400 Subject: [PATCH] add --ui parameter to lbrynet-daemon to set ui path defaults on temp, which will download a .zip of the current ui to a temp directory, which will be deleted when lbrynet-daemon closes --- lbrynet/lbrynet_daemon/LBRYDaemonControl.py | 38 +++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/lbrynet/lbrynet_daemon/LBRYDaemonControl.py b/lbrynet/lbrynet_daemon/LBRYDaemonControl.py index ce6540d0c..d3f9d1e5a 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemonControl.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemonControl.py @@ -42,29 +42,39 @@ def start(): help="True or false, default true", type=str, 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") - tmpdir = tempfile.mkdtemp() - url = urlopen("https://rawgit.com/lbryio/lbry-web-ui/master/dist.zip") - z = ZipFile(StringIO(url.read())) - z.extractall(tmpdir) - - args = parser.parse_args() + download_ui = True + + if args.ui != "temp" and os.path.isdir(args.ui): + download_ui = False + ui_dir = args.ui + + if args.ui == "temp" or download_ui: + ui_dir = tempfile.mkdtemp() + url = urlopen("https://rawgit.com/lbryio/lbry-web-ui/master/dist.zip") + z = ZipFile(StringIO(url.read())) + z.extractall(ui_dir) + daemon = LBRYDaemon() daemon.setup(args.wallet, args.update) - root = LBRYindex(tmpdir) - root.putChild("css", static.File(os.path.join(tmpdir, "css"))) - root.putChild("font", static.File(os.path.join(tmpdir, "font"))) - root.putChild("img", static.File(os.path.join(tmpdir, "img"))) - root.putChild("js", static.File(os.path.join(tmpdir, "js"))) + root = LBRYindex(ui_dir) + root.putChild("css", static.File(os.path.join(ui_dir, "css"))) + root.putChild("font", static.File(os.path.join(ui_dir, "font"))) + root.putChild("img", static.File(os.path.join(ui_dir, "img"))) + root.putChild("js", static.File(os.path.join(ui_dir, "js"))) root.putChild(API_ADDRESS, daemon) root.putChild("webapi", LBRYDaemonWeb()) 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() - - shutil.rmtree(tmpdir) \ No newline at end of file + + if download_ui: + shutil.rmtree(ui_dir)