Beispiel #1
0
#!/usr/bin/python

import jsonrpc
import socket

#rpc = jsonrpc.ServerProxy(jsonrpc.JsonRpc20(), jsonrpc.TransportSocket(addr="/tmp/testservice", sock_type=socket.AF_UNIX))
rpc = jsonrpc.ServerProxy(jsonrpc.JsonRpc20(),
                          jsonrpc.TransportSocket(addr=("127.0.0.1", 11111)))
print "Hi, " + rpc.bridge.getPeerName(rpc.bridge.getOwnId())
Beispiel #2
0
# create JSON-RPC client
import jsonrpc
import time
import checklines_pi

server = jsonrpc.ServerProxy(jsonrpc.JsonRpc20(), jsonrpc.TransportTcpIp(addr=("127.0.0.1", 31415)))

# call a remote-procedure (with positional parameters)



import os

host = 'LOCALHOST'
port = 8080

time.sleep(1)

try:
    while 1:
        testVar = raw_input("Enter Command: ")
        if testVar=="report":
            result=server.getreport()
        elif testVar=="1":
            result = server.sendcommand("opengrab#A")
        elif testVar=="2":
            result = server.sendcommand("closegrabA")
        elif testVar=="3":
            result = server.sendcommand("turnslow#0500A")
        elif testVar=="4":
            result = server.sendcommand("turnslow#2500A")
    training_data["sentiment"]]
tag_collection = t_connection[training_data["db"]][training_data["tag"]]
food_collection = t_connection[training_data["db"]][training_data["food"]]
service_collection = t_connection[training_data["db"]][
    training_data["service"]]
cost_collection = t_connection[training_data["db"]][training_data["cost"]]
ambience_collection = t_connection[training_data["db"]][
    training_data["ambience"]]
corenlp_collection = t_connection[corenlp_data["db"]][
    corenlp_data["sentiment"]]

import sys
print corenlp_data["path_jar_files"]
sys.path.append(corenlp_data["path_jar_files"])
with cd(corenlp_data["path_jar_files"]):
    import jsonrpc
    corenlpserver = jsonrpc.ServerProxy(
        jsonrpc.JsonRpc20(),
        jsonrpc.TransportTcpIp(addr=(corenlp_data["ip"],
                                     corenlp_data["port"])))


class bcolors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    RESET = '\033[0m'
Beispiel #4
0
#!/usr/bin/python

import jsonrpc
import socket

rpc = jsonrpc.ServerProxy(
    jsonrpc.JsonRpc20(),
    jsonrpc.TransportSocket(addr="/tmp/testservice", sock_type=socket.AF_UNIX))
print rpc.agent.testMethod()
print rpc.agent.testMethodWithParams("one", False, 10)
print rpc.agent.testMethodWithParamsAndReturnValue("matt")
 def get_server(self, hostname='localhost', port=3456, timeout=300.0):
     version = jsonrpc.JsonRpc20()
     transport = jsonrpc.TransportTcpIp(addr=(hostname, port), timeout=timeout)
     server = jsonrpc.ServerProxy(version, transport)
     return server
Beispiel #6
0
    def __init__(self, transport):

        self._timing = 0
        # default for USB
        self.proxy = jsonrpc.ServerProxy(jsonrpc.JsonRpc20(), transport)
from collections import Counter
from scipy.spatial.distance import cosine
import networkx as nx
import en
import sys
from operator import itemgetter
import csv

reload(sys)
sys.setdefaultencoding('utf-8')

# Normalization and cleaning engine
cucco = Cucco()

# Connect to core nLP server
coref_server = jsonrpc.ServerProxy(
    jsonrpc.JsonRpc20(), jsonrpc.TransportTcpIp(addr=("127.0.0.1", 8080)))
dep_server = jsonrpc.ServerProxy(
    jsonrpc.JsonRpc20(), jsonrpc.TransportTcpIp(addr=("127.0.0.2", 8080)))

normalizations = [
    'remove_accent_marks',
    ('replace_urls', {
        'replacement': ''
    }),
    ('replace_emails', {
        'replacement': ''
    }),
    'remove_extra_whitespaces',
]

