Skip to content
Snippets Groups Projects
Commit 9386c5b7 authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

black and isort

parent df9a9227
Branches
No related tags found
Loading
...@@ -33,12 +33,9 @@ from struct import calcsize, unpack ...@@ -33,12 +33,9 @@ from struct import calcsize, unpack
import attr import attr
from allmydata.interfaces import RIStorageServer from allmydata.interfaces import RIStorageServer
from allmydata.storage.common import storage_index_to_dir from allmydata.storage.common import storage_index_to_dir
from allmydata.storage.shares import get_share_file
from allmydata.storage.immutable import ShareFile from allmydata.storage.immutable import ShareFile
from allmydata.storage.mutable import MutableShareFile from allmydata.storage.mutable import MutableShareFile
from allmydata.storage.shares import get_share_file
from allmydata.util.base32 import b2a from allmydata.util.base32 import b2a
from attr.validators import instance_of, provides from attr.validators import instance_of, provides
from challenge_bypass_ristretto import SigningKey, TokenPreimage, VerificationSignature from challenge_bypass_ristretto import SigningKey, TokenPreimage, VerificationSignature
...@@ -642,6 +639,7 @@ def stat_slot(storage_server, slot, sharepath): ...@@ -642,6 +639,7 @@ def stat_slot(storage_server, slot, sharepath):
lease_expiration=get_lease_expiration(sharepath), lease_expiration=get_lease_expiration(sharepath),
) )
def get_lease_expiration(sharepath): def get_lease_expiration(sharepath):
# type: (str) -> Optional[int] # type: (str) -> Optional[int]
""" """
...@@ -651,14 +649,13 @@ def get_lease_expiration(sharepath): ...@@ -651,14 +649,13 @@ def get_lease_expiration(sharepath):
:param sharepath: The path to the share file to inspect. :param sharepath: The path to the share file to inspect.
""" """
leases = list( leases = list(
lease.get_expiration_time() lease.get_expiration_time() for lease in get_share_file(sharepath).get_leases()
for lease
in get_share_file(sharepath).get_leases()
) )
if leases: if leases:
return max(leases) return max(leases)
return None return None
def get_slot_share_size(sharepath): def get_slot_share_size(sharepath):
""" """
Get the size of a share belonging to a slot (a mutable share). Get the size of a share belonging to a slot (a mutable share).
......
...@@ -34,10 +34,10 @@ from hypothesis.strategies import ( ...@@ -34,10 +34,10 @@ from hypothesis.strategies import (
floats, floats,
integers, integers,
just, just,
tuples,
lists, lists,
sets,
randoms, randoms,
sets,
tuples,
) )
from testtools import TestCase from testtools import TestCase
from testtools.matchers import ( from testtools.matchers import (
...@@ -66,7 +66,13 @@ from ..lease_maintenance import ( ...@@ -66,7 +66,13 @@ from ..lease_maintenance import (
visit_storage_indexes_from_root, visit_storage_indexes_from_root,
) )
from .matchers import Provides, between, leases_current from .matchers import Provides, between, leases_current
from .strategies import clocks, posix_timestamps, node_hierarchies, storage_indexes, sharenums from .strategies import (
clocks,
node_hierarchies,
posix_timestamps,
sharenums,
storage_indexes,
)
def interval_means(): def interval_means():
...@@ -100,17 +106,12 @@ class DummyStorageServer(object): ...@@ -100,17 +106,12 @@ class DummyStorageServer(object):
""" """
clock = attr.ib() clock = attr.ib()
buckets = attr.ib() # type: Dict[bytes, Dict[int, ShareStat]] buckets = attr.ib() # type: Dict[bytes, Dict[int, ShareStat]]
lease_seed = attr.ib() lease_seed = attr.ib()
def stat_shares(self, storage_indexes): def stat_shares(self, storage_indexes):
# type: (List[bytes]) -> Deferred[List[Dict[int, ShareStat]]] # type: (List[bytes]) -> Deferred[List[Dict[int, ShareStat]]]
return succeed( return succeed(list(self.buckets.get(idx, {}) for idx in storage_indexes))
list(
self.buckets.get(idx, {})
for idx in storage_indexes
)
)
def get_lease_seed(self): def get_lease_seed(self):
return self.lease_seed return self.lease_seed
...@@ -440,6 +441,7 @@ def lists_of_buckets(): ...@@ -440,6 +441,7 @@ def lists_of_buckets():
share numbers to lease expiration times (as posix timestamps). Any given share numbers to lease expiration times (as posix timestamps). Any given
storage index will appear only once in the overall result. storage index will appear only once in the overall result.
""" """
def add_expiration_times(sharenums): def add_expiration_times(sharenums):
return builds( return builds(
lambda nums, expires: dict(zip(nums, expires)), lambda nums, expires: dict(zip(nums, expires)),
...@@ -634,7 +636,9 @@ class MaintainLeasesFromRootTests(TestCase): ...@@ -634,7 +636,9 @@ class MaintainLeasesFromRootTests(TestCase):
for node in root_node.flatten(): for node in root_node.flatten():
for server in storage_broker.get_connected_servers(): for server in storage_broker.get_connected_servers():
try: try:
shares = server.get_storage_server().buckets[node.get_storage_index()] shares = server.get_storage_server().buckets[
node.get_storage_index()
]
except KeyError: except KeyError:
continue continue
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment