Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moves exit_UIP() from UIP.py to utils/utils.py #342

Merged
merged 1 commit into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to import send in this file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also SIGTERM

os.remove(pid_file)
print("\nExiting UIP hope you had a nice time :)")
sys.exit(0)