new entry in config file : [profile] log : to show or not log in terminal

This commit is contained in:
Yann Leboulanger 2004-05-10 14:57:03 +00:00
parent ea6b541bb7
commit 3b25e64d8d
1 changed files with 24 additions and 11 deletions

View File

@ -37,10 +37,15 @@ LOGPATH = os.path.expanduser("~/.gajim/logs/")
class GajimCore: class GajimCore:
"""Core""" """Core"""
def __init__(self): def __init__(self):
self.log = 0
self.init_cfg_file() self.init_cfg_file()
self.cfgParser = common.optparser.OptionsParser(CONFPATH) self.cfgParser = common.optparser.OptionsParser(CONFPATH)
self.hub = common.hub.GajimHub() self.hub = common.hub.GajimHub()
self.parse() self.parse()
if self.log:
log.setLevel(logging.DEBUG)
else:
log.setLevel(None)
self.connected = {} self.connected = {}
#connexions {con: name, ...} #connexions {con: name, ...}
self.connexions = {} self.connexions = {}
@ -71,7 +76,7 @@ class GajimCore:
except: except:
print "creating %s" % fname print "creating %s" % fname
fic = open(fname, "w") fic = open(fname, "w")
fic.write("[Profile]\naccounts = \n\n[Core]\ndelauth = 1\nalwaysauth = 0\nmodules = logger gtkgui\ndelroster = 1\n") fic.write("[Profile]\naccounts = \nlog = 0\n\n[Core]\ndelauth = 1\nalwaysauth = 0\nmodules = logger gtkgui\ndelroster = 1\n")
fic.close() fic.close()
# END init_cfg_file # END init_cfg_file
@ -79,11 +84,15 @@ class GajimCore:
"""Parse configuratoin file and create self.accounts""" """Parse configuratoin file and create self.accounts"""
self.cfgParser.parseCfgFile() self.cfgParser.parseCfgFile()
self.accounts = {} self.accounts = {}
accts = string.split(self.cfgParser.tab['Profile']['accounts'], ' ') if self.cfgParser.tab.has_key('Profile'):
if accts == ['']: if self.cfgParser.tab['Profile'].has_key('log'):
accts = [] self.log = self.cfgParser.tab['Profile']['log']
for a in accts: if self.cfgParser.tab['Profile'].has_key('accounts'):
self.accounts[a] = self.cfgParser.tab[a] accts = string.split(self.cfgParser.tab['Profile']['accounts'], ' ')
if accts == ['']:
accts = []
for a in accts:
self.accounts[a] = self.cfgParser.tab[a]
def vCardCB(self, con, vc): def vCardCB(self, con, vc):
"""Called when we recieve a vCard """Called when we recieve a vCard
@ -183,10 +192,14 @@ class GajimCore:
proxy["port"] = self.cfgParser.tab[account]["proxyport"] proxy["port"] = self.cfgParser.tab[account]["proxyport"]
else: else:
proxy = None proxy = None
con = common.jabber.Client(host = hostname, \ if self.log:
debug = [], log = sys.stderr, \ con = common.jabber.Client(host = hostname, debug = [], \
# debug = [common.jabber.DBG_ALWAYS], log = sys.stderr, \ log = sys.stderr, connection=common.xmlstream.TCP, port=5222, \
proxy = proxy)
else:
con = common.jabber.Client(host = hostname, debug = [], log = None, \
connection=common.xmlstream.TCP, port=5222, proxy = proxy) connection=common.xmlstream.TCP, port=5222, proxy = proxy)
#debug = [common.jabber.DBG_ALWAYS], log = sys.stderr, \
#connection=common.xmlstream.TCP_SSL, port=5223, proxy = proxy) #connection=common.xmlstream.TCP_SSL, port=5223, proxy = proxy)
try: try:
con.connect() con.connect()
@ -362,8 +375,8 @@ class GajimCore:
proxy = {'host': ev[2][6], 'port': ev[2][7]} proxy = {'host': ev[2][6], 'port': ev[2][7]}
else: else:
proxy = None proxy = None
c = common.jabber.Client(host = \ c = common.jabber.Client(host = ev[2][0], debug = [], \
ev[2][0], debug = False, log = sys.stderr, proxy = proxy) log = None, proxy = proxy)
try: try:
c.connect() c.connect()
except IOError, e: except IOError, e: