kirill-stepanishin commented on code in PR #3231:
URL: https://github.com/apache/tinkerpop/pull/3231#discussion_r2414754531
##########
gremlin-python/src/main/python/examples/connections.py:
##########
@@ -40,60 +44,87 @@ def with_remote():
#
# which starts it in "console" mode with an empty in-memory TinkerGraph
ready to go bound to a
# variable named "g" as referenced in the following line.
- rc = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g')
+ # if there is a port placeholder in the env var then we are running with
docker so set appropriate port
+ server_url = os.getenv('GREMLIN_SERVER_URL',
'ws://localhost:8182/gremlin').format(45940)
+ rc = DriverRemoteConnection(server_url, 'g')
g = traversal().with_remote(rc)
- # drop existing vertices
- g.V().drop().iterate()
-
# simple query to verify connection
- v = g.add_v().iterate()
- count = g.V().count().next()
+ v = g.add_v('py-conn-ex').iterate()
+ count = g.V().has_label('py-conn-ex').count().next()
print("Vertex count: " + str(count))
+ # clean added data
+ g.V().has_label('py-conn-ex').drop().iterate()
# cleanup
rc.close()
# connecting with plain text authentication
def with_auth():
- rc = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g',
username='stephen', password='password')
+ # if there is a port placeholder in the env var then we are running with
docker so set appropriate port
+ server_url = os.getenv('GREMLIN_SERVER_BASIC_AUTH_URL',
'ws://localhost:8182/gremlin').format(45941)
+
+ # disable SSL certificate verification for remote hosts in test
environments
+ if 'localhost' not in server_url:
+ ssl_opts = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
+ ssl_opts.check_hostname = False
+ ssl_opts.verify_mode = ssl.CERT_NONE
+ rc = DriverRemoteConnection(server_url, 'g', username='stephen',
password='password',
+ transport_factory=lambda:
AiohttpTransport(ssl_options=ssl_opts))
+ else:
+ rc = DriverRemoteConnection(server_url, 'g', username='stephen',
password='password')
+
g = traversal().with_remote(rc)
- v = g.add_v().iterate()
- count = g.V().count().next()
+ v = g.add_v('py-conn-ex').iterate()
+ count = g.V().has_label('py-conn-ex').count().next()
print("Vertex count: " + str(count))
+ # clean added data
+ g.V().has_label('py-conn-ex').drop().iterate()
rc.close()
# connecting with Kerberos SASL authentication
def with_kerberos():
- rc = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g',
kerberized_service='[email protected]')
+ # if there is a port placeholder in the env var then we are running with
docker so set appropriate port
+ server_url = os.getenv('GREMLIN_SERVER_URL',
'ws://localhost:8182/gremlin').format(45942)
+ kerberos_hostname = os.getenv('KRB_HOSTNAME', socket.gethostname())
+ kerberized_service = f'test-service@{kerberos_hostname}'
Review Comment:
The GLV-level examples aren’t meant to be user-facing. The root-level GLV
examples won’t include those adaptations since they won’t be run as part of CI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]