From d05ad11855f3c8347033f716c154ffc15f6d1f5b Mon Sep 17 00:00:00 2001 From: Fillerino Date: Tue, 5 Sep 2017 20:56:29 +0200 Subject: [PATCH] Fixed indent and node running script. --- ansible-lighthouse/lighthouse.yml | 2 +- decoder/decoder.py | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ansible-lighthouse/lighthouse.yml b/ansible-lighthouse/lighthouse.yml index 93ddd71..649d786 100644 --- a/ansible-lighthouse/lighthouse.yml +++ b/ansible-lighthouse/lighthouse.yml @@ -16,4 +16,4 @@ - git: repo=https://github.com/lbryio/lighthouse.git dest=~/lighthouse - raw: cd ~/lighthouse/decoder && pip install -r requirements.txt && screen -S decoder -d -m python decoder.py && sleep 2 - raw: cd ~/lighthouse && yarn install --production=false && yarn global add forever - - raw: forever start -c "npm run prod" ~/lighthouse \ No newline at end of file + - raw: cd ~/lighthouse && yarn run build && cd dist && forever start index.js \ No newline at end of file diff --git a/decoder/decoder.py b/decoder/decoder.py index 4eeddfc..d6f7dd0 100644 --- a/decoder/decoder.py +++ b/decoder/decoder.py @@ -1,9 +1,12 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- import json from bitcoinrpc.authproxy import AuthServiceProxy from lbryschema.decode import smart_decode from flask import Flask, url_for app = Flask(__name__) + def get_lbrycrdd_connection_details(): with open('config.json', 'r') as f: config = json.load(f) @@ -11,13 +14,16 @@ def get_lbrycrdd_connection_details(): rpc_pass = config['rpc_password'] rpc_port = config['rpc_port'] rpc_url = config['rpc_url'] - return "http://%s:%s@%s:%i" % (rpc_user, rpc_pass, rpc_url, rpc_port) + return 'http://%s:%s@%s:%i' % (rpc_user, rpc_pass, rpc_url, + rpc_port) + @app.errorhandler(500) def internal_error(error): return 'error when decoding claims' + @app.route('/claim_decode//') def api_decode(txid, nout): connection_string = get_lbrycrdd_connection_details() @@ -29,21 +35,25 @@ def api_decode(txid, nout): claim = claim_out break if claim: - converted = "".join([chr(ord(i)) for i in claim['value']]) - decoded = smart_decode(converted) # Decode the claims and dump them back to logstash plugin + converted = ''.join([chr(ord(i)) for i in claim['value']]) + decoded = smart_decode(converted) claim['value'] = decoded.claim_dict return json.dumps(claim) + @app.route('/claim_decodeinv/') def api_decodebyclaim(claimid): connection_string = get_lbrycrdd_connection_details() rpc = AuthServiceProxy(connection_string) claim = rpc.getvalueforname(claimid) if claim: - converted = "".join([chr(ord(i)) for i in claim['value']]) - decoded = smart_decode(converted) # Decode the claims and dump them back to logstash plugin - claim['value'] = decoded.claim_dict + converted = ''.join([chr(ord(i)) for i in claim['value']]) + decoded = smart_decode(converted) + claim['value'] = decoded.claim_dict return json.dumps(claim) if __name__ == '__main__': - app.run(host='127.0.0.1') \ No newline at end of file + app.run(host='127.0.0.1') + + + \ No newline at end of file