def main(): #TODO: check that yokadid is not already running for this database ? Not very harmful... #TODO: change unix process name to "yokadid" # Make the event list global to allow communication with main event loop global event (options, args) = parseOptions() if options.kill: killYokadid(options.filename) sys.exit(0) signal(SIGTERM, sigTermHandler) signal(SIGHUP, sigHupHandler) if not options.foreground: doubleFork() if not options.filename: options.filename = os.path.join(os.path.expandvars("$HOME"), ".yokadi.db") print "Using default database (%s)" % options.filename connectDatabase(options.filename, createIfNeeded=False) # Basic tests : if not (Task.tableExists() and Config.tableExists()): print "Your database seems broken or not initialised properly. Start yokadi command line tool to do it" sys.exit(1) # Start ical http handler if options.icalserver: yokadiIcalServer = YokadiIcalServer(options.tcpPort, options.tcpListen) yokadiIcalServer.start() # Start the main event Loop try: while event[1] != "SIGTERM": eventLoop() event[0] = True except KeyboardInterrupt: print "\nExiting..."