mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-06-16 18:19:40 +08:00
@@ -40,8 +40,23 @@ def printValue(value):
|
||||
logger.info(pretty_dump(value))
|
||||
|
||||
|
||||
def getFormat(result):
|
||||
reply = {}
|
||||
|
||||
value = json.loads(json.dumps(result))
|
||||
|
||||
try:
|
||||
value = ast.literal_eval(value)
|
||||
except:
|
||||
pass
|
||||
|
||||
reply['value'] = value
|
||||
|
||||
return reply
|
||||
|
||||
|
||||
def printError(error):
|
||||
|
||||
|
||||
reply = {}
|
||||
reply['error'] = "Got an error"
|
||||
|
||||
@@ -218,8 +233,8 @@ def run_cli():
|
||||
reply = {}
|
||||
value = args.data
|
||||
|
||||
logger.debug('Storing %s', value)
|
||||
key = coinkit.hex_hash160(value)
|
||||
logger.debug('Storing %s', value)
|
||||
|
||||
client = proxy.callRemote('set', key, value)
|
||||
|
||||
@@ -227,6 +242,7 @@ def run_cli():
|
||||
logger.debug('Get %s', args.hash)
|
||||
|
||||
client = proxy.callRemote('get', args.hash)
|
||||
client.addCallback(getFormat)
|
||||
|
||||
client.addCallback(printValue).addErrback(printError).addBoth(shutDown)
|
||||
reactor.run()
|
||||
|
||||
@@ -14,6 +14,7 @@ import os
|
||||
import sys
|
||||
import subprocess
|
||||
import signal
|
||||
import json
|
||||
|
||||
from txjsonrpc.netstring import jsonrpc
|
||||
from twisted.internet import reactor
|
||||
@@ -84,8 +85,9 @@ class OpennamedRPC(jsonrpc.JSONRPC):
|
||||
reply = {}
|
||||
|
||||
try:
|
||||
test_value = json.loads(json.dumps(value))
|
||||
except:
|
||||
test_value = json.loads(value)
|
||||
except Exception as e:
|
||||
print e
|
||||
reply['error'] = "value not JSON, not storing"
|
||||
return reply
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ from opennamed import OpennamedRPC
|
||||
|
||||
application = service.Application("opennamed")
|
||||
|
||||
factory_openname = jsonrpc.RPCFactory(OpennamedRPC())
|
||||
factory_openname = jsonrpc.RPCFactory(OpennamedRPC(dht_server))
|
||||
|
||||
server_openname = internet.TCPServer(OPENNAMED_PORT, factory_openname)
|
||||
server_openname.setServiceParent(application)
|
||||
|
||||
Reference in New Issue
Block a user