various fixes (flake8, errors)

This commit is contained in:
meejah 2018-05-22 16:19:43 -06:00
parent 3f1a8d64d8
commit 2031b723b8
8 changed files with 8 additions and 15 deletions

View File

@ -15,7 +15,6 @@ from twisted.application.internet import TimerService
from twisted.python.filepath import FilePath from twisted.python.filepath import FilePath
from twisted.python.failure import Failure from twisted.python.failure import Failure
from pycryptopp.publickey import rsa from pycryptopp.publickey import rsa
from pycryptopp.publickey import ed25519
import allmydata import allmydata
from allmydata.storage.server import StorageServer from allmydata.storage.server import StorageServer

View File

@ -9,17 +9,11 @@ from pycryptopp.publickey import ed25519 # perhaps NaCl instead? other code use
from allmydata.scripts.common import BasedirOptions from allmydata.scripts.common import BasedirOptions
from allmydata.util.abbreviate import abbreviate_time from allmydata.util.abbreviate import abbreviate_time
from twisted.scripts import twistd
from twisted.python import usage from twisted.python import usage
from twisted.python.reflect import namedAny
from twisted.python.filepath import FilePath from twisted.python.filepath import FilePath
from allmydata.scripts.default_nodedir import _default_nodedir
from allmydata.util import fileutil from allmydata.util import fileutil
from allmydata.util import base32 from allmydata.util import base32
from allmydata.util import keyutil 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 from twisted.internet.defer import inlineCallbacks, returnValue
@ -178,7 +172,7 @@ class _GridManager(object):
if 'private_key' not in config: if 'private_key' not in config:
raise ValueError( raise ValueError(
"Grid Manager config from '{}' requires a 'private_key'".format( "Grid Manager config from '{}' requires a 'private_key'".format(
config_config config_location,
) )
) )
@ -406,7 +400,6 @@ def _list(gridoptions, options):
else: else:
print(" {}: expired ({})".format(cert_count, abbreviate_time(delta))) print(" {}: expired ({})".format(cert_count, abbreviate_time(delta)))
cert_count += 1 cert_count += 1
certs = ' ({} certificates)'.format(cert_count)
def _sign(gridoptions, options): def _sign(gridoptions, options):
@ -428,7 +421,6 @@ def _sign(gridoptions, options):
print(certificate_data) print(certificate_data)
if fp is not None: if fp is not None:
next_serial = 0 next_serial = 0
p = fp.child('{}.cert'.format(options['name'])).path
while fp.child("{}.cert.{}".format(options['name'], next_serial)).exists(): while fp.child("{}.cert.{}".format(options['name'], next_serial)).exists():
next_serial += 1 next_serial += 1
with fp.child('{}.cert.{}'.format(options['name'], next_serial)).open('w') as f: with fp.child('{}.cert.{}'.format(options['name'], next_serial)).open('w') as f:

View File

@ -33,6 +33,7 @@ import re
import time import time
import hashlib import hashlib
import json import json
from datetime import datetime
from zope.interface import implementer from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
@ -41,6 +42,7 @@ from twisted.application import service
from foolscap.api import eventually from foolscap.api import eventually
from allmydata.interfaces import IStorageBroker, IDisplayableServer, IServer from allmydata.interfaces import IStorageBroker, IDisplayableServer, IServer
from allmydata.util import log, base32, connection_status from allmydata.util import log, base32, connection_status
from allmydata.util import keyutil
from allmydata.util.assertutil import precondition from allmydata.util.assertutil import precondition
from allmydata.util.observer import ObserverList from allmydata.util.observer import ObserverList
from allmydata.util.rrefutil import add_version_to_remote_reference from allmydata.util.rrefutil import add_version_to_remote_reference

View File

@ -171,7 +171,7 @@ class NoNetworkServer(object):
@implementer(IStorageBroker) @implementer(IStorageBroker)
class NoNetworkStorageBroker(object): 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): def _permuted(server):
seed = server.get_permutation_seed() seed = server.get_permutation_seed()
return permute_server_hash(peer_selection_index, seed) return permute_server_hash(peer_selection_index, seed)

View File

@ -41,7 +41,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
"my-version": "ver", "my-version": "ver",
"oldest-supported": "oldest", "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) sb.test_add_server(server_id, s)
c = FakeClient() c = FakeClient()
c.storage_broker = sb c.storage_broker = sb

View File

@ -40,7 +40,7 @@ class TestNativeStorageServer(unittest.TestCase):
ann = {"anonymous-storage-FURL": "pb://w2hqnbaa25yw4qgcvghl5psa3srpfgw3@tcp:127.0.0.1:51309/vucto2z4fxment3vfxbqecblbf6zyp6x", ann = {"anonymous-storage-FURL": "pb://w2hqnbaa25yw4qgcvghl5psa3srpfgw3@tcp:127.0.0.1:51309/vucto2z4fxment3vfxbqecblbf6zyp6x",
"permutation-seed-base32": "w2hqnbaa25yw4qgcvghl5psa3srpfgw3", "permutation-seed-base32": "w2hqnbaa25yw4qgcvghl5psa3srpfgw3",
} }
nss = NativeStorageServer("server_id", ann, None, {}) nss = NativeStorageServer("server_id", ann, None, {}, {}, None)
self.assertEqual(nss.get_nickname(), "") self.assertEqual(nss.get_nickname(), "")
class TestStorageFarmBroker(unittest.TestCase): class TestStorageFarmBroker(unittest.TestCase):

View File

@ -96,7 +96,7 @@ class HumanReadable(unittest.TestCase):
def test_abbrev_time_future_5_minutes(self): def test_abbrev_time_future_5_minutes(self):
diff = timedelta(minutes=-5) diff = timedelta(minutes=-5)
s = abbreviate.abbreviate_time(diff) 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): def test_abbrev_time_hours(self):
diff = timedelta(hours=4) diff = timedelta(hours=4)

View File

@ -26,7 +26,7 @@ class RenderServiceRow(unittest.TestCase):
ann = {"anonymous-storage-FURL": "pb://w2hqnbaa25yw4qgcvghl5psa3srpfgw3@tcp:127.0.0.1:51309/vucto2z4fxment3vfxbqecblbf6zyp6x", ann = {"anonymous-storage-FURL": "pb://w2hqnbaa25yw4qgcvghl5psa3srpfgw3@tcp:127.0.0.1:51309/vucto2z4fxment3vfxbqecblbf6zyp6x",
"permutation-seed-base32": "w2hqnbaa25yw4qgcvghl5psa3srpfgw3", "permutation-seed-base32": "w2hqnbaa25yw4qgcvghl5psa3srpfgw3",
} }
s = NativeStorageServer("server_id", ann, None, {}) s = NativeStorageServer("server_id", ann, None, {}, {}, None)
cs = ConnectionStatus(False, "summary", {}, 0, 0) cs = ConnectionStatus(False, "summary", {}, 0, 0)
s.get_connection_status = lambda: cs s.get_connection_status = lambda: cs