From 5ae5897703410d3e0ed2ee7799403a94324fe9c6 Mon Sep 17 00:00:00 2001 From: Kevin F Date: Tue, 27 Sep 2022 19:06:18 +0000 Subject: [PATCH] Removed defunct utils that will probably never be used again --- src/logger/__init__.py | 3 ++- src/onionrutils/__init__.py | 0 src/onionrutils/bytesconverter.py | 16 ------------ src/onionrutils/epoch.py | 31 ------------------------ src/{onionrutils => utils}/escapeansi.py | 0 tests/integration-tests/details-test.py | 14 ----------- tests/test_escape_ansi.py | 6 ++--- 7 files changed, 5 insertions(+), 65 deletions(-) delete mode 100644 src/onionrutils/__init__.py delete mode 100644 src/onionrutils/bytesconverter.py delete mode 100644 src/onionrutils/epoch.py rename src/{onionrutils => utils}/escapeansi.py (100%) delete mode 100644 tests/integration-tests/details-test.py diff --git a/src/logger/__init__.py b/src/logger/__init__.py index 5e5e9b06..0d84d853 100755 --- a/src/logger/__init__.py +++ b/src/logger/__init__.py @@ -4,6 +4,7 @@ Onionr - Private P2P Communication We use built in logging but with a custom formatter for colors and such """ import logging +import sys from filepaths import log_file """ @@ -71,7 +72,7 @@ class FileFormatter(logging.Formatter): log = logging.getLogger('onionr') log.setLevel(logging.INFO) -ch = logging.StreamHandler() +ch = logging.StreamHandler(sys.stdout) ch.setLevel(logging.INFO) ch.setFormatter(ConsoleFormatter()) diff --git a/src/onionrutils/__init__.py b/src/onionrutils/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/onionrutils/bytesconverter.py b/src/onionrutils/bytesconverter.py deleted file mode 100644 index 66cbcc5b..00000000 --- a/src/onionrutils/bytesconverter.py +++ /dev/null @@ -1,16 +0,0 @@ -def str_to_bytes(data: str) -> bytes: - '''Convert a string to bytes with .encode(), utf8''' - try: - data = data.encode('UTF-8') - except AttributeError: - pass - return data - - -def bytes_to_str(data: bytes) -> str: - """Convert bytes to strings with .decode(), utf8""" - try: - data = data.decode('UTF-8') - except AttributeError: - pass - return data diff --git a/src/onionrutils/epoch.py b/src/onionrutils/epoch.py deleted file mode 100644 index 11bfc2cb..00000000 --- a/src/onionrutils/epoch.py +++ /dev/null @@ -1,31 +0,0 @@ -"""Onionr - Private P2P Communication. - -Get floored epoch, or rounded epoch -""" -import time -import math -""" -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" - - -def get_rounded_epoch(roundS=60) -> int: - """Return the epoch, rounded down to given seconds (Default 60).""" - epoch = get_epoch() - return epoch - (epoch % roundS) - - -def get_epoch() -> int: - """return epoch""" - return math.floor(time.time()) diff --git a/src/onionrutils/escapeansi.py b/src/utils/escapeansi.py similarity index 100% rename from src/onionrutils/escapeansi.py rename to src/utils/escapeansi.py diff --git a/tests/integration-tests/details-test.py b/tests/integration-tests/details-test.py deleted file mode 100644 index b8171423..00000000 --- a/tests/integration-tests/details-test.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys -import os -from subprocess import Popen, PIPE -import uuid - -TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' -os.environ["ONIONR_HOME"] = TEST_DIR - -print(f'running integration test for {__file__}') - -with Popen(['./onionr.sh', 'details'], stdout=PIPE) as onionr_proc: - output = onionr_proc.stdout.read().decode() -if onionr_proc.returncode != 0: - raise ValueError('Raised non zero exit ' + str(onionr_proc.returncode)) diff --git a/tests/test_escape_ansi.py b/tests/test_escape_ansi.py index b0cc8fc6..1009ddae 100644 --- a/tests/test_escape_ansi.py +++ b/tests/test_escape_ansi.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -import sys, os, random +import sys, os sys.path.append(".") sys.path.append("src/") import unittest, uuid @@ -12,7 +12,7 @@ from utils import identifyhome, createdirs from onionrsetup import setup_config createdirs.create_dirs() -from onionrutils.escapeansi import escape_ANSI +from utils.escapeansi import escape_ANSI class Colors: """ ANSI color codes """ @@ -41,7 +41,7 @@ class Colors: CROSSED = "\033[9m" END = "\033[0m" -class OnionrForwardSecrecyTests(unittest.TestCase): +class OnionrTestEscapeAnsi(unittest.TestCase): def test_no_replace(self): msg = 'test message' self.assertEqual(escape_ANSI(msg), msg)