forked from protonphoton/LJ
[fix] small bugs
This commit is contained in:
parent
71bcd8ba68
commit
e6aa595b4b
@ -17,10 +17,12 @@ by cocoa
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import ast
|
||||||
|
import json
|
||||||
|
import os
|
||||||
import redis
|
import redis
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
argsparser = argparse.ArgumentParser(description="Redis exporter LJ")
|
argsparser = argparse.ArgumentParser(description="Redis exporter LJ")
|
||||||
@ -49,9 +51,12 @@ try:
|
|||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
line = line.rstrip('\n')
|
line = line.rstrip('\n')
|
||||||
line=line[1:-1]
|
line=line[1:-1]
|
||||||
line = line.replace("[",'(')
|
# Decode as list of lists
|
||||||
line = line.replace("]",')')
|
pointsList = ast.literal_eval(line)
|
||||||
line = "[{}]".format(line)
|
# convert to list of tuples
|
||||||
|
pointsList = [tuple(elem) for elem in pointsList]
|
||||||
|
# Convert to JSON string
|
||||||
|
line = json.dumps( pointsList )
|
||||||
if r.set(key,line)==True:
|
if r.set(key,line)==True:
|
||||||
debug("exports::redis set("+str(key)+") to "+line)
|
debug("exports::redis set("+str(key)+") to "+line)
|
||||||
except EOFError:
|
except EOFError:
|
||||||
|
@ -64,6 +64,7 @@ while True:
|
|||||||
# Convert to JSON string
|
# Convert to JSON string
|
||||||
line = json.dumps( pointsList )
|
line = json.dumps( pointsList )
|
||||||
debug(name,"Key:{} line:{}".format(key,line))
|
debug(name,"Key:{} line:{}".format(key,line))
|
||||||
|
# Output
|
||||||
print(line, flush=True);
|
print(line, flush=True);
|
||||||
looptime = time.time() - start
|
looptime = time.time() - start
|
||||||
if( looptime < optimal_looptime ):
|
if( looptime < optimal_looptime ):
|
||||||
|
Loading…
Reference in New Issue
Block a user