Exemple #1
0
 def __init__(self):
     reader = graphsonV3d0.GraphSONReader()
     writer = graphsonV3d0.GraphSONWriter()
     version = b"application/vnd.gremlin-v3.0+json"
     super(ExtendedGraphSONSerializersV3d0,
           self).__init__(reader, writer, version)
     self.session = Session(writer)
Exemple #2
0
 def __init__(self, reader=None, writer=None):
     GraphSONMessageSerializer.__init__(
         self, reader, writer, b"application/vnd.gremlin-v3.0+json")
     if not reader:
         self._graphson_reader = graphsonV3d0.GraphSONReader()
     if not writer:
         self._graphson_writer = graphsonV3d0.GraphSONWriter()
     self.standard = Standard(self._graphson_writer)
     self.traversal = Traversal(self._graphson_writer)
Exemple #3
0
 def __init__(self,
              reader=None,
              writer=None,
              version=b"application/vnd.gremlin-v3.0+json"):
     self.version = version
     if not reader:
         reader = graphsonV3d0.GraphSONReader()
     self._graphson_reader = reader
     if not writer:
         writer = graphsonV3d0.GraphSONWriter()
     self.standard = Standard(writer)
     self.traversal = Traversal(writer)
Exemple #4
0
import json
import requests
import daiquiri
from gremlin_python.structure.io import graphsonV3d0
from requests.adapters import HTTPAdapter
from urllib3 import Retry

from src.config import (GREMLIN_DEFAULT_HOST, GREMLIN_DEFAULT_PORT,
                        GREMLIN_SCHEME, DAIQUIRI_LOG_LEVEL)

# from src.utils import get_session_retry

daiquiri.setup(level=DAIQUIRI_LOG_LEVEL)
log = daiquiri.getLogger(__name__)  # pylint: disable=invalid-name

_READER = graphsonV3d0.GraphSONReader()
_GREMLIN_URL = '{scheme}://{host}:{port}'.format(scheme=GREMLIN_SCHEME,
                                                 host=GREMLIN_DEFAULT_HOST,
                                                 port=GREMLIN_DEFAULT_PORT)


def test_connection() -> bool:
    """Test connection to gremlin server."""
    response = requests.get(_GREMLIN_URL)
    # Everything except "not found" is acceptable.
    return response.status_code != 404


def execute_query(query):
    """Post given Traversel to gremlin server."""
    response = get_session_retry().post(_GREMLIN_URL,