예제 #1
0
파일: test.py 프로젝트: vietbk12345/janus
def go():
    resp = yield submit(host, query_add_vertice)
    while True:
        msg = yield resp.read()
        print(msg)
        if msg is None:
            break
예제 #2
0
 def go():
     with self.assertRaises(RuntimeError):
         stream = yield From(submit(
             "ws://localhost:8182/", "throw new Exception('error')",
             password="******", username="******",
             loop=self.loop, future_class=Future))
         yield From(stream.read())
예제 #3
0
 def submit(gremlinServerURI, traversalString):
   response = yield submit(gremlinServerURI, traversalString)
   while True:
     result = yield response.read()
     if result is None:
       break
     raise gen.Return(result.data)
예제 #4
0
파일: test.py 프로젝트: vietbk12345/janus
def go():
    resp = yield submit(host, query_build_index)
    while True:
        msg = yield resp.read()
        print(msg)
        if msg is None:
            break
예제 #5
0
파일: test.py 프로젝트: vietbk12345/janus
def go():
    query_add_vertices = 'def graph=ConfiguredGraphFactory.open(\"vfm\");'
    while True:
        global j
        if j < 6078294:
            doc = cursor.next()
            query_add_vertices += 'graph.addVertex(T.label, "person", "id", "' + str(doc['_id']) \
                                  + '", "name", "' + str(doc['name']) \
                                  + '", "age", "' + str(doc['age']) \
                                  + '", "work", "' + str(doc['work']) \
                                  + '", "gender", "' + str(doc['gender']) \
                                  + '", "location", "' + str(doc['location']) + '");'
            print(j)
            j += 1

        else:
            break
        if j % 200 == 0:
            query_add_vertices += 'graph.tx().commit();'
            print(query_add_vertices)
            resp = yield submit(host, query_add_vertices)
            msg = yield resp.read()
            query_add_vertices = 'def graph=ConfiguredGraphFactory.open(\"vfm\");'
            print(msg)
            if msg is None:
                break
예제 #6
0
 def test_script_exception(self):
     with self.assertRaises(RuntimeError):
         stream = yield submit("ws://localhost:8182/",
                               "throw new Exception('error')",
                               password="******",
                               username="******")
         yield stream.read()
예제 #7
0
파일: test.py 프로젝트: vietbk12345/janus
def get_vertice():
    query_get_vertice = 'def g=ConfiguredGraphFactory.open(\"wordnet\").traversal(); g.V().has(\"name\", \"' + word + '\");'
    resp = yield submit(host, query_get_vertice)
    while True:
        msg = yield resp.read()
        print(msg)
        if msg is None:
            break
예제 #8
0
 def go():
     with self.assertRaises(RuntimeError):
         stream = yield from submit("ws://localhost:8182/",
                                    "throw new Exception('error')",
                                    password="******",
                                    username="******",
                                    loop=self.loop,
                                    future_class=Future)
         yield from stream.read()
예제 #9
0
 def test_submit(self):
     stream = yield submit(
         "ws://localhost:8182/", "1 + 1", password="******",
         username="******")
     while True:
         msg = yield stream.read()
         if msg is None:
             break
         self.assertEqual(msg.status_code, 200)
         self.assertEqual(msg.data[0], 2)
예제 #10
0
 def go():
     stream = yield from submit(
         "ws://localhost:8182/", "x + x", bindings={"x": 1},
         password="******", username="******", future_class=Future)
     while True:
         msg = yield from stream.read()
         if msg is None:
             break
         self.assertEqual(msg.status_code, 200)
         self.assertEqual(msg.data[0], 2)
예제 #11
0
 def go():
     stream = yield from submit(
         "ws://localhost:8182/", "x + x", bindings={"x": 1},
         password="******", username="******", future_class=Future)
     while True:
         msg = yield from stream.read()
         if msg is None:
             break
         self.assertEqual(msg.status_code, 200)
         self.assertEqual(msg.data[0], 2)
예제 #12
0
 def test_submit(self):
     stream = yield submit(
         "ws://localhost:8182/", "x + x", bindings={"x": 1},
         password="******", username="******")
     while True:
         msg = yield stream.read()
         if msg is None:
             break
         self.assertEqual(msg.status_code, 200)
         self.assertEqual(msg.data[0], 2)
예제 #13
0
파일: test.py 프로젝트: vietbk12345/janus
def get_all_words():
    query_get_all_vertices = 'def g=ConfiguredGraphFactory.open(\"wordnet\").traversal(); g.V();'
    while True:
        resp = yield submit(host, query_get_all_vertices)
        msg = yield resp.read()
        if msg is None:
            break
        else:
            data = msg[1]
            for d in data:
                print(d)
                vertices.append(d)
예제 #14
0
 def go():
     stream = yield From(
         submit("ws://localhost:8182/",
                "1 + 1",
                password="******",
                username="******",
                loop=self.loop,
                future_class=Future))
     while True:
         msg = yield From(stream.read())
         if msg is None:
             break
         self.assertEqual(msg.status_code, 200)
         self.assertEqual(msg.data[0], 2)
예제 #15
0
파일: test.py 프로젝트: vietbk12345/janus
def go():
    while True:
        query_add_edges = 'def graph=ConfiguredGraphFactory.open(\"wordnet\"); def g=graph.traversal();'
        global i
        if i < len(data):
            doc = data[i]
            query_add_edges += 'def v1 = g.V().has(T.label, "' \
                               + str(doc['source']) + '").next(); def v2 = g.V().has(T.label, "' + str(doc[
                                                                                                           'target']) + '").next(); v1.addEdge("' + \
                               doc['name'] + '", v2, "weight", 0.4f);'
            print(i)
            i += 1
        else:
            break
        resp = yield submit(host, query_add_edges)
        msg = yield resp.read()
        print(msg)
        if msg is None:
            break
예제 #16
0
파일: test.py 프로젝트: vietbk12345/janus
def go():
    while True:
        query_add_vertices = 'def graph=ConfiguredGraphFactory.open(\"wordnet\");'
        global j
        if j < len(data):
            doc = data[j]
            query_add_vertices += 'graph.addVertex(T.label, "' + str(doc['_id']) \
                                  + '", "id", "' + str(doc['id']) \
                                  + '", "name", "' + str(doc['vietnamese_word']) \
                                  + '", "english_word", "' + str(doc['english_word']) \
                                  + '", "word_type", "' + str(doc['word_type']) + '");'
            print(j)
            j += 1
        else:
            break
        resp = yield submit(host, query_add_vertices)
        msg = yield resp.read()
        print(msg)
        if msg is None:
            break
예제 #17
0
 def test_script_exception(self):
     with self.assertRaises(RuntimeError):
         stream = yield submit("ws://localhost:8182/",
                               "throw new Exception('error')",
                                password="******", username="******")
         yield stream.read()