poezio/src/poezio.py

69 lines
1.9 KiB
Python
Raw Normal View History

2011-09-06 00:45:53 +00:00
# Copyright 2010-2011 Florent Le Coz <louiz@louiz.org>
2010-01-10 20:14:17 +00:00
#
# This file is part of Poezio.
#
# Poezio is free software: you can redistribute it and/or modify
2011-09-11 15:10:05 +00:00
# it under the terms of the zlib license. See the COPYING file.
2011-09-06 00:45:53 +00:00
2010-01-10 20:14:17 +00:00
2010-05-18 13:29:02 +00:00
"""
Starting point of poezio. Launches both the Connection and Gui
"""
2010-07-19 23:55:20 +00:00
import sys
2010-12-26 20:51:14 +00:00
import os
import signal
import logging
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import singleton
2011-03-07 18:57:55 +00:00
def main():
"""
Enter point
"""
import config
config_path = config.check_create_config_dir()
config.run_cmdline_args(config_path)
config.create_global_config()
config.check_create_log_dir()
config.setup_logging()
config.post_logging_setup()
from config import options
import logger
logger.create_logger()
import roster
roster.create_roster()
import core
log = logging.getLogger('')
signal.signal(signal.SIGINT, signal.SIG_IGN) # ignore ctrl-c
2011-03-07 18:57:55 +00:00
cocore = singleton.Singleton(core.Core)
signal.signal(signal.SIGUSR1, cocore.sigusr_handler) # reload the config
signal.signal(signal.SIGHUP, cocore.exit_from_signal)
signal.signal(signal.SIGTERM, cocore.exit_from_signal)
2014-01-30 17:23:44 +00:00
signal.signal(signal.SIGPIPE, cocore.exit_from_signal)
2012-10-13 13:14:34 +00:00
if options.debug:
cocore.debug = True
2011-03-07 18:57:55 +00:00
cocore.start()
try:
if not cocore.xmpp.start(): # Connect to remote server
cocore.on_failed_connection()
except:
cocore.running = False
cocore.reset_curses()
print("Poezio could not start, maybe you tried aborting it while it was starting?\n"
"If you think it is abnormal, please run it with the -d option and report the bug.")
else:
log.error('------------------------ new poezio start ------------------------')
cocore.main_loop() # Refresh the screen, wait for user events etc
2011-03-07 18:57:55 +00:00
if __name__ == '__main__':
main()