From f0359f106c2631e7ac671c9a496a8d6de0fc675d Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 17 Dec 2020 10:20:17 -0500 Subject: [PATCH 01/10] news fragment --- newsfragments/3567.minor | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newsfragments/3567.minor diff --git a/newsfragments/3567.minor b/newsfragments/3567.minor new file mode 100644 index 000000000..e69de29bb From 8e6c52b61e2208a43ec0bcf1098f76c6b227eed2 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 17 Dec 2020 10:20:22 -0500 Subject: [PATCH 02/10] pre-assign a listening socket to the main tub to avoid the error --- src/allmydata/test/test_storage_client.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/allmydata/test/test_storage_client.py b/src/allmydata/test/test_storage_client.py index 18caccc5d..3a21dfd9e 100644 --- a/src/allmydata/test/test_storage_client.py +++ b/src/allmydata/test/test_storage_client.py @@ -457,7 +457,8 @@ class StoragePluginWebPresence(AsyncTestCase): self.storage_plugin = u"tahoe-lafs-dummy-v1" from twisted.internet import reactor - _, port_endpoint = self.port_assigner.assign(reactor) + _, webport_endpoint = self.port_assigner.assign(reactor) + tubport_location, tubport_endpoint = self.port_assigner.assign(reactor) tempdir = TempDir() self.useFixture(tempdir) @@ -468,8 +469,12 @@ class StoragePluginWebPresence(AsyncTestCase): "web": "1", }, node_config={ - "tub.location": "127.0.0.1:1", - "web.port": ensure_text(port_endpoint), + # We don't really need the main Tub listening but if we + # disable it then we also have to disable storage (because + # config validation policy). + "tub.port": tubport_endpoint, + "tub.location": tubport_location, + "web.port": ensure_text(webport_endpoint), }, storage_plugin=self.storage_plugin, basedir=self.basedir, From 05699722124f1fa41eae1a23133b0a2468528d11 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 17 Dec 2020 12:40:12 -0500 Subject: [PATCH 03/10] news fragment --- newsfragments/3568.minor | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newsfragments/3568.minor diff --git a/newsfragments/3568.minor b/newsfragments/3568.minor new file mode 100644 index 000000000..e69de29bb From ad1e38eea432dd2041be26ee7df0d29404b0d5a0 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 17 Dec 2020 12:40:20 -0500 Subject: [PATCH 04/10] Can we make codecov wait a while? --- .codecov.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index df1eb5e01..310a40743 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -40,3 +40,6 @@ codecov: # repositories have coverage uploaded to the right place in codecov so # their reports aren't incomplete. token: "abf679b6-e2e6-4b33-b7b5-6cfbd41ee691" + + notify: + after_n_builds: 23 From 29d54aee78fc43222e12a4cacf123a95c0ade0dc Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 17 Dec 2020 13:08:33 -0500 Subject: [PATCH 05/10] What does this setting do? --- .codecov.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.codecov.yml b/.codecov.yml index 310a40743..166190c5e 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -42,4 +42,7 @@ codecov: token: "abf679b6-e2e6-4b33-b7b5-6cfbd41ee691" notify: - after_n_builds: 23 + # The reference documentation suggests that this is the default setting: + # https://docs.codecov.io/docs/codecovyml-reference#codecovnotifywait_for_ci + # However observation suggests otherwise. + wait_for_ci: true From 8f4a0379eacb19320fe1c276c6e32f3313f1a988 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 18 Dec 2020 11:26:10 -0500 Subject: [PATCH 06/10] Correct examples. --- src/allmydata/test/common_util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/allmydata/test/common_util.py b/src/allmydata/test/common_util.py index 1ad0f8242..63c39d39a 100644 --- a/src/allmydata/test/common_util.py +++ b/src/allmydata/test/common_util.py @@ -59,10 +59,10 @@ def run_cli_native(verb, *args, **kwargs): Most code should prefer ``run_cli_unicode`` which deals with all the necessary encoding considerations. - :param native_str verb: The command to run. For example, ``b"create-node"``. + :param native_str verb: The command to run. For example, ``"create-node"``. :param [native_str] args: The arguments to pass to the command. For example, - ``(b"--hostname=localhost",)``. + ``("--hostname=localhost",)``. :param [native_str] nodeargs: Extra arguments to pass to the Tahoe executable before ``verb``. From 721b02b262a538de05bd757c655dc87f274e1950 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 18 Dec 2020 11:29:51 -0500 Subject: [PATCH 07/10] Use the function I specifically wrote for this! --- src/allmydata/util/base32.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/allmydata/util/base32.py b/src/allmydata/util/base32.py index 75625c817..efad58841 100644 --- a/src/allmydata/util/base32.py +++ b/src/allmydata/util/base32.py @@ -134,8 +134,7 @@ def a2b(cs): @param cs the base-32 encoded data (as bytes) """ # Workaround Future newbytes issues by converting to real bytes on Python 2: - if hasattr(cs, "__native__"): - cs = cs.__native__() + cs = backwardscompat_bytes(cs) precondition(could_be_base32_encoded(cs), "cs is required to be possibly base32 encoded data.", cs=cs) precondition(isinstance(cs, bytes), cs) From 865f3fd7d0d0fa82dcb9ed4a75f7f12ee02004fa Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 18 Dec 2020 11:33:24 -0500 Subject: [PATCH 08/10] Improve the docstring. --- src/allmydata/test/test_system.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 192b82e78..0a5996cdc 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -70,7 +70,13 @@ from ..scripts.common import ( def run_cli(*args, **kwargs): """ - Backwards compatible version so we don't have to change all the tests. + Run a Tahoe-LAFS CLI utility, but inline. + + Version of run_cli_unicode() that takes any kind of string, and the + command-line args inline instead of as verb + list. + + Backwards compatible version so we don't have to change all the tests that + expected this API. """ nodeargs = [ensure_text(a) for a in kwargs.pop("nodeargs", [])] kwargs["nodeargs"] = nodeargs From 50a794a91154259d7d948e5fb110e520f7d40588 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 18 Dec 2020 11:34:08 -0500 Subject: [PATCH 09/10] More accurate docstring. --- src/allmydata/test/test_system.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 0a5996cdc..e8b27fa69 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -664,7 +664,7 @@ def flush_but_dont_ignore(res): def _render_config(config): """ - Convert a ``dict`` of ``dict`` of ``bytes`` to an ini-format string. + Convert a ``dict`` of ``dict`` of ``unicode`` to an ini-format string. """ return u"\n\n".join(list( _render_config_section(k, v) @@ -674,8 +674,8 @@ def _render_config(config): def _render_config_section(heading, values): """ - Convert a ``bytes`` heading and a ``dict`` of ``bytes`` to an ini-format - section as ``bytes``. + Convert a ``unicode`` heading and a ``dict`` of ``unicode`` to an ini-format + section as ``unicode``. """ return u"[{}]\n{}\n".format( heading, _render_section_values(values) @@ -683,8 +683,8 @@ def _render_config_section(heading, values): def _render_section_values(values): """ - Convert a ``dict`` of ``bytes`` to the body of an ini-format section as - ``bytes``. + Convert a ``dict`` of ``unicode`` to the body of an ini-format section as + ``unicode``. """ return u"\n".join(list( u"{} = {}".format(k, v) From f964ae1782076dcb99aaad886393bbddb416ecbf Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 18 Dec 2020 15:43:27 -0500 Subject: [PATCH 10/10] Docstrings. --- src/allmydata/web/common.py | 20 ++++++++++++++++++-- src/allmydata/web/common_py3.py | 7 +++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/allmydata/web/common.py b/src/allmydata/web/common.py index 4e8cab89d..929db4f6e 100644 --- a/src/allmydata/web/common.py +++ b/src/allmydata/web/common.py @@ -208,7 +208,15 @@ def compute_rate(bytes, seconds): return 1.0 * bytes / seconds def abbreviate_rate(data): - # 21.8kBps, 554.4kBps 4.37MBps + """ + Convert number of bytes/second into human readable strings (unicode). + + Uses metric measures, so 1000 not 1024, e.g. 21.8kBps, 554.4kBps, 4.37MBps. + + :param data: Either ``None`` or integer. + + :return: Unicode string. + """ if data is None: return u"" r = float(data) @@ -219,7 +227,15 @@ def abbreviate_rate(data): return u"%.0fBps" % r def abbreviate_size(data): - # 21.8kB, 554.4kB 4.37MB + """ + Convert number of bytes into human readable strings (unicode). + + Uses metric measures, so 1000 not 1024, e.g. 21.8kB, 554.4kB, 4.37MB. + + :param data: Either ``None`` or integer. + + :return: Unicode string. + """ if data is None: return u"" r = float(data) diff --git a/src/allmydata/web/common_py3.py b/src/allmydata/web/common_py3.py index 89efd4d5d..41b6939f3 100644 --- a/src/allmydata/web/common_py3.py +++ b/src/allmydata/web/common_py3.py @@ -95,6 +95,13 @@ class MultiFormatResource(resource.Resource, object): def abbreviate_time(data): + """ + Convert number of seconds into human readable string. + + :param data: Either ``None`` or integer or float, seconds. + + :return: Unicode string. + """ # 1.23s, 790ms, 132us if data is None: return u""