Skip to content

Commit

Permalink
moves exit_UIP() from UIP.py to utils/utils.py
Browse files Browse the repository at this point in the history
fixes issue #340
  • Loading branch information
SACHIN-13 committed Jan 25, 2017
1 parent c65ba6a commit c6583af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
14 changes: 2 additions & 12 deletions uiplib/UIP.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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)
13 changes: 13 additions & 0 deletions uiplib/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit c6583af

Please sign in to comment.