change attribute "uri" to "name"

This commit is contained in:
Jack Robison 2017-03-06 16:52:16 -05:00
parent 59a5a3164f
commit 9744287370
6 changed files with 27 additions and 27 deletions

View file

@ -464,7 +464,7 @@ class DownloadRequest(RequestHelper):
blob_details.cancel_func, blob_details.cancel_func,
blob blob
) )
log.info("Requesting blob %s from %s", blob.blob_hash, self.peer) log.debug("Requesting blob %s from %s", blob.blob_hash, self.peer)
return request return request
def _handle_download_request(self, client_blob_request): def _handle_download_request(self, client_blob_request):

View file

@ -146,7 +146,7 @@ class FullStreamProgressManager(StreamProgressManager):
current_blob_num = self.last_blob_outputted + 1 current_blob_num = self.last_blob_outputted + 1
if current_blob_num in blobs and blobs[current_blob_num].is_validated(): if current_blob_num in blobs and blobs[current_blob_num].is_validated():
log.info("Outputting blob %s", str(self.last_blob_outputted + 1)) log.debug("Outputting blob %s", str(self.last_blob_outputted + 1))
self.provided_blob_nums.append(self.last_blob_outputted + 1) self.provided_blob_nums.append(self.last_blob_outputted + 1)
d = self.download_manager.handle_blob(self.last_blob_outputted + 1) d = self.download_manager.handle_blob(self.last_blob_outputted + 1)
d.addCallback(lambda _: finished_outputting_blob()) d.addCallback(lambda _: finished_outputting_blob())

View file

@ -19,7 +19,7 @@ from lbrynet.lbryfile.StreamDescriptor import save_sd_info
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def log_status(uri, sd_hash, status): def log_status(name, sd_hash, status):
if status == ManagedEncryptedFileDownloader.STATUS_RUNNING: if status == ManagedEncryptedFileDownloader.STATUS_RUNNING:
status_string = "running" status_string = "running"
elif status == ManagedEncryptedFileDownloader.STATUS_STOPPED: elif status == ManagedEncryptedFileDownloader.STATUS_STOPPED:
@ -28,7 +28,7 @@ def log_status(uri, sd_hash, status):
status_string = "finished" status_string = "finished"
else: else:
status_string = "unknown" status_string = "unknown"
log.info("lbry://%s (%s) is %s", uri, short_hash(sd_hash), status_string) log.info("lbry://%s (%s) is %s", name, short_hash(sd_hash), status_string)
class ManagedEncryptedFileDownloader(EncryptedFileSaver): class ManagedEncryptedFileDownloader(EncryptedFileSaver):
@ -49,7 +49,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
self.sd_hash = None self.sd_hash = None
self.txid = None self.txid = None
self.nout = None self.nout = None
self.uri = None self.name = None
self.claim_id = None self.claim_id = None
self.rowid = rowid self.rowid = rowid
self.lbry_file_manager = lbry_file_manager self.lbry_file_manager = lbry_file_manager
@ -64,7 +64,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
yield self.load_file_attributes() yield self.load_file_attributes()
status = yield self.lbry_file_manager.get_lbry_file_status(self) status = yield self.lbry_file_manager.get_lbry_file_status(self)
log_status(self.uri, self.sd_hash, status) log_status(self.name, self.sd_hash, status)
if status == ManagedEncryptedFileDownloader.STATUS_RUNNING: if status == ManagedEncryptedFileDownloader.STATUS_RUNNING:
# start returns self.finished_deferred # start returns self.finished_deferred
@ -115,12 +115,12 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
stream_metadata = yield self.wallet.get_claim_metadata_for_sd_hash(self.sd_hash) stream_metadata = yield self.wallet.get_claim_metadata_for_sd_hash(self.sd_hash)
if stream_metadata: if stream_metadata:
name, txid, nout = stream_metadata name, txid, nout = stream_metadata
self.uri = name self.name = name
self.txid = txid self.txid = txid
self.nout = nout self.nout = nout
else: else:
raise NoSuchSDHash(self.sd_hash) raise NoSuchSDHash(self.sd_hash)
self.claim_id = yield self.wallet.get_claimid(self.uri, self.txid, self.nout) self.claim_id = yield self.wallet.get_claimid(self.name, self.txid, self.nout)
defer.returnValue(None) defer.returnValue(None)
@defer.inlineCallbacks @defer.inlineCallbacks
@ -128,7 +128,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
yield EncryptedFileSaver._start(self) yield EncryptedFileSaver._start(self)
yield self.load_file_attributes() yield self.load_file_attributes()
status = yield self._save_status() status = yield self._save_status()
log_status(self.uri, self.sd_hash, status) log_status(self.name, self.sd_hash, status)
defer.returnValue(status) defer.returnValue(status)
def _get_finished_deferred_callback_value(self): def _get_finished_deferred_callback_value(self):

