def __init__(self, server_addr): try: if type(server_addr)==str : self.server=ServiceProxy("http://"+server_addr+"/") else : raise Exception("invalid paramater") except Exception as e: Exception("server offline")
def test_encoded_args(self): proxy = ServiceProxy(self.service_url) self.assertEquals('Hello No%20Space', proxy.jsonrpc.echo(name='No%20Space')['result']) self.assertEquals('Hello No+Space', proxy.jsonrpc.echo(name='No+Space')['result']) self.assertEquals('Hello No=Equal', proxy.jsonrpc.echo(name='No=Equal')['result'])
def test_decorators(self): for version in ['1.0', '1.1', '2.0']: proxy = ServiceProxy(self.service_url, version=version) [ self.assertEquals(resp, req['result']) for req, resp in [(proxy.jsonrpc.decorators('Flask JSON-RPC'), 'Hello Flask JSON-RPC')] ]
class JSONRPCTest(unittest.TestCase): def setUp(self): self.app = app.test_client() self.server = ServiceProxy('http://meowbook.org:5000/api/') def executeSQL(self, file, connection): file = open(file, 'r') sql = " ".join(file.readlines()) cur = connection.cursor() cur.execute(sql) connection.commit() file.close() def setNewDBData(self): conn = psycopg2.connect(user='******', database='template1') self.executeSQL('sql/DB.sql', conn) self.executeSQL('sql/DB_VALUES.sql', conn) def test_get_users(self): self.setNewDBData() s = self.server.get_users('root') # expected = {'id': '2fe4c96c-f4d6-4430-b23d-3ddbc67da184', 'jsonrpc': '2.0', 'result': {'0': {'name': 'root', 'nick': 'Koren', 'user_id': 0}}} self.assertEqual(s['result']['0']['nick'], 'Koren') # self.assertEqual(s['result']['1']['nick'], 'NeKoren') # print('--->', s, '<---', sep = '') def test_new_chat(self): self.setNewDBData() s = self.server.new_chat('NEWCHAT', True) tmp = self.server.get_chats() # print(tmp['result']) self.assertEqual(tmp['result']['1']['topic'], 'NEWCHAT') def test_new_message(self): self.setNewDBData() s = self.server.new_message(0, 0, 'Hello') # print(s) tmp = self.server.get_messages(0, 0) self.assertEqual(tmp['result']['0']['content'], 'Hello')
def test_positional_args(self): proxy = ServiceProxy(self.service_url) self.assert_(proxy.jsonrpc.echo()[u'result'] == 'Hello Flask JSON-RPC') try: proxy.jsonrpc.echo(name='Hello') except Exception, e: self.assert_(e.args[0] == 'Unsupported arg type for JSON-RPC 1.0 ' '(the default version for this client, ' 'pass version="2.0" to use keyword arguments)')
def test_positional_args(self): proxy = ServiceProxy(self.service_url, version='1.0') self.assertTrue( proxy.jsonrpc.echo()['result'] == 'Hello Flask JSON-RPC') try: proxy.jsonrpc.echo(name='Hello') except Exception as e: print(e.args) self.assertTrue( e.args[0] == 'Unsupport arg type for JSON-RPC 1.0 (the default version for this ' 'client, pass version="2.0" to use keyword arguments)')
def getQuoteValue(environ, start_response): form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) symbol = str(form.getvalue("quote")) server = ServiceProxy('http://localhost:5000/api') result = server.app.getStockQuote(symbol) r = "<ul style=\"list-style : none;\">" for key in result.keys(): if key == "result": r = str(result[key]) r += "</ul>" header = "<h1>Stock Quote for " + symbol + "</h1>" home_header = "<div><a href='/index.html'>Home</a></div>" start_response('200 OK', [('content-type', 'text/html')]) return ["<html><body>", header, r, home_header, "</body></html>"]
def wait_for_server_ready(time_out=10, interval=0.2): """ 阻塞等待数据服务启动 :param time_out: 超时时间 :param interval: 检测间隔 :return: """ secs = 0 while True: try: DataService.server = ServiceProxy( service_url="http://localhost:50000/api") DataService.server.api.index() break except Exception as e: secs += interval if secs >= time_out: Exception( f"data access server failed to start in {time_out} sec") else: sleep(interval) # TODO:log print("data access server started")
class Client: def __init__(self, server_addr): self.server_addr = server_addr self.server = ServiceProxy('http://' + server_addr + '/') def time(self): try: response = self.server.get_response('time').get('result') time_result = json.loads(response).get('time') return time_result except Exception as e: raise Exception("server offline") def ram(self): try: response = self.server.get_response('ram').get('result') total = int(json.loads(response).get('total')) used = int(json.loads(response).get('used')) return used, total except Exception as e: raise Exception("server offline") def hdd(self): try: response = self.server.get_response('hdd').get('result') total = int(json.loads(response).get('total')) used = int(json.loads(response).get('used')) return used, total except Exception as e: raise Exception("server offline") def add(self, a, b): if isinstance(a, int) and isinstance(b, int): try: response = self.server.get_add(a, b).get('result') response = int(json.loads(response)) return response except Exception as e: raise Exception("server offline") else: raise Exception("invalid paramater") def sub(self, a, b): if isinstance(a, int) and isinstance(b, int): try: response = self.server.get_sub(a, b).get('result') response = int(json.loads(response)) return response except Exception as e: raise Exception("server offline") else: raise Exception("invalid paramater") def json_to_xml(self, json_string): if (check_jsonstr(json_string)): try: response = self.server.get_xml(json_string).get('result') return response except Exception as e: raise Exception("server offline") else: raise Exception("invalid paramater")
if hasattr(args, "files") and not args.files: args.files = [] verbose = args.verbose config.update(args.__dict__) logger.info("Config: %s" % config) if args.dryrun: sys.exit(0) apiurl = "http://%s:5005/api" % config.get("serverIP", None) logger.info("Using service at %s" % apiurl) proxy = ServiceProxy(apiurl) apifunc = getattr(proxy.App, progname) params = parameters[progname].get('params', []) apiparams = {param: config.get(param, None) for param in params} if progname != "poll": print(apifunc) response = apifunc(**apiparams) retCode = print_response(response) if not config.get("poll", False): sys.exit(retCode) uuid = response['id']
def setUp(self): self.app = app.test_client() self.server = ServiceProxy('http://meowbook.org:5000/api/')
return True else: return False @jsonrpc.method('App.index', authenticated=check_auth) def index(): return u'Welcome to Flask JSON-RPC' @jsonrpc.method('App.echo(name=str) -> str', validate=True, authenticated=check_auth) def echo(name='Flask JSON-RPC'): return u'Hello {0}'.format(name) if __name__ == '__main__': app.run(host='0.0.0.0', debug=True) ###########json测试: #!/usr/bin/env python from flask_jsonrpc.proxy import ServiceProxy proxy = ServiceProxy('http://127.0.0.1:5000/api') print proxy.App.index('xiaoluo', '123') ##{u'jsonrpc': u'2.0', u'id': u'1e80bc94-494f-4b0b-9e22-9b30fb0c0d56', u'result': u'Welcome to Flask JSON-RPC'} print proxy.App.index() ##{u'jsonrpc': u'2.0', u'id': u'335c84d8-61e8-409a-bbec-201942d3599b', u'error': {u'executable': u'/usr/bin/python', u'code': -32602, u'name': u'InvalidParamsError', u'message': u'InvalidParamsError: Authenticated methods require at least [username, password] print proxy.App.echo(username='******', password='******', name='Flask') ##{u'jsonrpc': u'2.0', u'id': u'4f04fe80-24ec-47dd-af79-aaab979a6863', u'result': u'Hello Flask'}
def test_my_str(self): for version in ['1.0', '1.1', '2.0']: proxy = ServiceProxy(self.service_url, version=version) [ self.assertEquals(resp, req['result']) for req, resp in [(proxy.jsonrpc.echoMyStr('Hello Flask JSON-RPC'), 'Hello Flask JSON-RPC' ), (proxy.jsonrpc.echoMyStr('Hello Flask'), 'Hello Flask'), (proxy.jsonrpc.echoMyStr('Kolby Witaj JSON-RPC'), 'Kolby Witaj JSON-RPC'), (proxy.jsonrpc.echoMyStr('JSON-RPC قارورة مرحبا'), 'JSON-RPC قارورة مرحبا'), (proxy.jsonrpc.echoMyStr('Flask Բարեւ JSON-RPC'), 'Flask Բարեւ JSON-RPC'), (proxy.jsonrpc.echoMyStr('Настой Добры дзень JSON-RPC'), 'Настой Добры дзень JSON-RPC'), (proxy.jsonrpc.echoMyStr('বোতল হ্যালো JSON-RPC'), 'বোতল হ্যালো JSON-RPC'), (proxy.jsonrpc.echoMyStr('Čutura Hello JSON-RPC'), 'Čutura Hello JSON-RPC'), (proxy.jsonrpc.echoMyStr('Flascó Hola JSON-RPC'), 'Flascó Hola JSON-RPC' ), (proxy.jsonrpc.echoMyStr('瓶喂的JSON-RPC'), '瓶喂的JSON-RPC' ), (proxy.jsonrpc.echoMyStr('瓶餵的JSON-RPC'), '瓶餵的JSON-RPC'), (proxy.jsonrpc.echoMyStr('Baňka Hello JSON-RPC'), 'Baňka Hello JSON-RPC'), (proxy.jsonrpc.echoMyStr('Flakono Saluton JSON-RPC'), 'Flakono Saluton JSON-RPC'), (proxy.jsonrpc.echoMyStr('Kolb Tere JSON-RPC'), 'Kolb Tere JSON-RPC'), (proxy.jsonrpc.echoMyStr('Prasko Kamusta JSON-RPC'), 'Prasko Kamusta JSON-RPC'), (proxy.jsonrpc.echoMyStr('Pulloon Hei JSON-RPC'), 'Pulloon Hei JSON-RPC'), (proxy.jsonrpc.echoMyStr('Flacon Bonjour JSON-RPC'), 'Flacon Bonjour JSON-RPC'), (proxy.jsonrpc.echoMyStr('Hello Flask JSON-RPC'), 'Hello Flask JSON-RPC'), (proxy.jsonrpc.echoMyStr('Flask გამარჯობა JSON-RPC'), 'Flask გამარჯობა JSON-RPC'), (proxy.jsonrpc.echoMyStr('Hallo Flask JSON-RPC'), 'Hallo Flask JSON-RPC'), (proxy.jsonrpc.echoMyStr('Γεια Φιάλη JSON-RPC'), 'Γεια Φιάλη JSON-RPC'), (proxy.jsonrpc.echoMyStr('હેલો બાટલી JSON-RPC'), 'હેલો બાટલી JSON-RPC'), (proxy.jsonrpc.echoMyStr('Bonjou flakon JSON-RPC'), 'Bonjou flakon JSON-RPC'), (proxy.jsonrpc.echoMyStr('JSON-RPC שלום צפחת'), 'JSON-RPC שלום צפחת'), (proxy.jsonrpc.echoMyStr('हैलो फ्लास्क JSON-RPC'), 'हैलो फ्लास्क JSON-RPC'), (proxy.jsonrpc.echoMyStr('Halló flösku JSON-RPC'), 'Halló flösku JSON-RPC'), (proxy.jsonrpc.echoMyStr('こんにちはフラスコJSON-RPC'), 'こんにちはフラスコJSON-RPC'), (proxy.jsonrpc.echoMyStr('ಹಲೋ ಫ್ಲಾಸ್ಕ್ JSON-ಆರ್.ಪಿ.ಸಿ.'), 'ಹಲೋ ಫ್ಲಾಸ್ಕ್ JSON-ಆರ್.ಪಿ.ಸಿ.'), (proxy.jsonrpc.echoMyStr('ជំរាបសួរ Flask JSON-RPC'), 'ជំរាបសួរ Flask JSON-RPC'), (proxy.jsonrpc.echoMyStr('안녕하세요 플라스크 JSON-RPC'), '안녕하세요 플라스크 JSON-RPC'), (proxy.jsonrpc.echoMyStr('ສະບາຍດີ Flask JSON-RPC'), 'ສະບາຍດີ Flask JSON-RPC'), (proxy.jsonrpc.echoMyStr('Здраво Колба JSON-RPC'), 'Здраво Колба JSON-RPC'), (proxy.jsonrpc.echoMyStr('हॅलो चंबू JSON-RPC'), 'हॅलो चंबू JSON-RPC'), (proxy.jsonrpc.echoMyStr('Сайн байна уу колбонд JSON-RPC'), 'Сайн байна уу колбонд JSON-RPC'), (proxy.jsonrpc.echoMyStr('नमस्ते फ्लास्क जेएसओएन-RPC'), 'नमस्ते फ्लास्क जेएसओएन-RPC'), (proxy.jsonrpc.echoMyStr('خوش فلاسک JSON-RPC'), 'خوش فلاسک JSON-RPC'), (proxy.jsonrpc.echoMyStr('Olá Flask JSON-RPC'), 'Olá Flask JSON-RPC'), (proxy.jsonrpc.echoMyStr('ਹੈਲੋ ਕਿ ਫਲਾਸਕ JSON-RPC'), 'ਹੈਲੋ ਕਿ ਫਲਾਸਕ JSON-RPC'), (proxy.jsonrpc.echoMyStr('Здравствуйте Настой JSON-RPC'), 'Здравствуйте Настой JSON-RPC'), (proxy.jsonrpc.echoMyStr('Здраво Пљоска ЈСОН-РПЦ'), 'Здраво Пљоска ЈСОН-РПЦ'), (proxy.jsonrpc.echoMyStr('Dobrý deň, Banka JSON-RPC'), 'Dobrý deň, Banka JSON-RPC'), (proxy.jsonrpc.echoMyStr('Pozdravljeni Bučka JSON-RPC'), 'Pozdravljeni Bučka JSON-RPC'), (proxy.jsonrpc.echoMyStr('வணக்கம் குடுவை JSON-RPC'), 'வணக்கம் குடுவை JSON-RPC'), (proxy.jsonrpc.echoMyStr('హలో జాడీలో JSON-RPC'), 'హలో జాడీలో JSON-RPC'), (proxy.jsonrpc.echoMyStr('สวัสดีขวด JSON-RPC'), 'สวัสดีขวด JSON-RPC'), (proxy.jsonrpc.echoMyStr('Здравствуйте Настій JSON-RPC'), 'Здравствуйте Настій JSON-RPC'), (proxy.jsonrpc.echoMyStr('خوش فلاسک JSON-RPC'), 'خوش فلاسک JSON-RPC'), (proxy.jsonrpc.echoMyStr('Xin chào Bình JSON-RPC'), 'Xin chào Bình JSON-RPC'), (proxy.jsonrpc.echoMyStr('העלא פלאַסק דזשסאָן-רפּק'), 'העלא פלאַסק דזשסאָן-רפּק')] ]
def test_keyword_args(self): proxy = ServiceProxy(self.service_url, version='2.0') self.assert_(proxy.jsonrpc.echo(name='Flask')[u'result'] == 'Hello Flask') self.assert_(proxy.jsonrpc.echo('JSON-RPC')[u'result'] == 'Hello JSON-RPC')
def __init__(self, addr): self.server = ServiceProxy("http://" + addr)
class FsOcr: def __init__(self, ocr_docker_url): if not str(ocr_docker_url).startswith('http://'): ocr_docker_url = 'http://' + ocr_docker_url self.service = ServiceProxy('{}/session'.format(ocr_docker_url)) def img_from_url(self, url): r = requests.get(url, timeout=20).content return base64.b64encode(r).decode() def img_from_path(self, file_path): return base64.b64encode(open(file_path, 'rb').read()).decode() def ocr(self, file_path=None, url=None, binary_content=None, split_str='<br>'): if url is not None: img = self.img_from_url(url) elif file_path is not None: img = self.img_from_path(file_path) elif binary_content is not None: img = base64.b64encode(binary_content).decode() else: raise ValueError( 'You should set url or file_path or binary_content.') try: response = self.service.ocr(img) except: print('Error:url is {} , file_path is {}'.format(url, file_path)) response = list() text_list = list() try: # response有可能出现返回错误值 for j in response: if j['text'] != '': text_list.append(j['text']) except: text_list = [] # return '{}'.format(split_str).join(text_list) return ''.join(text_list) def ocr_list(self, file_path_list=None, url_list=None, binary_content_list=None, split_str='<br>'): img_list = list() if url_list is not None: for url in url_list: img = self.img_from_url(url) img_list.append(img) elif file_path_list is not None: for file_path in file_path_list: img = self.img_from_path(file_path) img_list.append(img) elif binary_content_list is not None: for binary_content in binary_content_list: img = base64.b64encode(binary_content).decode() img_list.append(img) else: raise ValueError( 'You should set url or file_path or binary_content.') response_list = self.service.ocr_list(img_list) obj = list() for response in response_list: text_list = list() for j in response: if j['text'] != '': text_list.append(j['text']) obj.append('{}'.format(split_str).join(text_list)) return obj def ocr_video(self, url=None, binary_content=None): r = self.service.ocr_video(url=url, binary_content=binary_content) if isinstance(r, dict) and 'error' in r.keys(): raise ValueError(r['error']['stack']) return r def speech_video(self, url=None, binary_content=None): r = self.service.speech_video(url=url, binary_content=binary_content) if isinstance(r, dict) and 'error' in r.keys(): raise ValueError(r['error']['stack']) return r def video_append(self, image_content, movie_content, download_path=None, cover_position='first', cover_hold_sec=2): print('开始执行视频添加图片首帧(尾帧)功能,正在执行中...') r = self.service.video_append(image_content=image_content, movie_content=movie_content, cover_position=cover_position, cover_hold_sec=cover_hold_sec) if isinstance(r, dict) and 'error' in r.keys(): raise ValueError(r['error']['stack']) if download_path is not None: with open(download_path, 'wb') as f: f.write(base64.b64decode(r)) print('添加图片首帧(尾帧)执行成功') return r def video_resize(self, movie_content, percent=None, resize=None, download_path=None): """ :param movie_content: [bytes] 视频二进制流 :param percent: [float]放缩比例,按0.5倍数相乘 :param resize: [tuple](width,height) :param download_path: [str] 下载路径 :return: [bytes] 返回的视频二进制流 """ print('开始执行视频等比例修改尺寸功能,正在执行中..') r = self.service.video_resize(movie_content=movie_content, percent=percent, resize=resize) if isinstance(r, dict) and 'error' in r.keys(): raise ValueError(r['error']['stack']) if download_path is not None: with open(download_path, 'wb') as f: f.write(base64.b64decode(r)) print('视频等比例修改尺寸功能执行成功') return r def get_video_size(self, movie_content): r = self.service.get_video_size(movie_content=movie_content) if isinstance(r, dict) and 'error' in r.keys(): raise ValueError(r['error']['stack']) return r def sr_picture(self, img_content, multiple=2, download_path=None): r = self.service.sr_picture(img_content=img_content, multiple=multiple) if isinstance(r, dict) and 'error' in r.keys(): raise ValueError(r['error']['stack']) if download_path is not None: with open(download_path, 'wb') as f: f.write(base64.b64decode(r)) return r
def test_method_repr(self): proxy = ServiceProxy(self.service_url) self.assertEqual('{"jsonrpc": "2.0", "method": "jsonrpc.echo"}', repr(proxy.jsonrpc.echo))
args = parser.parse_args() if args.AddScore: if not (args.AddScore[2] == "Easy" or args.AddScore[2] == "Medium" or args.AddScore[2] == "Hard"): parser.error("DIFFICULTY must be either Easy, Medium or Hard") try: args.AddScore[1] = int(args.AddScore[1]) except ValueError: parser.error("SCORE must be a number") init() #init colorama #Initialise JSON-RPC endpoint server = ServiceProxy('http://morganrobertson.net/LTLeaderBoard/api') # server = ServiceProxy('http://127.0.0.1:5000/api') failed_tests = False def random_generator(size=6, chars=string.ascii_uppercase): return ''.join(random.choice(chars) for x in range(size)) def test_index( ): # Establish basic call to API endpoint and time the connection. print( "Performing 'index' API call test. Ensure's basic API connectivity:") try: startTime = time.time()
from app import app, db_restrictions, responses from settings_local import FAUCET_CLI, CAPTCHA_SECRET from flask import request from flask_limiter import Limiter from flask_limiter.util import get_remote_address, get_ipaddr from flask_jsonrpc.proxy import ServiceProxy from flask_jsonrpc import exceptions import requests import traceback dblimits = db_restrictions.DatabaseRestrictions() limiter = Limiter(app, key_func=get_ipaddr) cli = ServiceProxy(FAUCET_CLI) asset_neo = "0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b" asset_gas = "0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7" asset_amount = app.config['DROP_AMOUNT'] limit_on = app.config['RATELIMIT_ENABLED'] @app.route('/api/request/', methods=['POST']) # restrict number of requests by IP - 1 request for IP per day # @limiter.limit("1 per day") def request_main(): # fetch captcha key and validate response = request.get_json() captcha_check = captcha_verify(response['g-recaptcha-response']) if not captcha_check["success"]: return responses.captcha_fail(captcha_check)
from flask_jsonrpc.proxy import ServiceProxy from lxml import objectify from ui.interface import Interface try: # open the constants folder to get the host and port necessary for client app to connect with open('../resources/constants.xml', 'r') as file: constants = objectify.fromstring(file.read()) # create the proxy service (connect to the service) service = ServiceProxy(service_url="http://{host}:{port}/api".format( host=str(constants.host), port=int(constants.port))) # run the interface Interface(service=service).run() except Exception as e: print(e)
def select_result(self, sql): address = self.service.get("Address") port = self.service.get("Port") server = ServiceProxy('http://{}:{}/'.format(address, port)) response = server.select_sql(sql).get('result') return response
def test_now4(self): server = ServiceProxy('http://localhost:5000/api') s = server.time.now() print(s) self.assertIn('result', s)
def __init__(self, server_addr): self.server_addr = server_addr self.server = ServiceProxy('http://' + server_addr + '/')
from flask import request, jsonify, Response from unittest import TestCase import testing.postgresql import psycopg2 import json from flask_jsonrpc.proxy import ServiceProxy import subprocess from app import app server = ServiceProxy('http://pomidorka.com:5000/api/') class AppTest(TestCase): class DB: def __init__(self, config): self.postgresql = testing.postgresql.Postgresql( name=config['db']['name'], port=int(config['db']['port']), base_dir=config['db']['path'], password=config['db']['password']) conn = psycopg2.connect(**self.postgresql.dsn()) self.sql_set_up = config['db']['sql_set_up'] self.sql_fill = config['db']['sql_fill'] self.sql_del = config['db']['sql_del'] self.runScript(self.sql_set_up, conn) self.runScript(self.sql_fill, conn) #self.runScript(self.sql_del, conn) self.app = app.test_client()
def __init__(self, url, name): self.url = url self.name = name self.server = ServiceProxy("{}/{}".format(self.url, self.name))
def test_keyword_args(self): proxy = ServiceProxy(self.service_url) self.assertEquals('Hello Flask', proxy.jsonrpc.echo(name='Flask')['result']) self.assertEquals('Hello JSON-RPC', proxy.jsonrpc.echo('JSON-RPC')['result'])
class Client: def __init__(self, addr): self.server = ServiceProxy("http://" + addr) def add(self, a, b): try: self.server.isConnected() except: raise Exception("server offline") if type(a) is not int or type(b) is not int: raise Exception("invalid parameter") res = self.server.add(a, b) return int(res['value']) def sub(self, a, b): try: self.server.isConnected() except: raise Exception("server offline") if type(a) is not int or type(b) is not int: raise Exception("invalid parameter") res = self.server.sub(a, b) return res['value'] def hdd(self): try: self.server.isConnected() except: raise Exception("server offline") res = self.server.hdd() a = int(res['total']) b = int(res['used']) return {a , b} def time(self): try: self.server.isConnected() except: raise Exception("server offline") res = self.server.time() return int(res['time']) def ram(self): try: self.server.isConnected() except: raise Exception("server offline") res = self.server.ram() return int(res['total']), int(res['used']) def json_to_xml(self, string): try: self.server.isConnected() except: raise Exception("server offline") if type(string) is not str: raise Exception("invalid parameter") try: json_object = json.loads(string) except: raise Exception("invalid parameter") res = self.server.json_to_xml(string) return str(res['value'].split('\'')[1])
from flask_jsonrpc.proxy import ServiceProxy server = ServiceProxy("http://localhost:5000/api") print(server.hello()) print(server.livre("Harry Potter"))
from flask_jsonrpc.proxy import ServiceProxy server = ServiceProxy('http://localhost:5000/api') s = server.time.now() print(s) print(s.get('result', '')) print(s.get('error', ''))
def __init__(self, ocr_docker_url): if not str(ocr_docker_url).startswith('http://'): ocr_docker_url = 'http://' + ocr_docker_url self.service = ServiceProxy('{}/session'.format(ocr_docker_url))