commit 6ea9e05e088b640e2ba69c3c125f3cc9ebe46802 Author: Damian Johnson atagar@torproject.org Date: Thu Jun 11 09:24:30 2015 -0700
Allow for tail() to do seeks relative to the end of files
Our tail() function had an issue where under python3 nyx's tests fail with...
====================================================================== ERROR: test_with_read_limit (util.log.read_tor_log.TestReadTorLog) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/atagar/Desktop/nyx/test/util/log/read_tor_log.py", line 28, in test_with_read_limit entries = list(read_tor_log(data_path('tor_log'), 5)) File "/home/atagar/Desktop/nyx/nyx/util/log.py", line 456, in read_tor_log for line in stem.util.system.tail(path, read_limit): File "/home/atagar/Desktop/nyx/stem/util/system.py", line 769, in tail for line in tail(target_file, lines): File "/home/atagar/Desktop/nyx/stem/util/system.py", line 785, in tail target.seek(block_number * BLOCK_SIZE, 2) io.UnsupportedOperation: can't do nonzero end-relative seeks
This is described on...
https://stackoverflow.com/questions/21533391/seeking-from-end-of-file-throwi...
Fix is trivial enough. :P --- stem/util/system.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stem/util/system.py b/stem/util/system.py index aa13cb9..4c5349b 100644 --- a/stem/util/system.py +++ b/stem/util/system.py @@ -765,7 +765,7 @@ def tail(target, lines = None): """
if isinstance(target, str): - with open(target) as target_file: + with open(target, 'rb') as target_file: for line in tail(target_file, lines): yield line
tor-commits@lists.torproject.org