def updatePasswords(): global passwords newpw = {} fn = conf.get('main', 'basedir') + conf.get('main', 'pwfile') if os.path.isfile(fn): content = readFile(fn) for line in content: (nick, pw) = line.split() newpw[nick] = pw passwords = newpw
def updateAddresses(): global addresses newaddy = {} fn = conf.get('main', 'basedir') + conf.get('main', 'addressfile') if os.path.isfile(fn): content = readFile(fn) for line in content: (nick, addy) = line.split() newaddy[nick] = addy addresses = newaddy
def updatePayouts(): global payouts newpay = {} fn = conf.get('main', 'basedir') + conf.get('main', 'payoutsfile') if os.path.isfile(fn): content = readFile(fn) for line in content: (timestamp, nick, amount) = line.split() newpay[nick] = "%s %s" % (timestamp, amount) payouts = newpay
def populateAddresses(): global addys newaddys = {} fn = conf.get('main', 'basedir') + conf.get('main', 'addressfile') if os.path.isfile(fn): content = readFile(fn) for line in content: (n, a) = line.split() newaddys[n] = a addys = newaddys
def populateLogs(): global logs for file in glob.glob(conf.get('main', 'basedir') + \ conf.get('main', 'nicksdir') + '*'): if re.search('\.', file): continue (head, tail) = os.path.split(file) file = file + '/' + tail if os.path.isfile(file): logs[tail] = readFile(file)
def updateAddressFile(nick, address): addys = {} fn = conf.get('main', 'basedir') + conf.get('main', 'addressfile') writedir = os.path.dirname(fn) if os.path.isfile(fn): content = readFile(fn) for line in content: (n, a) = line.split() addys[n] = a addys[nick] = address with open(fn, "w+") as fw: fcntl.flock(fw.fileno(), fcntl.LOCK_EX) for key, value in addys.iteritems(): fw.write("%s %s\n" % (key, value)) fw.close() else: if not os.path.exists(writedir): os.makedirs(writedir) with open(fn, "a") as f: fcntl.flock(f.fileno(), fcntl.LOCK_EX) f.write("%s %s\n" % (nick, address)) f.close()
def updateAddressFile(nick, address): addys = {} fn = conf.get('main', 'basedir') + conf.get('main', 'addressfile') writedir = os.path.dirname(fn) if os.path.isfile(fn): content = readFile(fn) for line in content: (n, a) = line.split() addys[n] = a addys[nick] = address with open(fn,"w+") as fw: fcntl.flock(fw.fileno(), fcntl.LOCK_EX) for key, value in addys.iteritems(): fw.write("%s %s\n" % (key, value)) fw.close() else: if not os.path.exists(writedir): os.makedirs(writedir) with open(fn, "a") as f: fcntl.flock(f.fileno(), fcntl.LOCK_EX) f.write("%s %s\n" % (nick, address)) f.close()