fix log messages during installation/uninstallation

This commit is contained in:
2020-11-05 12:05:32 +01:00
parent 0cca75731c
commit f087ff61a3

View File

@@ -49,32 +49,32 @@ def _check_openrc():
def _copy_missing_file(src, dst): def _copy_missing_file(src, dst):
if os.path.exists(dst): if os.path.exists(dst):
logging.info(f"=> file {dst} already installed") logging.info(f" => file {dst} already installed")
else: else:
try: try:
logging.info(f"=> install file {dst}") logging.info(f" => install file {dst}")
shutil.copy2(src, dst) shutil.copy2(src, dst)
except Exception as e: except Exception as e:
logging.error(f"=> unable to install file {dst}: {e}") logging.error(f" => unable to install file {dst}: {e}")
def _delete_present_file(f): def _delete_present_file(f):
if os.path.isfile(f): if os.path.isfile(f):
try: try:
logging.info(f"=> uninstall file {f}") logging.info(f" => uninstall file {f}")
os.remove(f) os.remove(f)
except Exception as e: except Exception as e:
logging.error(f"=> unable to uninstall file {f}: {e}") logging.error(f" => unable to uninstall file {f}: {e}")
def _warn_exists(path): def _warn_exists(path):
if os.path.isdir(path): if os.path.isdir(path):
logging.warning( logging.warning(
f"=> directory {path} is still present, " f" => directory {path} is still present, "
f"you have to remove it manually") f"you have to remove it manually")
else: else:
logging.warning( logging.warning(
f"=> file {path} is still present, " f" => file {path} is still present, "
f"you have to remove it manually") f"you have to remove it manually")
@@ -99,13 +99,13 @@ def install(name):
logging.info("install configuration file") logging.info("install configuration file")
config_dir = f"/etc/{name}" config_dir = f"/etc/{name}"
if os.path.isdir(config_dir): if os.path.isdir(config_dir):
logging.info(f"=> directory {config_dir} exists already") logging.info(f" => directory {config_dir} exists already")
else: else:
try: try:
logging.info(f"=> create directory {config_dir}") logging.info(f" => create directory {config_dir}")
os.mkdir(config_dir) os.mkdir(config_dir)
except Exception as e: except Exception as e:
logging.error(f"=> unable to create directory {config_dir}: {e}") logging.error(f" => unable to create directory {config_dir}: {e}")
sys.exit(3) sys.exit(3)
files = [ files = [