def SaveBalance(balance, balancent, receipt_id): src = dhnio._read_data(settings.BalanceFile()) if src is None: src = '0.0 0.0 0' words = src.split(' ') try: b = words[0] b2 = words[1] r = words[2] except: b = '0.0' b2 = '0.0' r = '0' try: b = float(b) b2 = float(b2) r = int(r) except: b = 0.0 b2 = 0.0 r = 0 try: balanceV = float(balance) balancentV = float(balancent) receipt_idV = int(receipt_id) except: balanceV = 0.0 balancentV = 0.0 receipt_idV = 0 if receipt_idV >= r: src = '%f %f %d' % (balanceV, balancentV, receipt_idV) return dhnio._write_data(settings.BalanceFile(), src)
def connected_time(idurl): s = dhnio._read_data(os.path.join(rating_dir(idurl), 'connected')) if s == '': return 0 try: return time.mktime(time.strptime(s, '%d%m%y %H:%M:%S')) except: return 0
def LoadBalance(): src = dhnio._read_data(settings.BalanceFile()) if src is None: src = '0.0 0.0 0' dhnio._write_data(settings.BalanceFile(), src) words = src.split(' ') try: b = float(words[0]) b2 = float(words[1]) except: b = 0.0 b2 = 0.0 try: r = int(words[2]) except: r = 0 return b, b2, r