Minature bug fixes to help things progress along
[theonering] / src / telepathy-theonering
index a32d3db..6d08aaa 100755 (executable)
@@ -37,25 +37,31 @@ import connection_manager
 IDLE_TIMEOUT = 5000
 
 
 IDLE_TIMEOUT = 5000
 
 
-def run_theonering():
+def run_theonering(persist):
        linux_utils.set_process_name(constants.__app_name__)
 
        linux_utils.set_process_name(constants.__app_name__)
 
+       try:
+               os.makedirs(constants._data_path_)
+       except OSError, e:
+               if e.errno != 17:
+                       raise
+
        @gobject_utils.async
        def quit():
                manager.quit()
                mainloop.quit()
 
        @gobject_utils.async
        def quit():
                manager.quit()
                mainloop.quit()
 
+       def timeout_cb():
+               if len(manager._connections) == 0:
+                       logging.info('No connection received - quitting')
+                       quit()
+               return False
 
 
-       if 'BUTTERFLY_PERSIST' not in os.environ:
-               def timeout_cb():
-                       if len(manager._connections) == 0:
-                               logging.info('No connection received - quitting')
-                               quit()
-                       return False
+       if persist:
+               shutdown_callback = None
+       else:
                gobject.timeout_add(IDLE_TIMEOUT, timeout_cb)
                shutdown_callback = quit
                gobject.timeout_add(IDLE_TIMEOUT, timeout_cb)
                shutdown_callback = quit
-       else:
-               shutdown_callback = None
 
        signal.signal(signal.SIGTERM, quit)
 
 
        signal.signal(signal.SIGTERM, quit)
 
@@ -75,6 +81,13 @@ def run_theonering():
 
 
 if __name__ == '__main__':
 
 
 if __name__ == '__main__':
-       telepathy_utils.debug_divert_messages(os.getenv('BUTTERFLY_LOGFILE'))
+       telepathy_utils.debug_divert_messages(os.getenv('THEONERING_LOGFILE'))
        logging.basicConfig(level=logging.DEBUG)
        logging.basicConfig(level=logging.DEBUG)
-       run_theonering()
+       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])
+
+       persist = 'THEONERING_PERSIST' in os.environ
+       persist = True
+       run_theonering(persist)