Removed defunct utils that will probably never be used again

This commit is contained in:
Kevin F 2022-09-27 19:06:18 +00:00
parent e9efffff34
commit 5ae5897703
7 changed files with 5 additions and 65 deletions

View File

@ -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())

View File

@ -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

View File

@ -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 <https://www.gnu.org/licenses/>.
"""
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())

View File

@ -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))

View File

@ -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)