opal/tasks/testt.py
anwinged 5e70da47dd heart is beating! tuk-tuk, tuk-tuk
Main engine has been finished, but needed to debug and refactoring
2012-04-07 06:22:54 +00:00

33 lines
638 B
Python

#! coding: utf-8
import sys
import json
import os
import time
def write(msg):
sys.stdout.write(msg + '\n')
sys.stdout.flush()
def main():
# try:
if sys.argv[1] == '-i':
with open('testt.json') as f:
d = json.load(f)
write(json.dumps(d, indent = 2))
elif sys.argv[1] == '-r':
textdata = raw_input()
#data = json.loads(data)
for i in xrange(10):
time.sleep(0.5)
write(json.dumps({ "hello": "world" }))
# except:
# print 'Error!'
# sys.exit(-1)
if __name__ == '__main__':
main()