Merge branch 'master' into metadata-version
# Conflicts: # lbrynet/core/utils.py # lbrynet/lbrynet_daemon/LBRYDaemon.py
This commit is contained in:
commit
9572336e96
6 changed files with 55 additions and 48 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -25,3 +25,6 @@ lbrynet.egg-info/PKG-INFO
|
||||||
*.decTest
|
*.decTest
|
||||||
|
|
||||||
.coverage
|
.coverage
|
||||||
|
|
||||||
|
# temporary files from the twisted.trial test runner
|
||||||
|
_trial_temp/
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
from lbrynet.core.cryptoutils import get_lbry_hash_obj
|
import distutils.version
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
from lbrynet.core.cryptoutils import get_lbry_hash_obj
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
blobhash_length = get_lbry_hash_obj().digest_size * 2 # digest_size is in bytes, and blob hashes are hex encoded
|
blobhash_length = get_lbry_hash_obj().digest_size * 2 # digest_size is in bytes, and blob hashes are hex encoded
|
||||||
|
|
||||||
|
@ -28,23 +31,9 @@ def is_valid_blobhash(blobhash):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def version_is_greater_than(version1, version2):
|
def version_is_greater_than(a, b):
|
||||||
"""
|
"""Returns True if version a is more recent than version b"""
|
||||||
handles differing numbers of subversions, ie 0.3.10 > 0.3.9.9
|
try:
|
||||||
"""
|
return distutils.version.StrictVersion(a) > distutils.version.StrictVersion(b)
|
||||||
|
except ValueError:
|
||||||
v1, v2 = version1.split("."), version2.split(".")
|
return distutils.version.LooseVersion(a) > distutils.version.LooseVersion(b)
|
||||||
r = True
|
|
||||||
if len(v2) > len(v1):
|
|
||||||
for j in range(len(v2) - len(v1)):
|
|
||||||
v1.append("0")
|
|
||||||
elif len(v2) < len(v1):
|
|
||||||
for j in range(len(v1) - len(v2)):
|
|
||||||
v2.append("0")
|
|
||||||
for c in range(len(v1)):
|
|
||||||
if int(v2[c]) > int(v1[c]):
|
|
||||||
r = False
|
|
||||||
break
|
|
||||||
elif c == len(v1) - 1 and int(v1[c]) == int(v2[c]):
|
|
||||||
r = False
|
|
||||||
return r
|
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
import string
|
import binascii
|
||||||
|
import distutils.version
|
||||||
import locale
|
import locale
|
||||||
|
import logging.handlers
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
|
import random
|
||||||
import re
|
import re
|
||||||
|
import socket
|
||||||
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import random
|
|
||||||
|
|
||||||
import pkg_resources
|
|
||||||
import simplejson as json
|
|
||||||
import binascii
|
|
||||||
import logging.handlers
|
|
||||||
import requests
|
|
||||||
import base58
|
import base58
|
||||||
import platform
|
import requests
|
||||||
import socket
|
import simplejson as json
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
from urllib2 import urlopen
|
||||||
|
from appdirs import user_data_dir
|
||||||
|
from datetime import datetime
|
||||||
|
from decimal import Decimal
|
||||||
from twisted.web import server
|
from twisted.web import server
|
||||||
from twisted.internet import defer, threads, error, reactor
|
from twisted.internet import defer, threads, error, reactor
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
|
@ -23,11 +27,6 @@ from txjsonrpc import jsonrpclib
|
||||||
from txjsonrpc.web import jsonrpc
|
from txjsonrpc.web import jsonrpc
|
||||||
from txjsonrpc.web.jsonrpc import Handler
|
from txjsonrpc.web.jsonrpc import Handler
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
from decimal import Decimal
|
|
||||||
from appdirs import user_data_dir
|
|
||||||
from urllib2 import urlopen
|
|
||||||
|
|
||||||
from lbrynet import __version__ as lbrynet_version
|
from lbrynet import __version__ as lbrynet_version
|
||||||
from lbryum.version import LBRYUM_VERSION as lbryum_version
|
from lbryum.version import LBRYUM_VERSION as lbryum_version
|
||||||
from lbrynet.core.PaymentRateManager import PaymentRateManager
|
from lbrynet.core.PaymentRateManager import PaymentRateManager
|
||||||
|
@ -42,7 +41,8 @@ from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifi
|
||||||
from lbrynet.lbrynet_daemon.LBRYUIManager import LBRYUIManager
|
from lbrynet.lbrynet_daemon.LBRYUIManager import LBRYUIManager
|
||||||
from lbrynet.lbrynet_daemon.LBRYDownloader import GetStream
|
from lbrynet.lbrynet_daemon.LBRYDownloader import GetStream
|
||||||
from lbrynet.lbrynet_daemon.LBRYPublisher import Publisher
|
from lbrynet.lbrynet_daemon.LBRYPublisher import Publisher
|
||||||
from lbrynet.core.utils import generate_id, version_is_greater_than
|
from lbrynet.core import utils
|
||||||
|
from lbrynet.core.utils import generate_id
|
||||||
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
|
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
|
||||||
from lbrynet.conf import MIN_BLOB_DATA_PAYMENT_RATE, DEFAULT_MAX_SEARCH_RESULTS, KNOWN_DHT_NODES, DEFAULT_MAX_KEY_FEE, \
|
from lbrynet.conf import MIN_BLOB_DATA_PAYMENT_RATE, DEFAULT_MAX_SEARCH_RESULTS, KNOWN_DHT_NODES, DEFAULT_MAX_KEY_FEE, \
|
||||||
DEFAULT_WALLET, DEFAULT_SEARCH_TIMEOUT, DEFAULT_CACHE_TIME, DEFAULT_UI_BRANCH, LOG_POST_URL, LOG_FILE_NAME, SOURCE_TYPES
|
DEFAULT_WALLET, DEFAULT_SEARCH_TIMEOUT, DEFAULT_CACHE_TIME, DEFAULT_UI_BRANCH, LOG_POST_URL, LOG_FILE_NAME, SOURCE_TYPES
|
||||||
|
@ -1497,8 +1497,8 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
'ui_version': self.ui_version,
|
'ui_version': self.ui_version,
|
||||||
'remote_lbrynet': self.pip_lbrynet_version,
|
'remote_lbrynet': self.pip_lbrynet_version,
|
||||||
'remote_lbryum': self.pip_lbryum_version,
|
'remote_lbryum': self.pip_lbryum_version,
|
||||||
'lbrynet_update_available': version_is_greater_than(self.pip_lbrynet_version, lbrynet_version),
|
'lbrynet_update_available': utils.version_is_greater_than(self.pip_lbrynet_version, lbrynet_version),
|
||||||
'lbryum_update_available': version_is_greater_than(self.pip_lbryum_version, lbryum_version),
|
'lbryum_update_available': utils.version_is_greater_than(self.pip_lbryum_version, lbryum_version),
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Get version info: " + json.dumps(msg))
|
log.info("Get version info: " + json.dumps(msg))
|
||||||
|
@ -2324,8 +2324,3 @@ def get_version_from_tag(tag):
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
else:
|
else:
|
||||||
raise Exception('Failed to parse version from tag {}'.format(tag))
|
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
|
|
||||||
|
|
|
@ -95,8 +95,8 @@ class LBRYUIManager(object):
|
||||||
return d
|
return d
|
||||||
else:
|
else:
|
||||||
log.info("Checking for updates for UI branch: " + branch)
|
log.info("Checking for updates for UI branch: " + branch)
|
||||||
self._git_url = "https://api.github.com/repos/lbryio/lbry-web-ui/git/refs/heads/%s" % branch
|
self._git_url = "https://s3.amazonaws.com/lbry-ui/{}/data.json".format(branch)
|
||||||
self._dist_url = "https://raw.githubusercontent.com/lbryio/lbry-web-ui/%s/dist.zip" % branch
|
self._dist_url = "https://s3.amazonaws.com/lbry-ui/{}/dist.zip".format(branch)
|
||||||
|
|
||||||
d = self._up_to_date()
|
d = self._up_to_date()
|
||||||
d.addCallback(lambda r: self._download_ui() if not r else self._load_ui())
|
d.addCallback(lambda r: self._download_ui() if not r else self._load_ui())
|
||||||
|
@ -106,7 +106,7 @@ class LBRYUIManager(object):
|
||||||
def _get_git_info():
|
def _get_git_info():
|
||||||
response = urlopen(self._git_url)
|
response = urlopen(self._git_url)
|
||||||
data = json.loads(response.read())
|
data = json.loads(response.read())
|
||||||
return defer.succeed(data['object']['sha'])
|
return defer.succeed(data['sha'])
|
||||||
|
|
||||||
def _set_git(version):
|
def _set_git(version):
|
||||||
self.git_version = version.replace('\n', '')
|
self.git_version = version.replace('\n', '')
|
||||||
|
|
|
@ -42,5 +42,6 @@ pip install mock pylint
|
||||||
trial tests
|
trial tests
|
||||||
# TODO: submit coverage report to coveralls
|
# TODO: submit coverage report to coveralls
|
||||||
|
|
||||||
|
# Ignoring distutils because: https://github.com/PyCQA/pylint/issues/73
|
||||||
# TODO: as code quality improves, make pylint be more strict
|
# TODO: as code quality improves, make pylint be more strict
|
||||||
pylint -E --disable=inherit-non-class --disable=no-member lbrynet
|
pylint -E --disable=inherit-non-class --disable=no-member --ignored-modules=distutils lbrynet
|
||||||
|
|
19
tests/lbrynet/core/test_utils.py
Normal file
19
tests/lbrynet/core/test_utils.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
from lbrynet.core import utils
|
||||||
|
|
||||||
|
from twisted.trial import unittest
|
||||||
|
|
||||||
|
|
||||||
|
class CompareVersionTest(unittest.TestCase):
|
||||||
|
def test_compare_versions_isnot_lexographic(self):
|
||||||
|
self.assertTrue(utils.version_is_greater_than('0.3.10', '0.3.6'))
|
||||||
|
|
||||||
|
def test_same_versions_return_false(self):
|
||||||
|
self.assertFalse(utils.version_is_greater_than('1.3.9', '1.3.9'))
|
||||||
|
|
||||||
|
def test_same_release_is_greater_then_beta(self):
|
||||||
|
self.assertTrue(utils.version_is_greater_than('1.3.9', '1.3.9b1'))
|
||||||
|
|
||||||
|
def test_version_can_have_four_parts(self):
|
||||||
|
self.assertTrue(utils.version_is_greater_than('1.3.9.1', '1.3.9'))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue