forked from LBRYCommunity/lbry-sdk
add --version flag, remove simplejson dependency
This commit is contained in:
parent
1c2290dc8e
commit
29dea4901e
9 changed files with 60 additions and 48 deletions
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
|
@ -32,7 +32,7 @@ Tell us what happens instead
|
||||||
|
|
||||||
<!-- For the daemon, run:
|
<!-- For the daemon, run:
|
||||||
curl 'http://localhost:5279/lbryapi' --data '{"method":"version"}'
|
curl 'http://localhost:5279/lbryapi' --data '{"method":"version"}'
|
||||||
and include the output -->
|
and include the full output -->
|
||||||
|
|
||||||
- LBRY Daemon version:
|
- LBRY Daemon version:
|
||||||
- LBRY App version:
|
- LBRY App version:
|
||||||
|
|
|
@ -9,12 +9,12 @@ at anytime.
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
*
|
* Added `--version` flag
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
*
|
* Removed `simplejson` dependency in favor of bulitin `json`
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import platform
|
import platform
|
||||||
import simplejson as json
|
import json
|
||||||
|
|
||||||
from urllib2 import urlopen
|
from urllib2 import urlopen
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from lbrynet import build_type
|
||||||
from lbryum.version import LBRYUM_VERSION as lbryum_version
|
from lbryum.version import LBRYUM_VERSION as lbryum_version
|
||||||
|
|
||||||
|
|
||||||
def get_platform():
|
def get_platform(get_ip=True):
|
||||||
p = {
|
p = {
|
||||||
"processor": platform.processor(),
|
"processor": platform.processor(),
|
||||||
"python_version": platform.python_version(),
|
"python_version": platform.python_version(),
|
||||||
|
@ -17,13 +17,13 @@ def get_platform():
|
||||||
"os_system": platform.system(),
|
"os_system": platform.system(),
|
||||||
"lbrynet_version": lbrynet_version,
|
"lbrynet_version": lbrynet_version,
|
||||||
"lbryum_version": lbryum_version,
|
"lbryum_version": lbryum_version,
|
||||||
"ui_version": "not loaded yet",
|
|
||||||
"build": build_type.BUILD, # travis sets this during build step
|
"build": build_type.BUILD, # travis sets this during build step
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
if get_ip:
|
||||||
p['ip'] = json.load(urlopen('http://jsonip.com'))['ip']
|
try:
|
||||||
except:
|
p['ip'] = json.load(urlopen('http://jsonip.com'))['ip']
|
||||||
p['ip'] = "Could not determine IP"
|
except:
|
||||||
|
p['ip'] = "Could not determine IP"
|
||||||
|
|
||||||
return p
|
return p
|
||||||
|
|
|
@ -4,16 +4,15 @@ import logging
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
import string
|
import string
|
||||||
|
import json
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from lbrynet.core.cryptoutils import get_lbry_hash_obj
|
from lbrynet.core.cryptoutils import get_lbry_hash_obj
|
||||||
|
|
||||||
|
|
||||||
# digest_size is in bytes, and blob hashes are hex encoded
|
# digest_size is in bytes, and blob hashes are hex encoded
|
||||||
blobhash_length = get_lbry_hash_obj().digest_size * 2
|
blobhash_length = get_lbry_hash_obj().digest_size * 2
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,3 +113,7 @@ def get_sd_hash(stream_info):
|
||||||
if not stream_info:
|
if not stream_info:
|
||||||
return None
|
return None
|
||||||
return stream_info['sources']['lbry_sd_hash']
|
return stream_info['sources']['lbry_sd_hash']
|
||||||
|
|
||||||
|
|
||||||
|
def json_dumps_pretty(obj, **kwargs):
|
||||||
|
return json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': '), **kwargs)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import re
|
||||||
import base58
|
import base58
|
||||||
import requests
|
import requests
|
||||||
import urllib
|
import urllib
|
||||||
import simplejson as json
|
import json
|
||||||
from requests import exceptions as requests_exceptions
|
from requests import exceptions as requests_exceptions
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
@ -36,8 +36,7 @@ from lbrynet.lbrynet_daemon.Publisher import Publisher
|
||||||
from lbrynet.lbrynet_daemon.ExchangeRateManager import ExchangeRateManager
|
from lbrynet.lbrynet_daemon.ExchangeRateManager import ExchangeRateManager
|
||||||
from lbrynet.lbrynet_daemon.auth.server import AuthJSONRPCServer
|
from lbrynet.lbrynet_daemon.auth.server import AuthJSONRPCServer
|
||||||
from lbrynet.core.PaymentRateManager import OnlyFreePaymentsManager
|
from lbrynet.core.PaymentRateManager import OnlyFreePaymentsManager
|
||||||
from lbrynet.core import log_support, utils
|
from lbrynet.core import log_support, utils, system_info
|
||||||
from lbrynet.core import system_info
|
|
||||||
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier, download_sd_blob
|
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier, download_sd_blob
|
||||||
from lbrynet.core.Session import Session
|
from lbrynet.core.Session import Session
|
||||||
from lbrynet.core.Wallet import LBRYumWallet, SqliteStorage, ClaimOutpoint
|
from lbrynet.core.Wallet import LBRYumWallet, SqliteStorage, ClaimOutpoint
|
||||||
|
@ -142,14 +141,14 @@ class CheckInternetConnection(object):
|
||||||
|
|
||||||
|
|
||||||
class CheckRemoteVersion(object):
|
class CheckRemoteVersion(object):
|
||||||
URL = 'https://api.github.com/repos/lbryio/lbry-electron/releases/latest'
|
URL = 'https://api.github.com/repos/lbryio/lbry-app/releases/latest'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.version = None
|
self.version = None
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
d = threads.deferToThread(self._get_lbry_electron_client_version)
|
d = threads.deferToThread(self._get_lbry_electron_client_version)
|
||||||
d.addErrback(self._trap_and_log_error, 'lbry-electron')
|
d.addErrback(self._trap_and_log_error, 'lbry-app')
|
||||||
d.addErrback(log.fail(), 'Failure checking versions on github')
|
d.addErrback(log.fail(), 'Failure checking versions on github')
|
||||||
|
|
||||||
def _trap_and_log_error(self, err, module_checked):
|
def _trap_and_log_error(self, err, module_checked):
|
||||||
|
@ -159,8 +158,7 @@ class CheckRemoteVersion(object):
|
||||||
log.warning("Failed to check latest %s version from github", module_checked)
|
log.warning("Failed to check latest %s version from github", module_checked)
|
||||||
|
|
||||||
def _get_lbry_electron_client_version(self):
|
def _get_lbry_electron_client_version(self):
|
||||||
# We'll need to ensure the lbry-electron version is in sync
|
# We'll need to ensure the lbry-app version is in sync with the lbrynet-daemon version
|
||||||
# with the lbrynet-daemon version
|
|
||||||
self._set_data_from_github()
|
self._set_data_from_github()
|
||||||
log.info(
|
log.info(
|
||||||
"remote lbrynet %s > local lbrynet %s = %s",
|
"remote lbrynet %s > local lbrynet %s = %s",
|
||||||
|
@ -180,7 +178,8 @@ class CheckRemoteVersion(object):
|
||||||
release = response.json()
|
release = response.json()
|
||||||
return release
|
return release
|
||||||
|
|
||||||
def _get_version_from_release(self, release):
|
@staticmethod
|
||||||
|
def _get_version_from_release(release):
|
||||||
"""Return the latest released version from github."""
|
"""Return the latest released version from github."""
|
||||||
tag = release['tag_name']
|
tag = release['tag_name']
|
||||||
return get_version_from_tag(tag)
|
return get_version_from_tag(tag)
|
||||||
|
@ -1228,19 +1227,10 @@ class Daemon(AuthJSONRPCServer):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
platform_info = self._get_platform()
|
platform_info = self._get_platform()
|
||||||
msg = {
|
platform_info['remote_lbrynet'] = self._remote_version.version
|
||||||
'platform': platform_info['platform'],
|
platform_info['lbrynet_update_available'] = self._remote_version.is_update_available()
|
||||||
'os_release': platform_info['os_release'],
|
log.info("Get version info: " + json.dumps(platform_info))
|
||||||
'os_system': platform_info['os_system'],
|
return self._render_response(platform_info)
|
||||||
'lbrynet_version': LBRYNET_VERSION,
|
|
||||||
'lbryum_version': LBRYUM_VERSION,
|
|
||||||
'ui_version': platform_info['ui_version'],
|
|
||||||
'remote_lbrynet': self._remote_version.version,
|
|
||||||
'lbrynet_update_available': self._remote_version.is_update_available(),
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("Get version info: " + json.dumps(msg))
|
|
||||||
return self._render_response(msg)
|
|
||||||
|
|
||||||
def jsonrpc_report_bug(self, message=None):
|
def jsonrpc_report_bug(self, message=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -4,6 +4,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from lbrynet import conf
|
from lbrynet import conf
|
||||||
|
from lbrynet.core import utils
|
||||||
from lbrynet.lbrynet_daemon.auth.client import JSONRPCException, LBRYAPIClient
|
from lbrynet.lbrynet_daemon.auth.client import JSONRPCException, LBRYAPIClient
|
||||||
from lbrynet.lbrynet_daemon.Daemon import LOADING_WALLET_CODE
|
from lbrynet.lbrynet_daemon.Daemon import LOADING_WALLET_CODE
|
||||||
from jsonrpc.common import RPCError
|
from jsonrpc.common import RPCError
|
||||||
|
@ -75,7 +76,7 @@ def main():
|
||||||
# printing the undumped string is prettier
|
# printing the undumped string is prettier
|
||||||
print result
|
print result
|
||||||
else:
|
else:
|
||||||
print json.dumps(result, sort_keys=True, indent=2, separators=(',', ': '))
|
print utils.json_dumps_pretty(result)
|
||||||
except (RPCError, KeyError, JSONRPCException) as err:
|
except (RPCError, KeyError, JSONRPCException) as err:
|
||||||
# TODO: The api should return proper error codes
|
# TODO: The api should return proper error codes
|
||||||
# and messages so that they can be passed along to the user
|
# and messages so that they can be passed along to the user
|
||||||
|
|
|
@ -8,7 +8,7 @@ from jsonrpc.proxy import JSONRPCProxy
|
||||||
|
|
||||||
from lbrynet import analytics
|
from lbrynet import analytics
|
||||||
from lbrynet import conf
|
from lbrynet import conf
|
||||||
from lbrynet.core import utils
|
from lbrynet.core import utils, system_info
|
||||||
from lbrynet.lbrynet_daemon.auth.client import LBRYAPIClient
|
from lbrynet.lbrynet_daemon.auth.client import LBRYAPIClient
|
||||||
from lbrynet.lbrynet_daemon.DaemonServer import DaemonServer
|
from lbrynet.lbrynet_daemon.DaemonServer import DaemonServer
|
||||||
|
|
||||||
|
@ -34,29 +34,49 @@ def start():
|
||||||
conf.initialize_settings()
|
conf.initialize_settings()
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Launch lbrynet-daemon")
|
parser = argparse.ArgumentParser(description="Launch lbrynet-daemon")
|
||||||
parser.add_argument("--wallet",
|
parser.add_argument(
|
||||||
help="lbryum or ptc for testing, default lbryum",
|
"--wallet",
|
||||||
type=str,
|
help="lbryum or ptc for testing, default lbryum",
|
||||||
default=conf.settings['wallet'])
|
type=str,
|
||||||
parser.add_argument("--ui", help="path to custom UI folder", default=None)
|
default=conf.settings['wallet']
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--ui", help="path to custom UI folder", default=None
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--branch",
|
"--branch",
|
||||||
help='Branch of lbry-web-ui repo to use, defaults to {}'.format(conf.settings['ui_branch']),
|
help='Branch of lbry-web-ui repo to use, defaults to {}'.format(conf.settings['ui_branch']),
|
||||||
default=conf.settings['ui_branch'])
|
default=conf.settings['ui_branch']
|
||||||
parser.add_argument('--launch-ui', dest='launchui', action="store_true")
|
)
|
||||||
parser.add_argument("--http-auth", dest="useauth", action="store_true",
|
parser.add_argument(
|
||||||
default=conf.settings['use_auth_http'])
|
'--launch-ui', dest='launchui', action="store_true"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--http-auth", dest="useauth", action="store_true", default=conf.settings['use_auth_http']
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--quiet', dest='quiet', action="store_true",
|
'--quiet', dest='quiet', action="store_true",
|
||||||
help='Disable all console output.')
|
help='Disable all console output.'
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--verbose', nargs="*",
|
'--verbose', nargs="*",
|
||||||
help=('Enable debug output. Optionally specify loggers for which debug output '
|
help=('Enable debug output. Optionally specify loggers for which debug output '
|
||||||
'should selectively be applied.'))
|
'should selectively be applied.')
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--version', action="store_true",
|
||||||
|
help='Show daemon version and quit'
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
update_settings_from_args(args)
|
update_settings_from_args(args)
|
||||||
|
|
||||||
|
if args.version:
|
||||||
|
version = system_info.get_platform(get_ip=False)
|
||||||
|
version['installation_id'] = conf.settings.installation_id
|
||||||
|
print utils.json_dumps_pretty(version)
|
||||||
|
return
|
||||||
|
|
||||||
lbrynet_log = conf.settings.get_log_filename()
|
lbrynet_log = conf.settings.get_log_filename()
|
||||||
log_support.configure_logging(lbrynet_log, not args.quiet, args.verbose)
|
log_support.configure_logging(lbrynet_log, not args.quiet, args.verbose)
|
||||||
log.debug('Final Settings: %s', conf.settings.get_current_settings_dict())
|
log.debug('Final Settings: %s', conf.settings.get_current_settings_dict())
|
||||||
|
|
|
@ -21,7 +21,6 @@ requests==2.9.1
|
||||||
requests_futures==0.9.7
|
requests_futures==0.9.7
|
||||||
seccure==0.3.1.3
|
seccure==0.3.1.3
|
||||||
service_identity==16.0.0
|
service_identity==16.0.0
|
||||||
simplejson==3.8.2
|
|
||||||
six>=1.9.0
|
six>=1.9.0
|
||||||
slowaes==0.1a1
|
slowaes==0.1a1
|
||||||
txJSON-RPC==0.5
|
txJSON-RPC==0.5
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -26,7 +26,6 @@ requires = [
|
||||||
'requests',
|
'requests',
|
||||||
'requests_futures',
|
'requests_futures',
|
||||||
'seccure',
|
'seccure',
|
||||||
'simplejson',
|
|
||||||
'txJSON-RPC',
|
'txJSON-RPC',
|
||||||
'zope.interface',
|
'zope.interface',
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue