43 lines
1.4 KiB
Python
Executable File
43 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify it under
|
|
# the terms of the GNU Lesser General Public License as published by the Free
|
|
# Software Foundation; either version 2 of the License, or (at your option) any
|
|
# later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
|
# details.
|
|
#
|
|
# You should have received a copy of the GNU Lesser General Public License along
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 51
|
|
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
#
|
|
# Copyright (C) 2014 Aleksander Morgado <aleksander@aleksander.es>
|
|
#
|
|
|
|
import sys, signal
|
|
import ModemWatcher
|
|
from gi.repository import GLib
|
|
|
|
main_loop = None
|
|
watcher = None
|
|
|
|
def signal_handler(data):
|
|
main_loop.quit()
|
|
|
|
if __name__ == "__main__":
|
|
# Create modem watcher
|
|
watcher = ModemWatcher.ModemWatcher()
|
|
|
|
# Main loop
|
|
main_loop = GLib.MainLoop()
|
|
GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGHUP, signal_handler, None)
|
|
GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGTERM, signal_handler, None)
|
|
try:
|
|
main_loop.run()
|
|
except KeyboardInterrupt:
|
|
pass
|