diff --git a/uiplib/UIP.py b/uiplib/UIP.py index 4c84284..ab7754c 100644 --- a/uiplib/UIP.py +++ b/uiplib/UIP.py @@ -3,12 +3,12 @@ import sys import os -from daemoniker import Daemonizer, send, SIGTERM +from daemoniker import Daemonizer from uiplib.settings import ParseSettings, HOME_DIR from uiplib.scheduler import scheduler from uiplib.Wallpaper import Wallpaper -from uiplib.utils.utils import flush_wallpapers +from uiplib.utils.utils import flush_wallpapers, exit_UIP def main(): @@ -67,13 +67,3 @@ def main(): wallpaper) except KeyboardInterrupt: exit_UIP() - - -def exit_UIP(): - """Exit from UIP program.""" - pid_file = os.path.join(HOME_DIR, 'daemon-uip.pid') - if os.path.exists(pid_file): - send(pid_file, SIGTERM) - os.remove(pid_file) - print("\nExiting UIP hope you had a nice time :)") - sys.exit(0) diff --git a/uiplib/utils/utils.py b/uiplib/utils/utils.py index 0db7408..7fc9e65 100644 --- a/uiplib/utils/utils.py +++ b/uiplib/utils/utils.py @@ -4,6 +4,9 @@ import time import json import shutil +import sys + +from daemoniker import send, SIGTERM from uiplib.settings import HOME_DIR from uiplib.utils.setupUtils import make_dir @@ -54,3 +57,13 @@ def flush_wallpapers(folder): make_dir(folder) except FileNotFoundError: pass + + +def exit_UIP(): # pragma: no cover + """Exit from UIP program.""" + pid_file = os.path.join(HOME_DIR, 'daemon-uip.pid') + if os.path.exists(pid_file): + send(pid_file, SIGTERM) + os.remove(pid_file) + print("\nExiting UIP hope you had a nice time :)") + sys.exit(0)