summaryrefslogtreecommitdiffstats
path: root/curunir.py
blob: 6b6ed8ac3a8ee11c3bfad2cd6663bbcf2fd60c38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import signal, sys, traceback

from config import config
from modules import ModuleManager
from connection.xmpp import XMPPConnection


run = True

def exithandler(signum, frame):
    global run
    run = False

print 'Starting Curunir 0.1'

signal.signal(signal.SIGINT, exithandler)
signal.signal(signal.SIGTERM, exithandler)
signal.signal(signal.SIGQUIT, exithandler)

print 'Loading modules...'

modman = ModuleManager(config)

while run:
    connection = XMPPConnection(config, modman)
    print 'Connecting...'
    connection.connect()
    
    try:
        while run:
            act = connection.stream.loop_iter(1)
            if not act: 
                connection.idle() 
        
        connection.disconnect()
    except:
        traceback.print_exc(file=sys.stdout)
        connection.disconnect()