commnets bugfix
This commit is contained in:
parent
5fa45fbab9
commit
77082c62ca
12 changed files with 293 additions and 75 deletions
|
|
@ -31,7 +31,7 @@ class Buffer(object):
|
|||
system = {
|
||||
'00_config' : conf,
|
||||
'0_request' : [],
|
||||
'0_done' : [],
|
||||
'0_result' : [],
|
||||
'device' : {},
|
||||
'error' : error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ api_url = 'http://%s:%s' % (api_host, conf['flask_port'])
|
|||
#buf = Buffer()
|
||||
|
||||
class Request(object):
|
||||
|
||||
'''
|
||||
request definition for buffer
|
||||
'''
|
||||
def __init__(self, path, time, req_id):
|
||||
self.content = path
|
||||
self.time = time
|
||||
|
|
@ -86,10 +88,10 @@ class REST(object):
|
|||
del l[-1] # remove it
|
||||
out = self.buf.get_level(l)
|
||||
elif 'dyn' == l[-1]:
|
||||
args = request.args # returns a dictionary with a list of values for each key
|
||||
# each value and each key is represented as a string
|
||||
# to convert it to a dictionary use to_dict(flat=False)
|
||||
# to_dict(flat=True) returns the key and the first item of the value list.
|
||||
args = request.args.to_dict(flat=False) # returns a dictionary with a list of values for each key
|
||||
# each value and each key is represented as a string
|
||||
# to convert it to a dictionary use to_dict(flat=False)
|
||||
# to_dict(flat=True) returns the key and the first item of the value list.
|
||||
out = self.buf.foo(l, args)
|
||||
else:
|
||||
#req = add_reqest(path)
|
||||
|
|
@ -103,17 +105,20 @@ class REST(object):
|
|||
return jsonify( out )
|
||||
|
||||
def add_reqest(self, path):
|
||||
'''
|
||||
build a request and add it to list
|
||||
'''
|
||||
notinlist = False
|
||||
time = datetime.now()
|
||||
req_id = Buffer._id
|
||||
tmp = Request(path, time, req_id)
|
||||
try:
|
||||
Buffer.system['request'].index(tmp)
|
||||
Buffer.system['0_request'].index(tmp)
|
||||
except ValueError:
|
||||
notinlist = True
|
||||
|
||||
if notinlist:
|
||||
Buffer.system['request'].insert(0, tmp)
|
||||
Buffer.system['0_request'].insert(0, tmp)
|
||||
return id
|
||||
else:
|
||||
return False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue