Removed defunct utils that will probably never be used again
This commit is contained in:
parent
e9efffff34
commit
5ae5897703
@ -4,6 +4,7 @@ Onionr - Private P2P Communication
|
|||||||
We use built in logging but with a custom formatter for colors and such
|
We use built in logging but with a custom formatter for colors and such
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
from filepaths import log_file
|
from filepaths import log_file
|
||||||
"""
|
"""
|
||||||
@ -71,7 +72,7 @@ class FileFormatter(logging.Formatter):
|
|||||||
log = logging.getLogger('onionr')
|
log = logging.getLogger('onionr')
|
||||||
log.setLevel(logging.INFO)
|
log.setLevel(logging.INFO)
|
||||||
|
|
||||||
ch = logging.StreamHandler()
|
ch = logging.StreamHandler(sys.stdout)
|
||||||
ch.setLevel(logging.INFO)
|
ch.setLevel(logging.INFO)
|
||||||
|
|
||||||
ch.setFormatter(ConsoleFormatter())
|
ch.setFormatter(ConsoleFormatter())
|
||||||
|
@ -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
|
|
@ -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())
|
|
@ -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))
|
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys, os, random
|
import sys, os
|
||||||
sys.path.append(".")
|
sys.path.append(".")
|
||||||
sys.path.append("src/")
|
sys.path.append("src/")
|
||||||
import unittest, uuid
|
import unittest, uuid
|
||||||
@ -12,7 +12,7 @@ from utils import identifyhome, createdirs
|
|||||||
from onionrsetup import setup_config
|
from onionrsetup import setup_config
|
||||||
createdirs.create_dirs()
|
createdirs.create_dirs()
|
||||||
|
|
||||||
from onionrutils.escapeansi import escape_ANSI
|
from utils.escapeansi import escape_ANSI
|
||||||
|
|
||||||
class Colors:
|
class Colors:
|
||||||
""" ANSI color codes """
|
""" ANSI color codes """
|
||||||
@ -41,7 +41,7 @@ class Colors:
|
|||||||
CROSSED = "\033[9m"
|
CROSSED = "\033[9m"
|
||||||
END = "\033[0m"
|
END = "\033[0m"
|
||||||
|
|
||||||
class OnionrForwardSecrecyTests(unittest.TestCase):
|
class OnionrTestEscapeAnsi(unittest.TestCase):
|
||||||
def test_no_replace(self):
|
def test_no_replace(self):
|
||||||
msg = 'test message'
|
msg = 'test message'
|
||||||
self.assertEqual(escape_ANSI(msg), msg)
|
self.assertEqual(escape_ANSI(msg), msg)
|
||||||
|
Loading…
Reference in New Issue
Block a user