Minor code cleanup
[theonering] / src / theonering.py
index 58b00fe..9209162 100755 (executable)
@@ -34,7 +34,7 @@ import constants
 import connection_manager
 
 
-IDLE_TIMEOUT = 5000
+IDLE_TIMEOUT = 5
 
 
 def run_theonering(persist):
@@ -47,23 +47,23 @@ def run_theonering(persist):
                        raise
 
        @gobject_utils.async
-       def quit():
+       def on_quit():
                manager.quit()
                mainloop.quit()
 
        def timeout_cb():
                if len(manager._connections) == 0:
                        logging.info('No connection received - quitting')
-                       quit()
+                       on_quit()
                return False
 
        if persist:
                shutdown_callback = None
        else:
-               gobject.timeout_add(IDLE_TIMEOUT, timeout_cb)
-               shutdown_callback = quit
+               gobject_utils.timeout_add_seconds(IDLE_TIMEOUT, timeout_cb)
+               shutdown_callback = on_quit
 
-       signal.signal(signal.SIGTERM, quit)
+       signal.signal(signal.SIGTERM, lambda: on_quit)
 
        try:
                manager = connection_manager.TheOneRingConnectionManager(shutdown_func=shutdown_callback)
@@ -91,18 +91,22 @@ def main(logToFile):
        if logToFile:
                logging.basicConfig(
                        level=logging.DEBUG,
+                       filename=constants._user_logpath_,
                        format='(%(asctime)s) %(levelname)s:%(name)s:%(message)s',
                        datefmt='%H:%M:%S',
                )
        else:
-               logging.basicConfig(level=logging.DEBUG, filename=constants._user_logpath_)
+               logging.basicConfig(
+                       level=logging.DEBUG,
+                       format='(%(asctime)s) %(levelname)s:%(name)s:%(message)s',
+                       datefmt='%H:%M:%S',
+               )
        logging.info("telepathy-theonering %s-%s" % (constants.__version__, constants.__build__))
-       logging.info("OS: %s" % (os.uname()[0], ))
-       logging.info("Kernel: %s (%s) for %s" % os.uname()[2:])
-       logging.info("Hostname: %s" % os.uname()[1])
+       logging.debug("OS: %s" % (os.uname()[0], ))
+       logging.debug("Kernel: %s (%s) for %s" % os.uname()[2:])
+       logging.debug("Hostname: %s" % os.uname()[1])
 
        persist = 'THEONERING_PERSIST' in os.environ
-       persist = True
 
        try:
                run_theonering(persist)