remove some unused code from utils.py
This commit is contained in:
parent
ac7e7cd08b
commit
9cb0c00271
|
@ -29,7 +29,6 @@ class SignalException(Exception):
|
|||
class Signal:
|
||||
known_signals = []
|
||||
signal_stack = []
|
||||
default_signal = None
|
||||
|
||||
def register_signals(self, signals):
|
||||
if type(signals) is list:
|
||||
|
|
|
@ -148,32 +148,6 @@ def run_command(command, timeout=None, shell=False):
|
|||
return run_command_summarize(p, stdout, stderr)
|
||||
|
||||
|
||||
def sys_dev_path(devname, path=""):
|
||||
return SYS_CLASS_NET + devname + "/" + path
|
||||
|
||||
|
||||
def read_sys_net(devname, path, translate=None, enoent=None, keyerror=None):
|
||||
try:
|
||||
contents = ""
|
||||
with open(sys_dev_path(devname, path), "r") as fp:
|
||||
contents = fp.read().strip()
|
||||
if translate is None:
|
||||
return contents
|
||||
|
||||
try:
|
||||
return translate.get(contents)
|
||||
except KeyError:
|
||||
log.debug("found unexpected value '%s' in '%s/%s'", contents,
|
||||
devname, path)
|
||||
if keyerror is not None:
|
||||
return keyerror
|
||||
raise
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOENT and enoent is not None:
|
||||
return enoent
|
||||
raise
|
||||
|
||||
|
||||
# FIXME: replace with passlib and update package deps
|
||||
def crypt_password(passwd, algo='SHA-512'):
|
||||
# encryption algo - id pairs for crypt()
|
||||
|
@ -190,24 +164,6 @@ def crypt_password(passwd, algo='SHA-512'):
|
|||
return crypt.crypt(passwd, algos[algo] + salt)
|
||||
|
||||
|
||||
def is_root():
|
||||
""" Returns root or if sudo user exists
|
||||
"""
|
||||
euid = os.geteuid()
|
||||
|
||||
log.debug('is_root: euid={}'.format(euid))
|
||||
if euid != 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def sudo_user():
|
||||
""" Returns the value of env['SUDO_USER']
|
||||
"""
|
||||
sudo_user = os.getenv('SUDO_USER', None)
|
||||
return sudo_user
|
||||
|
||||
|
||||
def disable_first_boot_service():
|
||||
""" Stop firstboot service; which also restores getty service """
|
||||
log.info('disabling first boot service')
|
||||
|
|
Loading…
Reference in New Issue