From 78c560a3be74ab7a20fc922f02934e12052dfe59 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Tue, 17 Jul 2018 21:35:53 -0300 Subject: [PATCH] general incomplete porting of daemon booting ~> py3 --- lbrynet/conf.py | 6 +++--- lbrynet/core/system_info.py | 2 +- lbrynet/core/utils.py | 9 +++++++-- lbrynet/daemon/DaemonControl.py | 21 +++++++++++---------- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/lbrynet/conf.py b/lbrynet/conf.py index 25d1edb74..01b3f22f7 100644 --- a/lbrynet/conf.py +++ b/lbrynet/conf.py @@ -313,7 +313,7 @@ class Config(object): environment=None, cli_settings=None): self._installation_id = None - self._session_id = base58.b58encode(utils.generate_id()) + self._session_id = base58.b58encode(utils.generate_id()).decode() self._node_id = None self._fixed_defaults = fixed_defaults @@ -517,7 +517,7 @@ class Config(object): @staticmethod def _convert_conf_file_lists_reverse(converted): rev = {} - for k in converted.iterkeys(): + for k in converted.keys(): if k in ADJUSTABLE_SETTINGS and len(ADJUSTABLE_SETTINGS[k]) == 4: rev[k] = ADJUSTABLE_SETTINGS[k][3](converted[k]) else: @@ -527,7 +527,7 @@ class Config(object): @staticmethod def _convert_conf_file_lists(decoded): converted = {} - for k, v in decoded.iteritems(): + for k, v in decoded.items(): if k in ADJUSTABLE_SETTINGS and len(ADJUSTABLE_SETTINGS[k]) >= 3: converted[k] = ADJUSTABLE_SETTINGS[k][2](v) else: diff --git a/lbrynet/core/system_info.py b/lbrynet/core/system_info.py index 66ce46b32..9725f3c7f 100644 --- a/lbrynet/core/system_info.py +++ b/lbrynet/core/system_info.py @@ -20,7 +20,7 @@ def get_lbrynet_version(): return subprocess.check_output( ['git', '--git-dir='+git_dir, 'describe', '--dirty', '--always'], stderr=devnull - ).strip().lstrip('v') + ).decode().strip().lstrip('v') except (subprocess.CalledProcessError, OSError): print("failed to get version from git") return lbrynet_version diff --git a/lbrynet/core/utils.py b/lbrynet/core/utils.py index 1f7f8515e..72eacee55 100644 --- a/lbrynet/core/utils.py +++ b/lbrynet/core/utils.py @@ -1,4 +1,5 @@ import base64 +import codecs import datetime import random import socket @@ -88,12 +89,16 @@ def version_is_greater_than(a, b): return pkg_resources.parse_version(a) > pkg_resources.parse_version(b) +def rot13(some_str): + return codecs.encode(some_str, 'rot_13') + + def deobfuscate(obfustacated): - return base64.b64decode(obfustacated.decode('rot13')) + return base64.b64decode(rot13(obfustacated)) def obfuscate(plain): - return base64.b64encode(plain).encode('rot13') + return rot13(base64.b64encode(plain)) def check_connection(server="lbry.io", port=80, timeout=2): diff --git a/lbrynet/daemon/DaemonControl.py b/lbrynet/daemon/DaemonControl.py index 8db0511b9..f83c63d62 100644 --- a/lbrynet/daemon/DaemonControl.py +++ b/lbrynet/daemon/DaemonControl.py @@ -12,8 +12,8 @@ from lbrynet.core import log_support import argparse import logging.handlers -from twisted.internet import reactor -from jsonrpc.proxy import JSONRPCProxy +from twisted.internet import defer, reactor +#from jsonrpc.proxy import JSONRPCProxy from lbrynet import conf from lbrynet.core import utils, system_info @@ -65,7 +65,7 @@ def start(): if args.version: version = system_info.get_platform(get_ip=False) version['installation_id'] = conf.settings.installation_id - print utils.json_dumps_pretty(version) + print(utils.json_dumps_pretty(version)) return lbrynet_log = conf.settings.get_log_filename() @@ -73,13 +73,14 @@ def start(): log_support.configure_loggly_handler() log.debug('Final Settings: %s', conf.settings.get_current_settings_dict()) - try: - log.debug('Checking for an existing lbrynet daemon instance') - JSONRPCProxy.from_url(conf.settings.get_api_connection_string()).status() - log.info("lbrynet-daemon is already running") - return - except Exception: - log.debug('No lbrynet instance found, continuing to start') + # fixme: fix that, JSONRPCProxy is gone on py3 + #try: + # log.debug('Checking for an existing lbrynet daemon instance') + # JSONRPCProxy.from_url(conf.settings.get_api_connection_string()).status() + # log.info("lbrynet-daemon is already running") + # return + #except Exception: + # log.debug('No lbrynet instance found, continuing to start') log.info("Starting lbrynet-daemon from command line")