47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
# coding: utf-8
|
|
|
|
import os
|
|
import time
|
|
import codecs
|
|
import json
|
|
|
|
from app import stream
|
|
|
|
class log_cl(object):
|
|
exposed = True
|
|
|
|
def __init__(self):
|
|
self.stream = stream.stream_cl()
|
|
|
|
def SEND(self, user, charge, los, preis):
|
|
|
|
file = codecs.open(os.path.join('data', 'log.txt'), 'r', 'utf-8')
|
|
log = json.loads(file.read())
|
|
file.close()
|
|
|
|
counter = 1
|
|
|
|
for x in log:
|
|
counter += 1
|
|
|
|
counter = str(counter)
|
|
|
|
log[counter] = {}
|
|
log[counter]['user'] = user
|
|
log[counter]['charge'] = charge
|
|
log[counter]['los'] = los
|
|
log[counter]['preis'] = preis
|
|
log[counter]['time'] = time.time()
|
|
|
|
print(log)
|
|
|
|
file = codecs.open(os.path.join('data', 'log.txt'), 'w', 'utf-8')
|
|
file.write(json.dumps(log, indent=3, ensure_ascii=True))
|
|
file.close()
|
|
|
|
def REQ(self):
|
|
file = codecs.open(os.path.join('data', 'log.txt'), 'r', 'utf-8')
|
|
log = json.loads(file.read())
|
|
file.close()
|
|
|
|
return json.dumps(log) |