corrected utils formatting and removed defunct utils
parent
b5e57da191
commit
2aa8cdbaa0
|
@ -28,7 +28,6 @@ from flask import Blueprint, Response, request, abort
|
|||
from onionrblocks import onionrblockapi
|
||||
import onionrexceptions
|
||||
from onionrutils import stringvalidators
|
||||
from utils import safezip
|
||||
from onionrutils import mnemonickeys
|
||||
from . import sitefiles
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
from onionrutils import localcommand
|
||||
import config
|
||||
config.reload()
|
||||
running_detected = False # if we know the api server is running
|
||||
first_get = True
|
||||
|
||||
def config_get(key):
|
||||
ret_data = False
|
||||
if running_detected or first_get:
|
||||
first_get = False
|
||||
ret_data = localcommand.local_command('/config/get/' + key)
|
||||
if ret_data == False:
|
||||
running_detected = False
|
||||
ret_data = config.get(key)
|
||||
else:
|
||||
running_detected = False
|
||||
return ret_data
|
|
@ -1,28 +0,0 @@
|
|||
'''
|
||||
Onionr - Private P2P Communication
|
||||
|
||||
Waits for a key to become set in a dictionary, even to None, 0 or empty string
|
||||
'''
|
||||
'''
|
||||
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/>.
|
||||
'''
|
||||
import time
|
||||
def define_wait(dictionary, key, delay: int = 0):
|
||||
while True:
|
||||
try:
|
||||
return dictionary[key]
|
||||
except KeyError:
|
||||
pass
|
||||
if delay > 0:
|
||||
time.sleep(delay)
|
|
@ -1,9 +1,9 @@
|
|||
'''
|
||||
Onionr - Private P2P Communication
|
||||
"""Onionr - Private P2P Communication.
|
||||
|
||||
Get the width of the terminal screen
|
||||
'''
|
||||
'''
|
||||
Get the width of the terminal screen
|
||||
"""
|
||||
import os
|
||||
"""
|
||||
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
|
||||
|
@ -16,12 +16,11 @@
|
|||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
import os
|
||||
def get_console_width():
|
||||
'''
|
||||
Returns an integer, the width of the terminal/cmd window
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
def get_console_width() -> int:
|
||||
"""Return the width of the terminal/cmd window."""
|
||||
|
||||
columns = 80
|
||||
|
||||
|
@ -31,4 +30,4 @@ def get_console_width():
|
|||
# if it errors, it's probably windows, so default to 80.
|
||||
pass
|
||||
|
||||
return columns
|
||||
return columns
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
'''
|
||||
Onionr - Private P2P Communication
|
||||
"""Onionr - Private P2P Communication.
|
||||
|
||||
Get the node's Tor hostname
|
||||
'''
|
||||
'''
|
||||
Get the node's Tor hostname
|
||||
"""
|
||||
"""
|
||||
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
|
||||
|
@ -16,9 +15,11 @@
|
|||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
"""
|
||||
from . import identifyhome
|
||||
import filepaths
|
||||
|
||||
|
||||
def get_hostname():
|
||||
try:
|
||||
with open(identifyhome.identify_home() + '/hs/hostname', 'r') as hostname:
|
||||
|
@ -26,4 +27,4 @@ def get_hostname():
|
|||
except FileNotFoundError:
|
||||
return "Not Generated"
|
||||
except Exception:
|
||||
return None
|
||||
return None
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
# safe unzip https://stackoverflow.com/a/36583849
|
||||
def safe_unzip(zip_file, extractpath='.'):
|
||||
with zipfile.ZipFile(zip_file, 'r') as zf:
|
||||
for member in zf.infolist():
|
||||
abspath = os.path.abspath(os.path.join(extractpath, member.filename))
|
||||
if abspath.startswith(os.path.abspath(extractpath)):
|
||||
zf.extract(member, extractpath)
|
|
@ -1 +1 @@
|
|||
1584769913
|
||||
1585025509
|
Loading…
Reference in New Issue