diff options
author | Yann Leboulanger <asterix@lagaule.org> | 2004-05-10 18:57:03 +0400 |
---|---|---|
committer | Yann Leboulanger <asterix@lagaule.org> | 2004-05-10 18:57:03 +0400 |
commit | 3b25e64d8d51577bc612ed4b99ad6eb88559240f (patch) | |
tree | e6009c44c868a13514800840b20d236d3d86e3c4 /core | |
parent | ea6b541bb79a82c5492b7023b0a58dba518ea60c (diff) |
new entry in config file : [profile] log : to show or not log in terminal
Diffstat (limited to 'core')
-rw-r--r-- | core/core.py | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/core/core.py b/core/core.py index 6aa4a02b0..6008f60a1 100644 --- a/core/core.py +++ b/core/core.py @@ -37,10 +37,15 @@ LOGPATH = os.path.expanduser("~/.gajim/logs/") class GajimCore: """Core""" def __init__(self): + self.log = 0 self.init_cfg_file() self.cfgParser = common.optparser.OptionsParser(CONFPATH) self.hub = common.hub.GajimHub() self.parse() + if self.log: + log.setLevel(logging.DEBUG) + else: + log.setLevel(None) self.connected = {} #connexions {con: name, ...} self.connexions = {} @@ -71,7 +76,7 @@ class GajimCore: except: print "creating %s" % fname 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() # END init_cfg_file @@ -79,11 +84,15 @@ class GajimCore: """Parse configuratoin file and create self.accounts""" self.cfgParser.parseCfgFile() self.accounts = {} - accts = string.split(self.cfgParser.tab['Profile']['accounts'], ' ') - if accts == ['']: - accts = [] - for a in accts: - self.accounts[a] = self.cfgParser.tab[a] + if self.cfgParser.tab.has_key('Profile'): + if self.cfgParser.tab['Profile'].has_key('log'): + self.log = self.cfgParser.tab['Profile']['log'] + if self.cfgParser.tab['Profile'].has_key('accounts'): + 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): """Called when we recieve a vCard @@ -183,10 +192,14 @@ class GajimCore: proxy["port"] = self.cfgParser.tab[account]["proxyport"] else: proxy = None - con = common.jabber.Client(host = hostname, \ - debug = [], log = sys.stderr, \ -# debug = [common.jabber.DBG_ALWAYS], log = sys.stderr, \ + if self.log: + con = common.jabber.Client(host = hostname, debug = [], \ + 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) + #debug = [common.jabber.DBG_ALWAYS], log = sys.stderr, \ #connection=common.xmlstream.TCP_SSL, port=5223, proxy = proxy) try: con.connect() @@ -362,8 +375,8 @@ class GajimCore: proxy = {'host': ev[2][6], 'port': ev[2][7]} else: proxy = None - c = common.jabber.Client(host = \ - ev[2][0], debug = False, log = sys.stderr, proxy = proxy) + c = common.jabber.Client(host = ev[2][0], debug = [], \ + log = None, proxy = proxy) try: c.connect() except IOError, e: |