fixes from review

This commit is contained in:
Victor Shyba 2018-08-10 01:55:28 -03:00 committed by Jack Robison
parent 451823f33e
commit 04836ea0d9
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
7 changed files with 13 additions and 13 deletions

View file

@ -1,4 +1,4 @@
import binascii
from binascii import unhexlify
import string
from collections import defaultdict
import json
@ -264,7 +264,7 @@ def save_sd_info(blob_manager, sd_hash, sd_info):
(sd_hash, calculated_sd_hash))
stream_hash = yield blob_manager.storage.get_stream_hash_for_sd_hash(sd_hash)
if not stream_hash:
log.debug("Saving info for %s", binascii.unhexlify(sd_info['stream_name']))
log.debug("Saving info for %s", unhexlify(sd_info['stream_name']))
stream_name = sd_info['stream_name']
key = sd_info['key']
stream_hash = sd_info['stream_hash']
@ -415,14 +415,14 @@ class EncryptedFileStreamDescriptorValidator:
def info_to_show(self):
info = []
info.append(("stream_name", binascii.unhexlify(self.raw_info.get("stream_name"))))
info.append(("stream_name", unhexlify(self.raw_info.get("stream_name"))))
size_so_far = 0
for blob_info in self.raw_info.get("blobs", []):
size_so_far += int(blob_info['length'])
info.append(("stream_size", str(self.get_length_of_stream())))
suggested_file_name = self.raw_info.get("suggested_file_name", None)
if suggested_file_name is not None:
suggested_file_name = binascii.unhexlify(suggested_file_name)
suggested_file_name = unhexlify(suggested_file_name)
info.append(("suggested_file_name", suggested_file_name))
return info

View file

@ -1,4 +1,4 @@
import binascii
from binascii import unhexlify
import logging
from lbrynet.core.client.BlobRequester import BlobRequester
from lbrynet.core.client.ConnectionManager import ConnectionManager
@ -60,8 +60,8 @@ class CryptStreamDownloader:
self.blob_manager = blob_manager
self.payment_rate_manager = payment_rate_manager
self.wallet = wallet
self.key = binascii.unhexlify(key)
self.stream_name = binascii.unhexlify(stream_name).decode()
self.key = unhexlify(key)
self.stream_name = unhexlify(stream_name).decode()
self.completed = False
self.stopped = True
self.stopping = False

View file

@ -92,7 +92,7 @@ class LbryUploader(object):
query_handler_factories,
self.peer_manager)
self.server_port = reactor.listenTCP(5553, server_factory, interface="localhost")
test_file = GenFile(self.file_size, bytes([i for i in range(0, 64, 6)]))
test_file = GenFile(self.file_size, bytes(i for i in range(0, 64, 6)))
lbry_file = yield create_lbry_file(self.blob_manager, self.storage, self.prm, self.lbry_file_manager,
"test_file", test_file)
defer.returnValue(lbry_file.sd_hash)

View file

@ -83,7 +83,7 @@ class TestReflector(unittest.TestCase):
return d
def create_stream():
test_file = mocks.GenFile(5209343, bytes([(i + 3) for i in range(0, 64, 6)]))
test_file = mocks.GenFile(5209343, bytes((i + 3) for i in range(0, 64, 6)))
d = EncryptedFileCreator.create_lbry_file(
self.client_blob_manager, self.client_storage, prm, self.client_lbry_file_manager,
"test_file",

View file

@ -81,7 +81,7 @@ class TestStreamify(TestCase):
yield b"%016d" % iv
def create_stream():
test_file = GenFile(5209343, bytes([(i + 3) for i in range(0, 64, 6)]))
test_file = GenFile(5209343, bytes((i + 3) for i in range(0, 64, 6)))
d = create_lbry_file(
self.blob_manager, self.storage, self.prm, self.lbry_file_manager, "test_file", test_file,
key=b'0123456701234567', iv_generator=iv_generator()
@ -95,7 +95,7 @@ class TestStreamify(TestCase):
@defer.inlineCallbacks
def test_create_and_combine_stream(self):
test_file = GenFile(53209343, bytes([(i + 5) for i in range(0, 64, 6)]))
test_file = GenFile(53209343, bytes((i + 5) for i in range(0, 64, 6)))
lbry_file = yield create_lbry_file(self.blob_manager, self.storage, self.prm, self.lbry_file_manager,
"test_file", test_file)
sd_hash = yield self.storage.get_sd_blob_hash_for_stream(lbry_file.stream_hash)

View file

@ -268,7 +268,7 @@ class GenFile(io.RawIOBase):
def __init__(self, size, pattern):
io.RawIOBase.__init__(self)
self.size = size
self.pattern = pattern.encode() if not isinstance(pattern, bytes) else pattern
self.pattern = pattern
self.read_so_far = 0
self.buff = b''
self.last_offset = 0

View file

@ -64,7 +64,7 @@ class CreateEncryptedFileTest(unittest.TestCase):
@defer.inlineCallbacks
def create_file(self, filename):
handle = mocks.GenFile(3*MB, '1')
handle = mocks.GenFile(3*MB, b'1')
key = b'2' * (AES.block_size // 8)
out = yield EncryptedFileCreator.create_lbry_file(
self.blob_manager, self.storage, self.prm, self.lbry_file_manager, filename, handle, key, iv_generator()