View file

@ -39,8 +39,8 @@ class EncryptedFileReflectorClient(Protocol):
lambda err: log.warning("An error occurred immediately: %s", err.getTraceback())) lambda err: log.warning("An error occurred immediately: %s", err.getTraceback()))
@property @property
def lbry_uri(self): def name(self):
return "lbry://%s" % self.factory.lbry_uri return "lbry://%s" % self.factory.name
@property @property
def blob_manager(self): def blob_manager(self):
@ -74,20 +74,20 @@ class EncryptedFileReflectorClient(Protocol):
if reason.check(error.ConnectionDone): if reason.check(error.ConnectionDone):
if not self.needed_blobs: if not self.needed_blobs:
log.info("Reflector has all blobs for %s (%s)", log.info("Reflector has all blobs for %s (%s)",
self.lbry_uri, self.stream_descriptor) self.name, self.stream_descriptor)
elif not self.reflected_blobs: elif not self.reflected_blobs:
log.info("No more completed blobs for %s (%s) to reflect, %i are still needed", log.info("No more completed blobs for %s (%s) to reflect, %i are still needed",
self.lbry_uri, self.stream_descriptor, len(self.needed_blobs)) self.name, self.stream_descriptor, len(self.needed_blobs))
else: else:
log.info('Finished sending reflector %i blobs for %s (%s)', log.info('Finished sending reflector %i blobs for %s (%s)',
len(self.reflected_blobs), self.lbry_uri, self.stream_descriptor) len(self.reflected_blobs), self.name, self.stream_descriptor)
self.factory.finished_deferred.callback(self.reflected_blobs) self.factory.finished_deferred.callback(self.reflected_blobs)
elif reason.check(error.ConnectionLost): elif reason.check(error.ConnectionLost):
log.warning("Stopped reflecting %s (%s) after sending %i blobs", self.lbry_uri, log.warning("Stopped reflecting %s (%s) after sending %i blobs", self.name,
self.stream_descriptor, len(self.reflected_blobs)) self.stream_descriptor, len(self.reflected_blobs))
self.factory.finished_deferred.callback(self.reflected_blobs) self.factory.finished_deferred.callback(self.reflected_blobs)
else: else:
log.info('Reflector finished for %s (%s): %s', self.lbry_uri, self.stream_descriptor, log.info('Reflector finished for %s (%s): %s', self.name, self.stream_descriptor,
reason) reason)
self.factory.finished_deferred.callback(reason) self.factory.finished_deferred.callback(reason)
@ -131,7 +131,7 @@ class EncryptedFileReflectorClient(Protocol):
log.info("Reflector needs %s%i blobs for %s", log.info("Reflector needs %s%i blobs for %s",
needs_desc, needs_desc,
len(filtered), len(filtered),
self.lbry_uri) self.name)
return filtered return filtered
d = self.factory.stream_info_manager.get_blobs_for_stream(self.factory.stream_hash) d = self.factory.stream_info_manager.get_blobs_for_stream(self.factory.stream_hash)
@ -223,7 +223,7 @@ class EncryptedFileReflectorClient(Protocol):
log.info("Sent reflector descriptor %s", self.next_blob_to_send) log.info("Sent reflector descriptor %s", self.next_blob_to_send)
else: else:
log.warning("Reflector failed to receive descriptor %s for %s", log.warning("Reflector failed to receive descriptor %s for %s",
self.next_blob_to_send, self.lbry_uri) self.next_blob_to_send, self.name)
self.blob_hashes_to_send.append(self.next_blob_to_send.blob_hash) self.blob_hashes_to_send.append(self.next_blob_to_send.blob_hash)
return self.set_not_uploading() return self.set_not_uploading()
@ -236,7 +236,7 @@ class EncryptedFileReflectorClient(Protocol):
return defer.succeed(True) return defer.succeed(True)
else: else:
log.warning("Reflector already has %s for %s", self.next_blob_to_send, log.warning("Reflector already has %s for %s", self.next_blob_to_send,
self.lbry_uri) self.name)
return self.set_not_uploading() return self.set_not_uploading()
else: # Expecting Server Blob Response else: # Expecting Server Blob Response
if 'received_blob' not in response_dict: if 'received_blob' not in response_dict:
@ -245,10 +245,10 @@ class EncryptedFileReflectorClient(Protocol):
if response_dict['received_blob']: if response_dict['received_blob']:
self.reflected_blobs.append(self.next_blob_to_send.blob_hash) self.reflected_blobs.append(self.next_blob_to_send.blob_hash)
log.debug("Sent reflector blob %s for %s", self.next_blob_to_send, log.debug("Sent reflector blob %s for %s", self.next_blob_to_send,
self.lbry_uri) self.name)
else: else:
log.warning("Reflector failed to receive blob %s for %s", log.warning("Reflector failed to receive blob %s for %s",
self.next_blob_to_send, self.lbry_uri) self.next_blob_to_send, self.name)
self.blob_hashes_to_send.append(self.next_blob_to_send.blob_hash) self.blob_hashes_to_send.append(self.next_blob_to_send.blob_hash)
return self.set_not_uploading() return self.set_not_uploading()
@ -284,12 +284,12 @@ class EncryptedFileReflectorClient(Protocol):
err.trap(ValueError) err.trap(ValueError)
if blob_hash not in self.failed_blob_hashes: if blob_hash not in self.failed_blob_hashes:
log.warning("Failed to reflect blob %s for %s, reason: %s", log.warning("Failed to reflect blob %s for %s, reason: %s",
str(blob_hash)[:16], self.lbry_uri, err.getTraceback()) str(blob_hash)[:16], self.name, err.getTraceback())
self.blob_hashes_to_send.append(blob_hash) self.blob_hashes_to_send.append(blob_hash)
self.failed_blob_hashes.append(blob_hash) self.failed_blob_hashes.append(blob_hash)
else: else:
log.warning("Failed second try reflecting blob %s for %s, giving up, reason: %s", log.warning("Failed second try reflecting blob %s for %s, giving up, reason: %s",
str(blob_hash)[:16], self.lbry_uri, err.getTraceback()) str(blob_hash)[:16], self.name, err.getTraceback())
def send_next_request(self): def send_next_request(self):
if self.file_sender is not None: if self.file_sender is not None:
@ -335,8 +335,8 @@ class EncryptedFileReflectorClientFactory(ClientFactory):
return self._lbry_file.stream_hash return self._lbry_file.stream_hash
@property @property
def lbry_uri(self): def name(self):
return self._lbry_file.uri return self._lbry_file.name
@property @property
def protocol_version(self): def protocol_version(self):

View file

@ -61,7 +61,7 @@ DummyBlobAvailabilityTracker = mocks.BlobAvailabilityTracker
log_format = "%(funcName)s(): %(message)s" log_format = "%(funcName)s(): %(message)s"
logging.basicConfig(level=logging.WARNING, format=log_format) logging.basicConfig(level=logging.CRITICAL, format=log_format)
def require_system(system): def require_system(system):

View file

@ -16,7 +16,7 @@ class FakeLBRYFile(object):
self.blob_manager = blob_manager self.blob_manager = blob_manager
self.stream_info_manager = stream_info_manager self.stream_info_manager = stream_info_manager
self.stream_hash = stream_hash self.stream_hash = stream_hash
self.uri = "fake_uri" self.name = "fake_uri"
class Node(object): class Node(object):