rep = {
Beispiel #8
0
def coref_resolution(text):
    server = jsonrpc.ServerProxy(
        jsonrpc.JsonRpc20(), jsonrpc.TransportTcpIp(addr=("127.0.0.1", 8080)))

    result = loads(server.parse(text))
    return result
Beispiel #9
0
 def __init__(self):
     self.server = jsonrpc.ServerProxy(
         jsonrpc.JsonRpc20(),
         jsonrpc.TransportTcpIp(addr=("128.10.4.66", 4056)))
Beispiel #10
0
from nltk.tree import *
import jsonrpc
from simplejson import loads
import subprocess as sp
from lstm import *

#Connecting to nltk server
server = jsonrpc.ServerProxy(jsonrpc.JsonRpc20(),
                             jsonrpc.TransportTcpIp(addr=("0.0.0.0", 3456)))


#Function to get noun list
def getNoun(noun):
    nlist = []
    for i in noun.subtrees():
        if (i.label() == "NN"):
            np = " ".join(i.leaves())
            nlist.append(np)
    return nlist


def init(cmdDict, cmd):
    #Training the new model
    sls = lstm("bestsem.p", load=True, training=True)
    print "Pre training "
    train = pickle.load(open("myTrain3.p", 'rb'))
    sls.train_lstm(train, 75)
    #Loading the command dictionary
    f = open("commands.csv")
    line = f.read().splitlines()
    for x in line:
Beispiel #11
0
# Cambrionix Ltd - 2015
# cbrxapi.py
# @version $Id: cbrxapi.py 980 2015-09-23 12:38:06Z arno.brevoort $
#
# This is sample software provided to you without implied warranty of any sort.
# You are free to use and adapt this for your own use.

import jsonrpc

CBRXAPI_ERRORCODE_DROPPED = -10007
CBRXAPI_ERRORCODE_TIMEOUT = -10006
CBRXAPI_ERRORCODE_INVALIDHANDLE = -10005
CBRXAPI_ERRORCODE_ERRORSETTINGVALUE = -10004
CBRXAPI_ERRORCODE_KEYNOTFOUND = -10003
CBRXAPI_ERRORCODE_NOHANDLINGTHREAD = -10002
CBRXAPI_ERRORCODE_IDNOTFOUND = -10001

CBRXAPI_LISTENINGPORT = -1

try:
    f = open('/usr/local/share/cbrxd/config/listeningport')
    CBRXAPI_LISTENINGPORT = int(f.read())
    f.close
except:
    CBRXAPI_LISTENINGPORT = 43424

cbrxapi = jsonrpc.ServerProxy(
    jsonrpc.JsonRpc20(),
    jsonrpc.TransportTcpIp(addr=("localhost", CBRXAPI_LISTENINGPORT),
                           timeout=200.0))
Beispiel #12
0
import urllib2
# import warehouse_scraper
from flask import Flask, request, redirect, url_for, \
     abort, render_template, flash, make_response, jsonify # clean these up
from nltk.corpus import wordnet as wn


app = Flask(__name__)
app.config.from_object(__name__)

app.config.from_envvar('FLASKR_SETTINGS', silent=True)

pp = pprint.PrettyPrinter(indent=4)

SCENE_FILE = "../Descriptions/first_demo.txt"
server = jsonrpc.ServerProxy(jsonrpc.JsonRpc20(),
        jsonrpc.TransportTcpIp(addr=("http://104.236.90.178/", 80)))
print "SERVER"
print server
f = {}
# scenes = [f for f in open(SCENE_FILE).read().split('\n') if f != '']
@app.route('/', methods=['POST'])
def get_entities():
# for scene in scenes:
    print 'here'
    global f
    scene = request.json['text']
    print scene
    print "\n"
    result = loads(server.parse(scene))
    entities = {}
    deps = []
Beispiel #13
0
from simplejson import loads

from tornado.options import define, options

define("port", default=8888, help="run on the given port", type=int)
define("corenlpPort",
       default=5985,
       help="port to connect with corenlp",
       type=int)
define("host",
       default="127.0.0.1",
       help="host where corenlp is running",
       type=str)

server = jsonrpc.ServerProxy(
    jsonrpc.JsonRpc20(),
    jsonrpc.TransportTcpIp(addr=(options.host, options.corenlpPort)))


class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write({'status': 'FAILED', 'result': 'GET Not Implemented'})

    def post(self):
        try:
            input = loads(self.request.body)
            result = server.tokenize(input)
            self.write(result)
        except ValueError:
            self.write({
                'status': 'FAILED',
 def __init__(self, host="127.0.0.1", port=8080):
     self.server = jsonrpc.ServerProxy(
         jsonrpc.JsonRpc20(), jsonrpc.TransportTcpIp(addr=(host, port)))
Beispiel #15
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Sample python file to call rpc functions to the navc daemon. It should be called
from the test directory as:
  PYTHONPATH=../third_party/jsonrpc/ python client.py
"""

import jsonrpc

server = jsonrpc.ServerProxy(
    jsonrpc.JsonRpc10(),
    jsonrpc.TransportUnixSocket(addr='/tmp/navc.sock',
                                logfunc=jsonrpc.log_stdout))

args = {
    "File": "sample/a.c",
    "Line": 16,
    "Col": 2,
}
ret = server.RequestHandler.GetSymbolDecl(args)
print ret

args = {
    "File": "sample/a.c",
    "Line": 14,
    "Col": 2,
}