moved config to a file, the config module now looks in ~/.brathuhn.cfg,

$CWD/brathuhn.cfg and /etc/brathuhn/config.cfg
An example config-file:
[Account]
NAME = brathuhn
SRV  = n0g.at
PWD = secret

[Conference]
ROOM = gladio@conference.n0g.at
PWD_ROOM = terces

;ROOM = debug@conference.n0g.at
;PWD_ROOM = this is a comment
master
Stefan Krulj 14 years ago
parent 2b6537104d
commit 882ec95e0a
  1. 4
      brathuhn.py
  2. 20
      config.py

@ -205,7 +205,7 @@ def connect_and_join():
con=cl.connect() con=cl.connect()
if not con: if not con:
print 'could not connect!' print 'could not connect!'
raise 'could not connect!' raise Exception('could not connect!')
print 'connected' print 'connected'
cl.RegisterHandler('message',__messageCB) cl.RegisterHandler('message',__messageCB)
@ -215,7 +215,7 @@ def connect_and_join():
auth=cl.auth(NAME,PWD,resource=jid.getResource()) auth=cl.auth(NAME,PWD,resource=jid.getResource())
if not auth: if not auth:
print 'could not authenticate!' print 'could not authenticate!'
raise 'could not authenticate!' raise Exception('could not authenticate!')
print 'auth' print 'auth'

@ -1,9 +1,15 @@
NAME = "brathuhn" from ConfigParser import ConfigParser
SRV = "n0g.at" import os
PWD = "123huhn"
ROOM = "gladio@conference.n0g.at" cp = ConfigParser()
PWD_ROOM = "secret" cp.read(["/etc/brathuhn/config.cfg","brathuhn.cfg",os.path.expanduser('~/.brathuhn.cfg')])
NAME = cp.get("Account","NAME")
SRV = cp.get("Account","SRV")
PWD = cp.get("Account","PWD")
ROOM = cp.get("Conference","ROOM")
PWD_ROOM = cp.get("Conference","PWD_ROOM")
print NAME,SRV
#ROOM = "debug@conference.n0g.at"
#PWD_ROOM = ""

Loading…
Cancel
Save