Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
recompiled apps with new notifications on quit
Browse files Browse the repository at this point in the history
  • Loading branch information
pirate committed May 17, 2016
1 parent a0adced commit e3e4936
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
Binary file modified Security Growler Light.app.zip
Binary file not shown.
19 changes: 16 additions & 3 deletions Security Growler Light.app/Contents/Resources/growler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
# Nick Sweeting (github.com/pirate) 2016
# MIT License

import signal
import traceback

from sources import get_new_lines
from parsers import parse_line, get_sources_info
from loggers import notify, alert


def watch_sources():
"""runloop to parse events from sources and dispatch alerts"""
sources_info = '\n' + get_sources_info()
Expand All @@ -27,10 +29,21 @@ def watch_sources():
if alert_type == 'alert':
alert(content, title)


def quit_handler(signo, _stack_frame=None):
notify('Quit by user: got signal #%s' % signo, title='Stopped Watching Sources')
raise SystemExit(0)


if __name__ == "__main__":
signal.signal(signal.SIGTERM, quit_handler)
try:
watch_sources()
except KeyboardInterrupt:
quit_handler('CTRL-C')
except SystemExit:
raise
except BaseException as e:
notify(type(e).__name__, 'Stopped Watching Sources')
if isinstance(e, Exception):
traceback.print_exc()
# notify user protection has stopped at all costs, even if error is a SyntaxError
notify(traceback.format_exc(), title='Stopped Watching Sources: %s' % type(e).__name__)
raise
Binary file modified Security Growler.app.zip
Binary file not shown.
19 changes: 16 additions & 3 deletions Security Growler.app/Contents/Resources/growler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
# Nick Sweeting (github.com/pirate) 2016
# MIT License

import signal
import traceback

from sources import get_new_lines
from parsers import parse_line, get_sources_info
from loggers import notify, alert


def watch_sources():
"""runloop to parse events from sources and dispatch alerts"""
sources_info = '\n' + get_sources_info()
Expand All @@ -27,10 +29,21 @@ def watch_sources():
if alert_type == 'alert':
alert(content, title)


def quit_handler(signo, _stack_frame=None):
notify('Quit by user: got signal #%s' % signo, title='Stopped Watching Sources')
raise SystemExit(0)


if __name__ == "__main__":
signal.signal(signal.SIGTERM, quit_handler)
try:
watch_sources()
except KeyboardInterrupt:
quit_handler('CTRL-C')
except SystemExit:
raise
except BaseException as e:
notify(type(e).__name__, 'Stopped Watching Sources')
if isinstance(e, Exception):
traceback.print_exc()
# notify user protection has stopped at all costs, even if error is a SyntaxError
notify(traceback.format_exc(), title='Stopped Watching Sources: %s' % type(e).__name__)
raise
19 changes: 15 additions & 4 deletions growler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
# Nick Sweeting (github.com/pirate) 2016
# MIT License

import signal
import traceback

from sources import get_new_lines
from parsers import parse_line, get_sources_info
from loggers import notify, alert


def watch_sources():
"""runloop to parse events from sources and dispatch alerts"""
sources_info = '\n' + get_sources_info()
Expand All @@ -27,12 +29,21 @@ def watch_sources():
if alert_type == 'alert':
alert(content, title)


def quit_handler(signo, _stack_frame=None):
notify('Quit by user: got signal #%s' % signo, title='Stopped Watching Sources')
raise SystemExit(0)


if __name__ == "__main__":
signal.signal(signal.SIGTERM, quit_handler)
try:
watch_sources()
except KeyboardInterrupt:
quit_handler('CTRL-C')
except SystemExit:
raise
except BaseException as e:
if isinstance(e, Exception):
notify(traceback.format_exc(), title='Stopped Watching Sources: %s' % type(e).__name__)
else:
notify('Quit by user: %s' % type(e).__name__, title='Stopped Watching Sources')
# notify user protection has stopped at all costs, even if error is a SyntaxError
notify(traceback.format_exc(), title='Stopped Watching Sources: %s' % type(e).__name__)
raise

0 comments on commit e3e4936

Please sign in to comment.