4 Telepathy-TheOneRing - Telepathy plugin for GoogleVoice
5 Copyright (C) 2009 Ed Page eopage AT byu DOT net
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 import telepathy.utils as telepathy_utils
31 import util.linux as linux_utils
32 import util.go_utils as gobject_utils
34 import connection_manager
40 def run_theonering(persist):
41 linux_utils.set_process_name(constants.__app_name__)
44 os.makedirs(constants._data_path_)
55 if len(manager._connections) == 0:
56 logging.info('No connection received - quitting')
61 shutdown_callback = None
63 gobject_utils.timeout_add_seconds(IDLE_TIMEOUT, timeout_cb)
64 shutdown_callback = on_quit
66 signal.signal(signal.SIGTERM, lambda: on_quit)
69 manager = connection_manager.TheOneRingConnectionManager(shutdown_func=shutdown_callback)
70 except dbus.exceptions.NameExistsException:
71 logging.warning('Failed to acquire bus name, connection manager already running?')
74 mainloop = gobject.MainLoop(is_running=True)
76 gobject.threads_init()
77 dbus.glib.init_threads()
78 while mainloop.is_running():
81 except KeyboardInterrupt:
87 os.makedirs(constants._data_path_)
92 telepathy_utils.debug_divert_messages(os.getenv('THEONERING_LOGFILE'))
93 logFormat = '(%(asctime)s) %(levelname)-5s %(threadName)s.%(name)s: %(message)s'
94 logging.raiseExceptions = True # Getting funky shutdown behavior, checking it out
98 filename=constants._user_logpath_,
108 logging.info("telepathy-theonering %s-%s" % (constants.__version__, constants.__build__))
109 logging.debug("OS: %s" % (os.uname()[0], ))
110 logging.debug("Kernel: %s (%s) for %s" % os.uname()[2:])
111 logging.debug("Hostname: %s" % os.uname()[1])
113 persist = 'THEONERING_PERSIST' in os.environ
116 run_theonering(persist)
121 if __name__ == "__main__":