fix pylint errors

This commit is contained in:
Job Evers-Meltzer 2016-11-28 13:23:10 -06:00
parent c91034ee4c
commit 6f2e2e727e
4 changed files with 61 additions and 51 deletions

View file

@ -47,7 +47,7 @@ class ClaimOutpoint(dict):
self['nout'] = nout
def __repr__(self):
return "{}:{}".format(txid,nout)
return "{}:{}".format(self['txid'], self['nout'])
def __eq__(self, compare):
if isinstance(compare, dict):
@ -67,7 +67,8 @@ def _catch_connection_error(f):
try:
return f(*args)
except socket.error:
raise ValueError("Unable to connect to an lbrycrd server. Make sure an lbrycrd server " +
raise ValueError(
"Unable to connect to an lbrycrd server. Make sure an lbrycrd server " +
"is running and that this application can connect to it.")
return w
@ -90,8 +91,9 @@ class Wallet(object):
self.queued_payments = defaultdict(Decimal) # {address(string): amount(Decimal)}
self.expected_balances = defaultdict(Decimal) # {address(string): amount(Decimal)}
self.current_address_given_to_peer = {} # {Peer: address(string)}
self.expected_balance_at_time = deque() # (Peer, address(string), amount(Decimal), time(datetime), count(int),
# (Peer, address(string), amount(Decimal), time(datetime), count(int),
# incremental_amount(float))
self.expected_balance_at_time = deque()
self.max_expected_payment_time = datetime.timedelta(minutes=3)
self.stopped = True
@ -193,7 +195,8 @@ class Wallet(object):
d.addCallback(lambda _: set_next_manage_call())
def log_error(err):
log.error("Something went wrong during manage. Error message: %s", err.getErrorMessage())
log.error("Something went wrong during manage. Error message: %s",
err.getErrorMessage())
return err
d.addErrback(log_error)
@ -213,14 +216,15 @@ class Wallet(object):
return LBRYcrdAddressQueryHandlerFactory(self)
def reserve_points(self, identifier, amount):
"""
Ensure a certain amount of points are available to be sent as payment, before the service is rendered
"""Ensure a certain amount of points are available to be sent as
payment, before the service is rendered
@param identifier: The peer to which the payment will ultimately be sent
@param amount: The amount of points to reserve
@return: A ReservedPoints object which is given to send_points once the service has been rendered
@return: A ReservedPoints object which is given to send_points
once the service has been rendered
"""
rounded_amount = Decimal(str(round(amount, 8)))
#if peer in self.peer_addresses:
@ -287,11 +291,13 @@ class Wallet(object):
rounded_amount = Decimal(str(round(amount, 8)))
assert(peer in self.current_address_given_to_peer)
address = self.current_address_given_to_peer[peer]
log.info("expecting a payment at address %s in the amount of %s", str(address), str(rounded_amount))
log.info("expecting a payment at address %s in the amount of %s",
str(address), str(rounded_amount))
self.expected_balances[address] += rounded_amount
expected_balance = self.expected_balances[address]
expected_time = datetime.datetime.now() + self.max_expected_payment_time
self.expected_balance_at_time.append((peer, address, expected_balance, expected_time, 0, amount))
self.expected_balance_at_time.append(
(peer, address, expected_balance, expected_time, 0, amount))
peer.update_stats('expected_points', amount)
def update_peer_address(self, peer, address):

View file

@ -8,9 +8,9 @@ def migrate_db(db_dir, start, end):
from lbrynet.db_migrator.migrate1to2 import do_migration
do_migration(db_dir)
else:
raise Exception("DB migration of version {} to {} is not available".format(current,current+1))
raise Exception(
"DB migration of version {} to {} is not available".format(current, current+1))
current += 1
return None

View file

@ -38,10 +38,14 @@ def migrate_blockchainname_db(db_dir):
# fill n as V1_UNSET_NOUT, Wallet.py will be responsible for filling in correct n
for name, txid, sd_hash in name_metadata:
mem_cursor.execute("insert into name_metadata values (?, ?, ?, ?) ", (name, txid, UNSET_NOUT, sd_hash))
mem_cursor.execute(
"insert into name_metadata values (?, ?, ?, ?) ",
(name, txid, UNSET_NOUT, sd_hash))
for claim_id, name, txid in claim_metadata:
mem_cursor.execute("insert into claim_ids values (?, ?, ?, ?)", (claim_id, name, txid, UNSET_NOUT))
mem_cursor.execute(
"insert into claim_ids values (?, ?, ?, ?)",
(claim_id, name, txid, UNSET_NOUT))
temp_db.commit()
new_name_metadata = mem_cursor.execute("select * from name_metadata").fetchall()

View file

@ -47,7 +47,7 @@ from lbrynet.core.Wallet import LBRYcrdWallet, LBRYumWallet
from lbrynet.core.looping_call_manager import LoopingCallManager
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
from lbrynet.core.server.ServerProtocol import ServerProtocolFactory
from lbrynet.core.Error import InsufficientFundsError, InvalidNameError, UnknownNameError
from lbrynet.core.Error import InsufficientFundsError, InvalidNameError
log = logging.getLogger(__name__)