Sammlung
This commit is contained in:
37
Sammlung/Praktikum/3/ias_p2_a0.21/app/Neues Textdokument.txt
Normal file
37
Sammlung/Praktikum/3/ias_p2_a0.21/app/Neues Textdokument.txt
Normal file
@ -0,0 +1,37 @@
|
||||
# coding: utf-8
|
||||
|
||||
import os
|
||||
import time
|
||||
import codecs
|
||||
import json
|
||||
|
||||
from app import stream
|
||||
|
||||
class manager_cl(object):
|
||||
exposed = True
|
||||
|
||||
def __init__(self):
|
||||
self.stream = stream.stream_cl()
|
||||
|
||||
def LIST(self):
|
||||
#ausliefern der liste der Auktionen
|
||||
filelist = {}
|
||||
|
||||
filenames = os.listdir('data')
|
||||
for name in filenames:
|
||||
if name.endswith('.json'):
|
||||
charge = codecs.open(os.path.join('data', name), 'rU', 'utf-8')
|
||||
chargeData = charge.read()
|
||||
charge.close()
|
||||
|
||||
filelist[name]['chargeNr'] = name
|
||||
filelist[name]['chargeName'] = chargeData['info']['name']
|
||||
print(filelist)
|
||||
|
||||
def LOS(self, charge, los_nr):
|
||||
#gibt Daten vom Los zurück
|
||||
pass
|
||||
def RECEIVE(self, charge):
|
||||
#erhält Daten einer Charge und legt diese an oder überschreibt sie
|
||||
#wenn sie bereits existiert
|
||||
pass
|
3
Sammlung/Praktikum/3/ias_p2_a0.21/app/__init__.py
Normal file
3
Sammlung/Praktikum/3/ias_p2_a0.21/app/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# coding: utf-8
|
||||
|
||||
# hier können Paket-Initialisierungen eingetragen werden
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
33
Sammlung/Praktikum/3/ias_p2_a0.21/app/chargen.py
Normal file
33
Sammlung/Praktikum/3/ias_p2_a0.21/app/chargen.py
Normal file
@ -0,0 +1,33 @@
|
||||
# coding: utf-8
|
||||
|
||||
import time
|
||||
import codecs
|
||||
import json
|
||||
|
||||
from app import stream
|
||||
|
||||
class chargen_cl(object):
|
||||
exposed = True
|
||||
|
||||
chargenCounter = 1
|
||||
|
||||
def __init__(self):
|
||||
self.stream = stream.stream_cl()
|
||||
|
||||
def NEXT(self):
|
||||
if(self.chargenCounter > self.stream.anzChargen()):
|
||||
self.chargenCounter = 1
|
||||
|
||||
# timeout = 0
|
||||
# while(self.chargenCounter > self.stream.anzChargen()):
|
||||
# print(self.stream.anzChargen())
|
||||
# time.sleep(1)
|
||||
# timeout += 1
|
||||
# if(timeout > 3600):
|
||||
# return -1
|
||||
|
||||
newCharge = self.stream.loadCharge(self.chargenCounter)
|
||||
self.chargenCounter += 1
|
||||
|
||||
return json.dumps(newCharge)
|
||||
|
47
Sammlung/Praktikum/3/ias_p2_a0.21/app/log.py
Normal file
47
Sammlung/Praktikum/3/ias_p2_a0.21/app/log.py
Normal file
@ -0,0 +1,47 @@
|
||||
# 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)
|
35
Sammlung/Praktikum/3/ias_p2_a0.21/app/manager.py
Normal file
35
Sammlung/Praktikum/3/ias_p2_a0.21/app/manager.py
Normal file
@ -0,0 +1,35 @@
|
||||
# coding: utf-8
|
||||
|
||||
import os
|
||||
import time
|
||||
import codecs
|
||||
import json
|
||||
|
||||
from app import stream
|
||||
|
||||
class manager_cl(object):
|
||||
exposed = True
|
||||
|
||||
def __init__(self):
|
||||
self.stream = stream.stream_cl()
|
||||
|
||||
def LIST(self):
|
||||
chargenliste = {'1': {}, '2': {}}
|
||||
filenames = os.listdir('data')
|
||||
for filename in filenames:
|
||||
if filename.endswith('.json'):
|
||||
charge = codecs.open(os.path.join('data', filename), 'r', 'utf-8')
|
||||
chargeData = eval(charge.read())
|
||||
charge.close()
|
||||
|
||||
charge_id = filename[:-5]
|
||||
chargenliste[charge_id]['chargeName'] = chargeData['info']['name']
|
||||
print(chargenliste)
|
||||
return json.dumps(chargenliste)
|
||||
|
||||
|
||||
def LOS(self, charge, los_nr):
|
||||
pass
|
||||
|
||||
def RECEIVE(self, charge):
|
||||
pass
|
31
Sammlung/Praktikum/3/ias_p2_a0.21/app/stream.py
Normal file
31
Sammlung/Praktikum/3/ias_p2_a0.21/app/stream.py
Normal file
@ -0,0 +1,31 @@
|
||||
# coding: utf-8
|
||||
import os
|
||||
import os.path
|
||||
import codecs
|
||||
import json
|
||||
|
||||
class stream_cl(object):
|
||||
exposed = True
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def loadCharge(self, id):
|
||||
filename = str(id)
|
||||
filename += '.json'
|
||||
|
||||
file = codecs.open(os.path.join('data', filename), 'r', 'utf-8')
|
||||
charge = file.read()
|
||||
file.close()
|
||||
|
||||
return charge
|
||||
|
||||
def anzChargen(self):
|
||||
files = os.listdir('data')
|
||||
fileCounter = 0
|
||||
|
||||
for file in files:
|
||||
if file.endswith('.json'):
|
||||
fileCounter += 1
|
||||
|
||||
return fileCounter
|
55
Sammlung/Praktikum/3/ias_p2_a0.21/app/template.py
Normal file
55
Sammlung/Praktikum/3/ias_p2_a0.21/app/template.py
Normal file
@ -0,0 +1,55 @@
|
||||
# coding: utf-8
|
||||
|
||||
|
||||
#not planned
|
||||
|
||||
import json
|
||||
|
||||
import os
|
||||
import codecs
|
||||
|
||||
import cherrypy
|
||||
|
||||
# Method-Dispatching!
|
||||
|
||||
# Übersicht Anforderungen / Methoden
|
||||
# (beachte: / relativ zu /template, siehe Konfiguration Server!)
|
||||
|
||||
"""
|
||||
|
||||
Anforderung GET PUT POST DELETE
|
||||
----------------------------------------------------------------
|
||||
/ Alle - - -
|
||||
Templates
|
||||
liefern
|
||||
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------
|
||||
class Template_cl(object):
|
||||
#----------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self):
|
||||
#-------------------------------------------------------
|
||||
retVal_o = {
|
||||
'templates': {}
|
||||
}
|
||||
|
||||
files_a = os.listdir('templates/engine')
|
||||
for fileName_s in files_a:
|
||||
file_o = codecs.open(os.path.join('templates/engine', fileName_s), 'rU', 'utf-8')
|
||||
content_s = file_o.read()
|
||||
file_o.close()
|
||||
retVal_o["templates"][fileName_s] = content_s
|
||||
|
||||
return json.dumps(retVal_o)
|
||||
|
||||
# EOF
|
Reference in New Issue
Block a user