remove unused util functions
This commit is contained in:
parent
3dd7569d1f
commit
6e06214104
1 changed files with 1 additions and 29 deletions
30
oml/utils.py
30
oml/utils.py
|
@ -34,7 +34,7 @@ import logging
|
||||||
logging.getLogger('PIL').setLevel(logging.ERROR)
|
logging.getLogger('PIL').setLevel(logging.ERROR)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
ENCODING='base64'
|
ENCODING = 'base64'
|
||||||
|
|
||||||
def valid_olid(id):
|
def valid_olid(id):
|
||||||
return id.startswith('OL') and id.endswith('M')
|
return id.startswith('OL') and id.endswith('M')
|
||||||
|
@ -190,34 +190,6 @@ def get_service_id(private_key_file=None, cert=None):
|
||||||
service_id = base64.b32encode(hashlib.sha1(public_key).digest()[:10]).lower().decode()
|
service_id = base64.b32encode(hashlib.sha1(public_key).digest()[:10]).lower().decode()
|
||||||
return service_id
|
return service_id
|
||||||
|
|
||||||
def get_public_ipv6():
|
|
||||||
try:
|
|
||||||
host = ('2a01:4f8:120:3201::3', 25519)
|
|
||||||
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
|
||||||
s.settimeout(1)
|
|
||||||
s.connect(host)
|
|
||||||
ip = s.getsockname()[0]
|
|
||||||
s.close()
|
|
||||||
except:
|
|
||||||
ip = None
|
|
||||||
return ip
|
|
||||||
|
|
||||||
def get_interface():
|
|
||||||
interface = ''
|
|
||||||
if sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
|
|
||||||
#cmd = ['/usr/sbin/netstat', '-rn']
|
|
||||||
cmd = ['/sbin/route', '-n', 'get', 'default']
|
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
|
|
||||||
stdout, stderr = p.communicate()
|
|
||||||
stdout = stdout.decode('utf-8')
|
|
||||||
interface = [[p.strip() for p in s.split(':', 1)]
|
|
||||||
for s in stdout.strip().split('\n') if 'interface' in s]
|
|
||||||
if interface:
|
|
||||||
interface = '%%%s' % interface[0][1]
|
|
||||||
else:
|
|
||||||
interface = ''
|
|
||||||
return interface
|
|
||||||
|
|
||||||
def update_dict(root, data):
|
def update_dict(root, data):
|
||||||
for key in data:
|
for key in data:
|
||||||
keys = [part.replace('\0', '.') for part in key.replace('\\.', '\0').split('.')]
|
keys = [part.replace('\0', '.') for part in key.replace('\\.', '\0').split('.')]
|
||||||
|
|
Loading…
Reference in a new issue