From 31ee3fb12b30632f4353263935146ff813d0c21f Mon Sep 17 00:00:00 2001 From: jackrobison Date: Tue, 27 Oct 2015 12:07:09 -0400 Subject: [PATCH] Update LBRYConsole.py Forgetting to add a new line at the end of lbrycrd.conf will no longer mess up the rpc login. --- lbrynet/lbrynet_console/LBRYConsole.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lbrynet/lbrynet_console/LBRYConsole.py b/lbrynet/lbrynet_console/LBRYConsole.py index 91800dce9..3b322fb39 100644 --- a/lbrynet/lbrynet_console/LBRYConsole.py +++ b/lbrynet/lbrynet_console/LBRYConsole.py @@ -220,11 +220,25 @@ class LBRYConsole(): d = self.settings.save_lbryid(self.lbryid) return d + def _check_config_newlines(self, config_path): + f = open(config_path, 'r') + lines = [l for l in f] + f.close() + if lines[-1][-1] != "\n": + f = open(config_path, 'w') + for l in lines: + if l[-1] == "\n": + f.write(l) + else: + f.write(l + "\n") + f.close() + def _get_lbrycrd_settings(self): settings = {"username": "rpcuser", "password": "rpcpassword", "rpc_port": 8332} if os.path.exists(self.lbrycrd_conf): + self._check_config_newlines(self.lbrycrd_conf) lbrycrd_conf = open(self.lbrycrd_conf) for l in lbrycrd_conf: if l.startswith("rpcuser="): @@ -556,4 +570,4 @@ def launch_lbry_console(): d.addErrback(lambda _: reactor.stop()) reactor.addSystemEventTrigger('before', 'shutdown', console.shut_down) - reactor.run() \ No newline at end of file + reactor.run()