You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
991 B

import socket
import logging
from etcd3_wrapper import EtcdEntry
class SpecificEtcdEntryBase(object):
def __init__(self, e: EtcdEntry):
self.key = e.key
for k in e.value.keys():
self.__setattr__(k, e.value[k])
def original_keys(self):
r = dict(self.__dict__)
del r["key"]
return r
def value(self):
return self.original_keys()
def __repr__(self):
return str(dict(self.__dict__))
def get_ipv4_address():
# If host is connected to internet
# Return IPv4 address of machine
# Otherwise, return
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
s.connect(("", 80))
except socket.timeout:
address = ""
except Exception as e:
address = ""
address = s.getsockname()[0]
return address