From 2031b723b8bf087ec31e980a5ae2ff78ce397b0d Mon Sep 17 00:00:00 2001 From: meejah Date: Tue, 22 May 2018 16:19:43 -0600 Subject: [PATCH] various fixes (flake8, errors) --- src/allmydata/client.py | 1 - src/allmydata/scripts/tahoe_grid_manager.py | 10 +--------- src/allmydata/storage_client.py | 2 ++ src/allmydata/test/no_network.py | 2 +- src/allmydata/test/test_checker.py | 2 +- src/allmydata/test/test_storage_client.py | 2 +- src/allmydata/test/test_util.py | 2 +- src/allmydata/test/web/test_root.py | 2 +- 8 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/allmydata/client.py b/src/allmydata/client.py index b9225e169..335d5b31d 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -15,7 +15,6 @@ from twisted.application.internet import TimerService from twisted.python.filepath import FilePath from twisted.python.failure import Failure from pycryptopp.publickey import rsa -from pycryptopp.publickey import ed25519 import allmydata from allmydata.storage.server import StorageServer diff --git a/src/allmydata/scripts/tahoe_grid_manager.py b/src/allmydata/scripts/tahoe_grid_manager.py index d75b293cd..7cbfcd22d 100644 --- a/src/allmydata/scripts/tahoe_grid_manager.py +++ b/src/allmydata/scripts/tahoe_grid_manager.py @@ -9,17 +9,11 @@ from pycryptopp.publickey import ed25519 # perhaps NaCl instead? other code use from allmydata.scripts.common import BasedirOptions from allmydata.util.abbreviate import abbreviate_time -from twisted.scripts import twistd from twisted.python import usage -from twisted.python.reflect import namedAny from twisted.python.filepath import FilePath -from allmydata.scripts.default_nodedir import _default_nodedir from allmydata.util import fileutil from allmydata.util import base32 from allmydata.util import keyutil -from allmydata.node import read_config -from allmydata.util.encodingutil import listdir_unicode, quote_local_unicode_path -from twisted.application.service import Service from twisted.internet.defer import inlineCallbacks, returnValue @@ -178,7 +172,7 @@ class _GridManager(object): if 'private_key' not in config: raise ValueError( "Grid Manager config from '{}' requires a 'private_key'".format( - config_config + config_location, ) ) @@ -406,7 +400,6 @@ def _list(gridoptions, options): else: print(" {}: expired ({})".format(cert_count, abbreviate_time(delta))) cert_count += 1 - certs = ' ({} certificates)'.format(cert_count) def _sign(gridoptions, options): @@ -428,7 +421,6 @@ def _sign(gridoptions, options): print(certificate_data) if fp is not None: next_serial = 0 - p = fp.child('{}.cert'.format(options['name'])).path while fp.child("{}.cert.{}".format(options['name'], next_serial)).exists(): next_serial += 1 with fp.child('{}.cert.{}'.format(options['name'], next_serial)).open('w') as f: diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index 34e96f38a..f0928d46b 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -33,6 +33,7 @@ import re import time import hashlib import json +from datetime import datetime from zope.interface import implementer from twisted.internet import defer @@ -41,6 +42,7 @@ from twisted.application import service from foolscap.api import eventually from allmydata.interfaces import IStorageBroker, IDisplayableServer, IServer from allmydata.util import log, base32, connection_status +from allmydata.util import keyutil from allmydata.util.assertutil import precondition from allmydata.util.observer import ObserverList from allmydata.util.rrefutil import add_version_to_remote_reference diff --git a/src/allmydata/test/no_network.py b/src/allmydata/test/no_network.py index 1fcfab1f9..de15d32bf 100644 --- a/src/allmydata/test/no_network.py +++ b/src/allmydata/test/no_network.py @@ -171,7 +171,7 @@ class NoNetworkServer(object): @implementer(IStorageBroker) class NoNetworkStorageBroker(object): - def get_servers_for_psi(self, peer_selection_index): + def get_servers_for_psi(self, peer_selection_index, for_upload=True): def _permuted(server): seed = server.get_permutation_seed() return permute_server_hash(peer_selection_index, seed) diff --git a/src/allmydata/test/test_checker.py b/src/allmydata/test/test_checker.py index 46dec8c24..7f89e9e08 100644 --- a/src/allmydata/test/test_checker.py +++ b/src/allmydata/test/test_checker.py @@ -41,7 +41,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin): "my-version": "ver", "oldest-supported": "oldest", } - s = NativeStorageServer(server_id, ann, None, None) + s = NativeStorageServer(server_id, ann, None, None, {}, None) sb.test_add_server(server_id, s) c = FakeClient() c.storage_broker = sb diff --git a/src/allmydata/test/test_storage_client.py b/src/allmydata/test/test_storage_client.py index a78f91acb..6a4ae5d06 100644 --- a/src/allmydata/test/test_storage_client.py +++ b/src/allmydata/test/test_storage_client.py @@ -40,7 +40,7 @@ class TestNativeStorageServer(unittest.TestCase): ann = {"anonymous-storage-FURL": "pb://w2hqnbaa25yw4qgcvghl5psa3srpfgw3@tcp:127.0.0.1:51309/vucto2z4fxment3vfxbqecblbf6zyp6x", "permutation-seed-base32": "w2hqnbaa25yw4qgcvghl5psa3srpfgw3", } - nss = NativeStorageServer("server_id", ann, None, {}) + nss = NativeStorageServer("server_id", ann, None, {}, {}, None) self.assertEqual(nss.get_nickname(), "") class TestStorageFarmBroker(unittest.TestCase): diff --git a/src/allmydata/test/test_util.py b/src/allmydata/test/test_util.py index 381add043..76e3f8155 100644 --- a/src/allmydata/test/test_util.py +++ b/src/allmydata/test/test_util.py @@ -96,7 +96,7 @@ class HumanReadable(unittest.TestCase): def test_abbrev_time_future_5_minutes(self): diff = timedelta(minutes=-5) s = abbreviate.abbreviate_time(diff) - self.assertEqual('5 minutes in the future', s) + self.assertEqual('5 minutes from now', s) def test_abbrev_time_hours(self): diff = timedelta(hours=4) diff --git a/src/allmydata/test/web/test_root.py b/src/allmydata/test/web/test_root.py index 727189421..81b531113 100644 --- a/src/allmydata/test/web/test_root.py +++ b/src/allmydata/test/web/test_root.py @@ -26,7 +26,7 @@ class RenderServiceRow(unittest.TestCase): ann = {"anonymous-storage-FURL": "pb://w2hqnbaa25yw4qgcvghl5psa3srpfgw3@tcp:127.0.0.1:51309/vucto2z4fxment3vfxbqecblbf6zyp6x", "permutation-seed-base32": "w2hqnbaa25yw4qgcvghl5psa3srpfgw3", } - s = NativeStorageServer("server_id", ann, None, {}) + s = NativeStorageServer("server_id", ann, None, {}, {}, None) cs = ConnectionStatus(False, "summary", {}, 0, 0) s.get_connection_status = lambda: cs