forked from LBRYCommunity/lbry-sdk
merge master
This commit is contained in:
commit
5e815a5832
10 changed files with 81 additions and 9 deletions
|
@ -45,6 +45,7 @@ deploy:
|
|||
- provider: releases
|
||||
file: "${TRAVIS_BUILD_DIR}/`python setup.py --name`_`python setup.py -V`_amd64.deb"
|
||||
skip_cleanup: true
|
||||
prerelease: true
|
||||
on:
|
||||
tags: true
|
||||
condition: "$TRAVIS_OS_NAME = linux"
|
||||
|
@ -54,6 +55,7 @@ deploy:
|
|||
- provider: releases
|
||||
file: "${TRAVIS_BUILD_DIR}/packaging/osx/lbry-osx-app/`python setup.py --name`.`python setup.py -V`.dmg"
|
||||
skip_cleanup: true
|
||||
prerelease: true
|
||||
on:
|
||||
tags: true
|
||||
condition: "$TRAVIS_OS_NAME = osx"
|
||||
|
|
|
@ -61,7 +61,6 @@ class LBRYWallet(object):
|
|||
_FIRST_RUN_NO = 2
|
||||
|
||||
def __init__(self, db_dir):
|
||||
|
||||
self.db_dir = db_dir
|
||||
self.db = None
|
||||
self.next_manage_call = None
|
||||
|
@ -663,7 +662,7 @@ class LBRYcrdWallet(LBRYWallet):
|
|||
settings = {"username": "rpcuser",
|
||||
"password": "rpcpassword",
|
||||
"rpc_port": 9245}
|
||||
if os.path.exists(self.wallet_conf):
|
||||
if self.wallet_conf and os.path.exists(self.wallet_conf):
|
||||
conf = open(self.wallet_conf)
|
||||
for l in conf:
|
||||
if l.startswith("rpcuser="):
|
||||
|
|
|
@ -198,7 +198,7 @@ class StreamDescriptorIdentifier(object):
|
|||
return self._stream_downloader_factories[stream_type]
|
||||
|
||||
def _get_validator(self, stream_type):
|
||||
if not stream_type in self._stream_downloader_factories:
|
||||
if not stream_type in self._sd_info_validators:
|
||||
raise UnknownStreamTypeError(stream_type)
|
||||
return self._sd_info_validators[stream_type]
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class DownloadManager(object):
|
|||
|
||||
def add_blobs_to_download(self, blob_infos):
|
||||
|
||||
log.debug("Adding %s to blobs", str(blob_infos))
|
||||
log.debug("Adding %s blobs to blobs", len(blob_infos))
|
||||
|
||||
def add_blob_to_list(blob, blob_num):
|
||||
self.blobs[blob_num] = blob
|
||||
|
|
|
@ -240,9 +240,9 @@ class Node(object):
|
|||
known_nodes = {}
|
||||
|
||||
def log_error(err, n):
|
||||
log.debug("error storing blob_hash %s at %s", binascii.hexlify(blob_hash), str(n))
|
||||
log.debug(binascii.hexlify(err.getErrorMessage()))
|
||||
log.debug(err.getTraceback())
|
||||
log.error("error storing blob_hash %s at %s", binascii.hexlify(blob_hash), str(n))
|
||||
log.error(err.getErrorMessage())
|
||||
log.error(err.getTraceback())
|
||||
|
||||
def log_success(res):
|
||||
log.debug("Response to store request: %s", str(res))
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
# The docstrings in this module contain epytext markup; API documentation
|
||||
# may be created by processing this file with epydoc: http://epydoc.sf.net
|
||||
|
||||
import binascii
|
||||
import time
|
||||
|
||||
from twisted.internet import protocol, defer
|
||||
|
@ -23,6 +24,13 @@ reactor = twisted.internet.reactor
|
|||
|
||||
class TimeoutError(Exception):
|
||||
""" Raised when a RPC times out """
|
||||
def __init__(self, remote_contact_id):
|
||||
# remote_contact_id is a binary blob so we need to convert it
|
||||
# into something more readable
|
||||
msg = 'Timeout connecting to {}'.format(binascii.hexlify(remote_contact_id))
|
||||
Exception.__init__(self, msg)
|
||||
self.remote_contact_id = remote_contact_id
|
||||
|
||||
|
||||
class KademliaProtocol(protocol.DatagramProtocol):
|
||||
""" Implements all low-level network-related functions of a Kademlia node """
|
||||
|
|
|
@ -2,6 +2,7 @@ import string
|
|||
import locale
|
||||
import mimetypes
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import random
|
||||
|
@ -2308,7 +2309,6 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
Returns:
|
||||
True, opens file browser
|
||||
"""
|
||||
|
||||
path = p['path']
|
||||
if sys.platform == "darwin":
|
||||
d = threads.deferToThread(subprocess.Popen, ['open', '-R', path])
|
||||
|
@ -2319,3 +2319,27 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
|
||||
d.addCallback(lambda _: self._render_response(True, OK_CODE))
|
||||
return d
|
||||
|
||||
|
||||
def get_lbrynet_version_from_github():
|
||||
"""Return the latest released version from github."""
|
||||
response = requests.get('https://api.github.com/repos/lbryio/lbry/releases/latest')
|
||||
release = response.json()
|
||||
tag = release['tag_name']
|
||||
# githubs documentation claims this should never happen, but we'll check just in case
|
||||
if release['prerelease']:
|
||||
raise Exception('Release {} is a pre-release'.format(tag))
|
||||
return get_version_from_tag(tag)
|
||||
|
||||
|
||||
def get_version_from_tag(tag):
|
||||
match = re.match('v([\d.]+)', tag)
|
||||
if match:
|
||||
return match.group(1)
|
||||
else:
|
||||
raise Exception('Failed to parse version from tag {}'.format(tag))
|
||||
|
||||
|
||||
def compare_versions(a, b):
|
||||
"""Returns True if version a is more recent than version b"""
|
||||
return a > b
|
||||
|
|
|
@ -74,6 +74,7 @@ class GetStream(object):
|
|||
def check_status(self):
|
||||
self.timeout_counter += 1
|
||||
|
||||
# TODO: Why is this the stopping condition for the finished callback?
|
||||
if self.download_path:
|
||||
self.checker.stop()
|
||||
self.finished.callback((self.stream_hash, self.download_path))
|
||||
|
|
0
tests/lbrynet/lbrynet_daemon/__init__.py
Normal file
0
tests/lbrynet/lbrynet_daemon/__init__.py
Normal file
38
tests/lbrynet/lbrynet_daemon/test_LBRYDaemon.py
Normal file
38
tests/lbrynet/lbrynet_daemon/test_LBRYDaemon.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
import mock
|
||||
import requests
|
||||
from twisted.trial import unittest
|
||||
|
||||
from lbrynet.lbrynet_daemon import LBRYDaemon
|
||||
|
||||
|
||||
class MiscTests(unittest.TestCase):
|
||||
def test_get_lbrynet_version_from_github(self):
|
||||
response = mock.create_autospec(requests.Response)
|
||||
# don't need to mock out the entire response from the api
|
||||
# but at least need 'tag_name'
|
||||
response.json.return_value = {
|
||||
"url": "https://api.github.com/repos/lbryio/lbry/releases/3685199",
|
||||
"assets_url": "https://api.github.com/repos/lbryio/lbry/releases/3685199/assets",
|
||||
"html_url": "https://github.com/lbryio/lbry/releases/tag/v0.3.8",
|
||||
"id": 3685199,
|
||||
"tag_name": "v0.3.8",
|
||||
"prerelease": False
|
||||
}
|
||||
with mock.patch('lbrynet.lbrynet_daemon.LBRYDaemon.requests') as req:
|
||||
req.get.return_value = response
|
||||
self.assertEqual('0.3.8', LBRYDaemon.get_lbrynet_version_from_github())
|
||||
|
||||
def test_error_is_thrown_if_prerelease(self):
|
||||
response = mock.create_autospec(requests.Response)
|
||||
response.json.return_value = {
|
||||
"tag_name": "v0.3.8",
|
||||
"prerelease": True
|
||||
}
|
||||
with mock.patch('lbrynet.lbrynet_daemon.LBRYDaemon.requests') as req:
|
||||
req.get.return_value = response
|
||||
with self.assertRaises(Exception):
|
||||
LBRYDaemon.get_lbrynet_version_from_github()
|
||||
|
||||
def test_error_is_thrown_when_version_cant_be_parsed(self):
|
||||
with self.assertRaises(Exception):
|
||||
LBRYDaemon.get_version_from_tag('garbage')
|
Loading…
Reference in a new issue