From bfbca87f265d00241cd9892ac5fb5de19c3c4ce7 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Mon, 3 Aug 2020 11:31:02 -0400 Subject: [PATCH 01/18] Missing from previous PR. --- src/allmydata/hashtree.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/allmydata/hashtree.py b/src/allmydata/hashtree.py index 77798b3c2..c692e3597 100644 --- a/src/allmydata/hashtree.py +++ b/src/allmydata/hashtree.py @@ -45,6 +45,8 @@ Written by Connelly Barnes in 2005 and released into the public domain with no warranty of any kind, either expressed or implied. It probably won't make your computer catch on fire, or eat your children, but it might. Use at your own risk. + +Ported to Python 3. """ from __future__ import absolute_import From 1703230a2a5bc48278581e558e9ca9091d7d5647 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Mon, 3 Aug 2020 11:33:21 -0400 Subject: [PATCH 02/18] Use nummedobj from pyutil. --- src/allmydata/util/log.py | 2 +- src/allmydata/util/nummedobj.py | 42 --------------------------------- 2 files changed, 1 insertion(+), 43 deletions(-) delete mode 100644 src/allmydata/util/nummedobj.py diff --git a/src/allmydata/util/log.py b/src/allmydata/util/log.py index 454002000..8ebf1262b 100644 --- a/src/allmydata/util/log.py +++ b/src/allmydata/util/log.py @@ -1,4 +1,4 @@ -from allmydata.util import nummedobj +from pyutil import nummedobj from foolscap.logging import log from twisted.python import log as tw_log diff --git a/src/allmydata/util/nummedobj.py b/src/allmydata/util/nummedobj.py deleted file mode 100644 index 50d7c6454..000000000 --- a/src/allmydata/util/nummedobj.py +++ /dev/null @@ -1,42 +0,0 @@ -import collections, itertools, functools - -objnums = collections.defaultdict(itertools.count) - - -@functools.total_ordering -class NummedObj(object): - """ - This is useful for nicer debug printouts. Instead of objects of the same class being - distinguished from one another by their memory address, they each get a unique number, which - can be read as "the first object of this class", "the second object of this class", etc. This - is especially useful because separate runs of a program will yield identical debug output, - (assuming that the objects get created in the same order in each run). This makes it possible - to diff outputs from separate runs to see what changed, without having to ignore a difference - on every line due to different memory addresses of objects. - """ - - def __init__(self, klass=None): - """ - @param klass: in which class are you counted? If default value of `None', then self.__class__ will be used. - """ - if klass is None: - klass = self.__class__ - self._classname = klass.__name__ - - self._objid = objnums[self._classname].next() - - def __repr__(self): - return "<%s #%d>" % (self._classname, self._objid,) - - def __lt__(self, other): - if isinstance(other, NummedObj): - return (self._objid, self._classname,) < (other._objid, other._classname,) - return NotImplemented - - def __eq__(self, other): - if isinstance(other, NummedObj): - return (self._objid, self._classname,) == (other._objid, other._classname,) - return NotImplemented - - def __hash__(self): - return id(self) From 02daa12031105f36649828b5e024bbb27ed5d295 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Mon, 3 Aug 2020 11:33:29 -0400 Subject: [PATCH 03/18] Move logging tests into their own, Python 3-compatible, module. --- src/allmydata/test/test_util.py | 16 ---------------- src/allmydata/util/_python3.py | 1 + 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/allmydata/test/test_util.py b/src/allmydata/test/test_util.py index 1e9dd0f49..bd0e16df1 100644 --- a/src/allmydata/test/test_util.py +++ b/src/allmydata/test/test_util.py @@ -6,13 +6,11 @@ import yaml from twisted.trial import unittest from twisted.internet import defer, reactor -from twisted.python.failure import Failure from allmydata.util import idlib, mathutil from allmydata.util import fileutil from allmydata.util import limiter, pollmixin from allmydata.util import yamlutil -from allmydata.util import log as tahoe_log from allmydata.util.fileutil import EncryptedTemporaryFile from allmydata.test.common_util import ReallyEqualMixin @@ -528,20 +526,6 @@ class EqButNotIs(object): return self.x == other -class SampleError(Exception): - pass - -class Log(unittest.TestCase): - def test_err(self): - try: - raise SampleError("simple sample") - except: - f = Failure() - tahoe_log.err(format="intentional sample error", - failure=f, level=tahoe_log.OPERATIONAL, umid="wO9UoQ") - self.flushLoggedErrors(SampleError) - - class YAML(unittest.TestCase): def test_convert(self): data = yaml.safe_dump(["str", u"unicode", u"\u1234nicode"]) diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 8a75a8fc5..046468eeb 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -48,6 +48,7 @@ PORTED_TEST_MODULES = [ "allmydata.test.test_hashutil", "allmydata.test.test_humanreadable", "allmydata.test.test_iputil", + "allmydata.test.test_log", "allmydata.test.test_netstring", "allmydata.test.test_observer", "allmydata.test.test_pipeline", From 622ed2f971a94f54de19f2cdb1ee2459723155a4 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Mon, 3 Aug 2020 14:09:28 -0400 Subject: [PATCH 04/18] Standalone logging tests, most of them new, and an attempt to fix the parent msgid logic so it's a little less broken. --- src/allmydata/test/test_log.py | 113 +++++++++++++++++++++++++++++++++ src/allmydata/util/log.py | 4 +- 2 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 src/allmydata/test/test_log.py diff --git a/src/allmydata/test/test_log.py b/src/allmydata/test/test_log.py new file mode 100644 index 000000000..00ba03013 --- /dev/null +++ b/src/allmydata/test/test_log.py @@ -0,0 +1,113 @@ +""" +Tests for allmydata.util.log. + +Ported to Python 3. +""" + +from __future__ import unicode_literals +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from future.utils import PY2 +if PY2: + from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, int, list, object, range, str, max, min # noqa: F401 + +from twisted.trial import unittest +from twisted.python.failure import Failure + +from foolscap.logging import log + +from allmydata.util import log as tahoe_log + + +class SampleError(Exception): + pass + + +class LoggingObject0(tahoe_log.PrefixingLogMixin): + pass + + +class LoggingObject1(tahoe_log.PrefixingLogMixin): + pass + + +class LoggingObject2(tahoe_log.PrefixingLogMixin): + pass + + +class LoggingObject3(tahoe_log.PrefixingLogMixin): + pass + + +class Log(unittest.TestCase): + def setUp(self): + self.messages = [] + + def msg(msg, facility, parent, *args, **kwargs): + self.messages.append((msg, facility, parent, args, kwargs)) + return "msg{}".format(len(self.messages)) + + self.patch(log, "msg", msg) + + def test_err(self): + """Logging with log.err() causes tests to fail.""" + try: + raise SampleError("simple sample") + except: + f = Failure() + tahoe_log.err(format="intentional sample error", + failure=f, level=tahoe_log.OPERATIONAL, umid="wO9UoQ") + self.flushLoggedErrors(SampleError) + + def test_default_facility(self): + obj = LoggingObject1(facility="defaultfac") + obj.log("hello") + obj.log("world", facility="override") + self.assertEqual(self.messages[-2][1], "defaultfac") + self.assertEqual(self.messages[-1][1], "override") + + def test_with_prefix(self): + obj = LoggingObject0("fac", prefix="pre1") + obj.log("hello") + obj.log("world") + self.assertEqual(self.messages[-2][0], '(pre1): hello') + self.assertEqual(self.messages[-1][0], '(pre1): world') + + def test_no_prefix(self): + obj = LoggingObject2() + obj.log("hello") + obj.log("world") + self.assertEqual(self.messages[-2][0], ': hello') + self.assertEqual(self.messages[-1][0], ': world') + + def test_numming(self): + obj = LoggingObject3() + obj2 = LoggingObject3() + obj.log("hello") + obj2.log("world") + self.assertEqual(self.messages[-2][0], ': hello') + self.assertEqual(self.messages[-1][0], ': world') + + def test_parent_id(self): + obj = LoggingObject1() + result = obj.log("zero") + self.assertEqual(result, "msg1") + obj.log("one", parent="par1") + obj.log("two", parent="par2") + obj.log("three") + obj.log("four") + self.assertEqual([m[2] for m in self.messages], + [None, "par1", "par2", "msg1", "msg1"]) + + def test_grandparent_id(self): + obj = LoggingObject1(grandparentmsgid="grand") + result = obj.log("zero") + self.assertEqual(result, "msg1") + obj.log("one", parent="par1") + obj.log("two", parent="par2") + obj.log("three") + obj.log("four") + self.assertEqual([m[2] for m in self.messages], + ["grand", "par1", "par2", "msg1", "msg1"]) diff --git a/src/allmydata/util/log.py b/src/allmydata/util/log.py index 8ebf1262b..c1966aadb 100644 --- a/src/allmydata/util/log.py +++ b/src/allmydata/util/log.py @@ -36,8 +36,8 @@ class LogMixin(object): def log(self, msg, facility=None, parent=None, *args, **kwargs): if facility is None: facility = self._facility - pmsgid = None - if parent is None: + pmsgid = parent + if pmsgid is None: pmsgid = self._parentmsgid if pmsgid is None: pmsgid = self._grandparentmsgid From 2a623e0b05e0162d9332eea40429b4115c5984af Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Mon, 3 Aug 2020 14:13:16 -0400 Subject: [PATCH 05/18] Port to Python 3. --- misc/python3/ratchet-passing | 7 +++++++ newsfragments/3365.minor | 0 src/allmydata/util/_python3.py | 1 + src/allmydata/util/log.py | 14 ++++++++++++++ 4 files changed, 22 insertions(+) create mode 100644 newsfragments/3365.minor diff --git a/misc/python3/ratchet-passing b/misc/python3/ratchet-passing index b9beb360e..2edba65c0 100644 --- a/misc/python3/ratchet-passing +++ b/misc/python3/ratchet-passing @@ -54,6 +54,13 @@ allmydata.test.test_iputil.ListAddresses.test_list_async_mock_ip_addr allmydata.test.test_iputil.ListAddresses.test_list_async_mock_route allmydata.test.test_iputil.ListenOnUsed.test_random_port allmydata.test.test_iputil.ListenOnUsed.test_specific_port +allmydata.test.test_log.Log.test_default_facility +allmydata.test.test_log.Log.test_err +allmydata.test.test_log.Log.test_grandparent_id +allmydata.test.test_log.Log.test_no_prefix +allmydata.test.test_log.Log.test_numming +allmydata.test.test_log.Log.test_parent_id +allmydata.test.test_log.Log.test_with_prefix allmydata.test.test_netstring.Netstring.test_encode allmydata.test.test_netstring.Netstring.test_extra allmydata.test.test_netstring.Netstring.test_nested diff --git a/newsfragments/3365.minor b/newsfragments/3365.minor new file mode 100644 index 000000000..e69de29bb diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 046468eeb..a1c727697 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -25,6 +25,7 @@ PORTED_MODULES = [ "allmydata.util.hashutil", "allmydata.util.humanreadable", "allmydata.util.iputil", + "allmydata.util.log", "allmydata.util.mathutil", "allmydata.util.namespace", "allmydata.util.netstring", diff --git a/src/allmydata/util/log.py b/src/allmydata/util/log.py index c1966aadb..cd20c764d 100644 --- a/src/allmydata/util/log.py +++ b/src/allmydata/util/log.py @@ -1,3 +1,17 @@ +""" +Logging utilities. + +Ported to Python 3. +""" +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +from future.utils import PY2 +if PY2: + from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, int, list, object, range, str, max, min # noqa: F401 + from pyutil import nummedobj from foolscap.logging import log From ff7cf4d731242744c2b971f485b48e50a9cce02f Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Tue, 4 Aug 2020 15:15:32 -0400 Subject: [PATCH 06/18] Test improvements. --- src/allmydata/test/test_log.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/allmydata/test/test_log.py b/src/allmydata/test/test_log.py index 00ba03013..1d24d7f7b 100644 --- a/src/allmydata/test/test_log.py +++ b/src/allmydata/test/test_log.py @@ -59,9 +59,14 @@ class Log(unittest.TestCase): f = Failure() tahoe_log.err(format="intentional sample error", failure=f, level=tahoe_log.OPERATIONAL, umid="wO9UoQ") - self.flushLoggedErrors(SampleError) + result = self.flushLoggedErrors(SampleError) + self.assertEqual(len(result), 1) def test_default_facility(self): + """ + If facility is passed to PrefixingLogMixin.__init__, it is used as + default facility. + """ obj = LoggingObject1(facility="defaultfac") obj.log("hello") obj.log("world", facility="override") @@ -69,6 +74,10 @@ class Log(unittest.TestCase): self.assertEqual(self.messages[-1][1], "override") def test_with_prefix(self): + """ + If prefix is passed to PrefixingLogMixin.__init__, it is used in + message rendering. + """ obj = LoggingObject0("fac", prefix="pre1") obj.log("hello") obj.log("world") @@ -76,6 +85,10 @@ class Log(unittest.TestCase): self.assertEqual(self.messages[-1][0], '(pre1): world') def test_no_prefix(self): + """ + If no prefix is passed to PrefixingLogMixin.__init__, it is not used in + message rendering. + """ obj = LoggingObject2() obj.log("hello") obj.log("world") @@ -83,6 +96,10 @@ class Log(unittest.TestCase): self.assertEqual(self.messages[-1][0], ': world') def test_numming(self): + """ + Objects inheriting from PrefixingLogMixin get a unique number from a + class-specific counter. + """ obj = LoggingObject3() obj2 = LoggingObject3() obj.log("hello") @@ -91,6 +108,12 @@ class Log(unittest.TestCase): self.assertEqual(self.messages[-1][0], ': world') def test_parent_id(self): + """ + The parent message id can be passed in, otherwise the first message's + id is used as the parent. + + This logic is pretty bogus, but that's what the code does. + """ obj = LoggingObject1() result = obj.log("zero") self.assertEqual(result, "msg1") @@ -102,6 +125,10 @@ class Log(unittest.TestCase): [None, "par1", "par2", "msg1", "msg1"]) def test_grandparent_id(self): + """ + If grandparent message id is given, it's used as parent id of the first + message. + """ obj = LoggingObject1(grandparentmsgid="grand") result = obj.log("zero") self.assertEqual(result, "msg1") From 0bef1eb4e2c6f76c82df67cc6d990e9f8f285b0d Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Wed, 5 Aug 2020 11:25:40 -0400 Subject: [PATCH 07/18] Support prefix that is bytes. --- src/allmydata/test/test_log.py | 11 +++++++++++ src/allmydata/util/log.py | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/allmydata/test/test_log.py b/src/allmydata/test/test_log.py index 1d24d7f7b..2c26e8ff4 100644 --- a/src/allmydata/test/test_log.py +++ b/src/allmydata/test/test_log.py @@ -84,6 +84,17 @@ class Log(unittest.TestCase): self.assertEqual(self.messages[-2][0], '(pre1): hello') self.assertEqual(self.messages[-1][0], '(pre1): world') + def test_with_bytes_prefix(self): + """ + If bytes prefix is passed to PrefixingLogMixin.__init__, it is used in + message rendering. + """ + obj = LoggingObject0("fac", prefix=b"pre1") + obj.log("hello") + obj.log("world") + self.assertEqual(self.messages[-2][0], '(pre1): hello') + self.assertEqual(self.messages[-1][0], '(pre1): world') + def test_no_prefix(self): """ If no prefix is passed to PrefixingLogMixin.__init__, it is not used in diff --git a/src/allmydata/util/log.py b/src/allmydata/util/log.py index cd20c764d..dcb5838a3 100644 --- a/src/allmydata/util/log.py +++ b/src/allmydata/util/log.py @@ -68,6 +68,8 @@ class PrefixingLogMixin(nummedobj.NummedObj, LogMixin): LogMixin.__init__(self, facility, grandparentmsgid) if prefix: + if isinstance(prefix, bytes): + prefix = prefix.decode("utf-8", errors="replace") self._prefix = "%s(%s): " % (self.__repr__(), prefix) else: self._prefix = "%s: " % (self.__repr__(),) From 32945b85f6d84820843465f39da732ad5170fdde Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Thu, 6 Aug 2020 16:14:39 -0400 Subject: [PATCH 08/18] Drop int. --- src/allmydata/test/test_log.py | 2 +- src/allmydata/util/log.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/allmydata/test/test_log.py b/src/allmydata/test/test_log.py index 2c26e8ff4..dea198506 100644 --- a/src/allmydata/test/test_log.py +++ b/src/allmydata/test/test_log.py @@ -11,7 +11,7 @@ from __future__ import print_function from future.utils import PY2 if PY2: - from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, int, list, object, range, str, max, min # noqa: F401 + from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 from twisted.trial import unittest from twisted.python.failure import Failure diff --git a/src/allmydata/util/log.py b/src/allmydata/util/log.py index dcb5838a3..11c78a5a2 100644 --- a/src/allmydata/util/log.py +++ b/src/allmydata/util/log.py @@ -10,7 +10,7 @@ from __future__ import unicode_literals from future.utils import PY2 if PY2: - from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, int, list, object, range, str, max, min # noqa: F401 + from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 from pyutil import nummedobj From ff5cfe0c71822ff13d39e0567320339dd6205687 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Thu, 6 Aug 2020 16:15:31 -0400 Subject: [PATCH 09/18] Update ratchet with new test. --- misc/python3/ratchet-passing | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/python3/ratchet-passing b/misc/python3/ratchet-passing index 2edba65c0..56d82d4e7 100644 --- a/misc/python3/ratchet-passing +++ b/misc/python3/ratchet-passing @@ -60,6 +60,7 @@ allmydata.test.test_log.Log.test_grandparent_id allmydata.test.test_log.Log.test_no_prefix allmydata.test.test_log.Log.test_numming allmydata.test.test_log.Log.test_parent_id +allmydata.test.test_log.Log.test_with_bytes_prefix allmydata.test.test_log.Log.test_with_prefix allmydata.test.test_netstring.Netstring.test_encode allmydata.test.test_netstring.Netstring.test_extra From 49c631b4c8d20bda1bb0f7c6a0d4017e14be3355 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Fri, 7 Aug 2020 08:43:17 -0400 Subject: [PATCH 10/18] Sort the thing we said we'd sort --- newsfragments/3372.minor | 0 src/allmydata/util/_python3.py | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 newsfragments/3372.minor diff --git a/newsfragments/3372.minor b/newsfragments/3372.minor new file mode 100644 index 000000000..e69de29bb diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index b4b6b0695..ea852cc54 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -22,6 +22,8 @@ PORTED_MODULES = [ "allmydata.crypto.rsa", "allmydata.crypto.util", "allmydata.hashtree", + "allmydata.test.common_py3", + "allmydata.util._python3", "allmydata.util.abbreviate", "allmydata.util.assertutil", "allmydata.util.base32", @@ -38,11 +40,9 @@ PORTED_MODULES = [ "allmydata.util.observer", "allmydata.util.pipeline", "allmydata.util.pollmixin", - "allmydata.util._python3", "allmydata.util.spans", "allmydata.util.statistics", "allmydata.util.time_format", - "allmydata.test.common_py3", ] PORTED_TEST_MODULES = [ From fb9bf5511ff18a407fdfc357fca94ec15d58450f Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 7 Aug 2020 11:09:41 -0400 Subject: [PATCH 11/18] Passing tests. --- src/allmydata/test/test_log.py | 49 +++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/allmydata/test/test_log.py b/src/allmydata/test/test_log.py index dea198506..eecbda9e3 100644 --- a/src/allmydata/test/test_log.py +++ b/src/allmydata/test/test_log.py @@ -25,22 +25,6 @@ class SampleError(Exception): pass -class LoggingObject0(tahoe_log.PrefixingLogMixin): - pass - - -class LoggingObject1(tahoe_log.PrefixingLogMixin): - pass - - -class LoggingObject2(tahoe_log.PrefixingLogMixin): - pass - - -class LoggingObject3(tahoe_log.PrefixingLogMixin): - pass - - class Log(unittest.TestCase): def setUp(self): self.messages = [] @@ -67,6 +51,9 @@ class Log(unittest.TestCase): If facility is passed to PrefixingLogMixin.__init__, it is used as default facility. """ + class LoggingObject1(tahoe_log.PrefixingLogMixin): + pass + obj = LoggingObject1(facility="defaultfac") obj.log("hello") obj.log("world", facility="override") @@ -78,28 +65,37 @@ class Log(unittest.TestCase): If prefix is passed to PrefixingLogMixin.__init__, it is used in message rendering. """ - obj = LoggingObject0("fac", prefix="pre1") + class LoggingObject4(tahoe_log.PrefixingLogMixin): + pass + + obj = LoggingObject4("fac", prefix="pre1") obj.log("hello") obj.log("world") - self.assertEqual(self.messages[-2][0], '(pre1): hello') - self.assertEqual(self.messages[-1][0], '(pre1): world') + self.assertEqual(self.messages[-2][0], '(pre1): hello') + self.assertEqual(self.messages[-1][0], '(pre1): world') def test_with_bytes_prefix(self): """ If bytes prefix is passed to PrefixingLogMixin.__init__, it is used in message rendering. """ - obj = LoggingObject0("fac", prefix=b"pre1") + class LoggingObject5(tahoe_log.PrefixingLogMixin): + pass + + obj = LoggingObject5("fac", prefix=b"pre1") obj.log("hello") obj.log("world") - self.assertEqual(self.messages[-2][0], '(pre1): hello') - self.assertEqual(self.messages[-1][0], '(pre1): world') + self.assertEqual(self.messages[-2][0], '(pre1): hello') + self.assertEqual(self.messages[-1][0], '(pre1): world') def test_no_prefix(self): """ If no prefix is passed to PrefixingLogMixin.__init__, it is not used in message rendering. """ + class LoggingObject2(tahoe_log.PrefixingLogMixin): + pass + obj = LoggingObject2() obj.log("hello") obj.log("world") @@ -111,6 +107,9 @@ class Log(unittest.TestCase): Objects inheriting from PrefixingLogMixin get a unique number from a class-specific counter. """ + class LoggingObject3(tahoe_log.PrefixingLogMixin): + pass + obj = LoggingObject3() obj2 = LoggingObject3() obj.log("hello") @@ -125,6 +124,9 @@ class Log(unittest.TestCase): This logic is pretty bogus, but that's what the code does. """ + class LoggingObject1(tahoe_log.PrefixingLogMixin): + pass + obj = LoggingObject1() result = obj.log("zero") self.assertEqual(result, "msg1") @@ -140,6 +142,9 @@ class Log(unittest.TestCase): If grandparent message id is given, it's used as parent id of the first message. """ + class LoggingObject1(tahoe_log.PrefixingLogMixin): + pass + obj = LoggingObject1(grandparentmsgid="grand") result = obj.log("zero") self.assertEqual(result, "msg1") From c2b1fda4e7502c82b1b53fc5cbd8fba22e793d0c Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Fri, 7 Aug 2020 14:59:27 -0400 Subject: [PATCH 12/18] Add Ubuntu 20.04 --- .circleci/config.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d0f596fc7..dae9e904e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,10 +11,13 @@ workflows: requires: - "debian-9" - - "ubuntu-18.04" + - "ubuntu-20.04" + - "ubuntu-18.04": + requires: + - "ubuntu-20.04" - "ubuntu-16.04": requires: - - "ubuntu-18.04" + - "ubuntu-20.04" - "fedora-29" - "fedora-28": @@ -65,6 +68,7 @@ workflows: - "build-image-debian-9" - "build-image-ubuntu-16.04" - "build-image-ubuntu-18.04" + - "build-image-ubuntu-20.04" - "build-image-fedora-28" - "build-image-fedora-29" - "build-image-centos-8" @@ -268,6 +272,13 @@ jobs: user: "nobody" + ubuntu-20.04: + <<: *DEBIAN + docker: + - image: "tahoelafsci/ubuntu:20.04" + user: "nobody" + + centos-8: &RHEL_DERIV docker: - image: "tahoelafsci/centos:8" @@ -480,6 +491,14 @@ jobs: TAG: "18.04" + build-image-ubuntu-20.04: + <<: *BUILD_IMAGE + + environment: + DISTRO: "ubuntu" + TAG: "20.04" + + build-image-centos-8: <<: *BUILD_IMAGE From 083be5f0c834e2ca16791d53e49c0beb2916af6c Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Fri, 7 Aug 2020 14:59:45 -0400 Subject: [PATCH 13/18] news fragment --- newsfragments/3328.installation | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/3328.installation diff --git a/newsfragments/3328.installation b/newsfragments/3328.installation new file mode 100644 index 000000000..7b08ffdc4 --- /dev/null +++ b/newsfragments/3328.installation @@ -0,0 +1 @@ +Tahoe-LAFS now supports Ubuntu 20.04. \ No newline at end of file From fdfa95e1e8b5bbc2aeadd9b999cc5fb57515beea Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Mon, 10 Aug 2020 09:59:28 -0400 Subject: [PATCH 14/18] news fragment --- newsfragments/3375.minor | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newsfragments/3375.minor diff --git a/newsfragments/3375.minor b/newsfragments/3375.minor new file mode 100644 index 000000000..e69de29bb From 9853fa90904be82e71c7e9fd19d99d2177289bad Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Mon, 10 Aug 2020 09:59:36 -0400 Subject: [PATCH 15/18] Pin Python 2 compatible PyInstaller --- tox.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 4356cfd24..908d24d54 100644 --- a/tox.ini +++ b/tox.ini @@ -210,7 +210,9 @@ extras = deps = {[testenv]deps} packaging - pyinstaller + # PyInstaller 4.0 drops Python 2 support. When we finish porting to + # Python 3 we can reconsider this constraint. + pyinstaller < 4.0 # Setting PYTHONHASHSEED to a known value assists with reproducible builds. # See https://pyinstaller.readthedocs.io/en/stable/advanced-topics.html#creating-a-reproducible-build setenv=PYTHONHASHSEED=1 From 0f65d10f47abf761d27bd4fb1e12e4d442553472 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Tue, 11 Aug 2020 13:25:08 -0400 Subject: [PATCH 16/18] news fragment --- newsfragments/3323.removed | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/3323.removed diff --git a/newsfragments/3323.removed b/newsfragments/3323.removed new file mode 100644 index 000000000..356b4b2af --- /dev/null +++ b/newsfragments/3323.removed @@ -0,0 +1 @@ +Slackware 14.2 is no longer a Tahoe-LAFS supported platform. From a74ef86098c8a2e9676c226d6861903c2fac7a9d Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Tue, 11 Aug 2020 13:25:16 -0400 Subject: [PATCH 17/18] Remove the CI configuration --- .circleci/Dockerfile.slackware | 49 ---------------------------------- .circleci/config.yml | 31 --------------------- 2 files changed, 80 deletions(-) delete mode 100644 .circleci/Dockerfile.slackware diff --git a/.circleci/Dockerfile.slackware b/.circleci/Dockerfile.slackware deleted file mode 100644 index 73ba6b32d..000000000 --- a/.circleci/Dockerfile.slackware +++ /dev/null @@ -1,49 +0,0 @@ -ARG TAG -FROM vbatts/slackware:${TAG} - -ENV WHEELHOUSE_PATH /tmp/wheelhouse -ENV VIRTUALENV_PATH /tmp/venv -# This will get updated by the CircleCI checkout step. -ENV BUILD_SRC_ROOT /tmp/project - -# Be careful with slackpkg. If the package name given doesn't match anything, -# slackpkg still claims to succeed but you're totally screwed. Slackware -# updates versions of packaged software so including too much version prefix -# is a good way to have your install commands suddenly begin not installing -# anything. -RUN slackpkg update && \ - slackpkg install \ - openssh-7 git-2 \ - ca-certificates \ - sudo-1 \ - make-4 \ - automake-1 \ - kernel-headers \ - glibc-2 \ - binutils-2 \ - gcc-5 \ - gcc-g++-5 \ - python-2 \ - libffi-3 \ - libyaml-0 \ - sqlite-3 \ - icu4c-56 \ - libmpc-1 Date: Tue, 11 Aug 2020 14:54:12 -0400 Subject: [PATCH 18/18] Docstring. --- src/allmydata/immutable/happiness_upload.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/allmydata/immutable/happiness_upload.py b/src/allmydata/immutable/happiness_upload.py index a177660cc..9716aaef2 100644 --- a/src/allmydata/immutable/happiness_upload.py +++ b/src/allmydata/immutable/happiness_upload.py @@ -1,3 +1,9 @@ +""" +Algorithms for figuring out happiness, the number of unique nodes the data is +on. + +Ported to Python 3. +""" from __future__ import absolute_import from __future__ import division from __future__ import print_function