Skip to content

Commit

Permalink
Verify client version. (#148)
Browse files Browse the repository at this point in the history
* Check client version.

* Fix execute_json.

* Address comment.
  • Loading branch information
CPWstatic authored Oct 12, 2021
1 parent f78992c commit fe2a856
Show file tree
Hide file tree
Showing 15 changed files with 1,493 additions and 1,177 deletions.
21 changes: 1 addition & 20 deletions example/GraphClientSimpleExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from nebula2.gclient.net import ConnectionPool
from nebula2.Config import Config
from nebula2.common import *
from FormatResp import print_resp

if __name__ == '__main__':
Expand Down Expand Up @@ -53,28 +52,10 @@
assert resp.is_succeeded(), resp.error_msg()
print_resp(resp)

bval = ttypes.Value()
bval.set_bVal(True)
ival = ttypes.Value()
ival.set_iVal(3)
sval = ttypes.Value()
sval.set_sVal("Cypher Parameter")
params={"p1":ival,"p2":bval,"p3":sval}

# test parameter interface
resp = client.execute_parameter('RETURN abs($p1)+3, toBoolean($p2) and false, toLower($p3)+1',params)
assert resp.is_succeeded(), resp.error_msg()
print_resp(resp)
# test compatibility
resp = client.execute('RETURN 3')
resp = client.execute('FETCH PROP ON like "Bob"->"Lily"')
assert resp.is_succeeded(), resp.error_msg()
print_resp(resp)

# get the result in json format
resp_json = client.execute_json_with_parameter("yield 1", params)
json_obj = json.loads(resp_json)
print(json.dumps(json_obj, indent=2, sort_keys=True))

# drop space
resp = client.execute('DROP SPACE test')
assert resp.is_succeeded(), resp.error_msg()
Expand Down
3 changes: 3 additions & 0 deletions nebula2/Exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ def __init__(self, code=E_UNKNOWN, message=None):
self.type = code
self.message = message

class ClientServerIncompatibleException(Exception):
def __init__(self, message):
Exception.__init__(self, f'Current client is not compatible with the remote server, please check the version: {message}')
4 changes: 3 additions & 1 deletion nebula2/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@



from .ttypes import UTF8STRINGS, NullType, ErrorCode, SchemaID, Date, Time, DateTime, Value, NList, NMap, NSet, Row, DataSet, Tag, Vertex, Edge, Step, Path, HostAddr, KeyValue, LogInfo, DirInfo, NodeInfo, PartitionBackupInfo, CheckpointInfo, GraphSpaceID, PartitionID, TagID, EdgeType, EdgeRanking, LogID, TermID, Timestamp, IndexID, Port, SessionID, ExecutionPlanID
from .ttypes import UTF8STRINGS, NullType, ErrorCode, SchemaID, Date, Time, DateTime, Value, NList, NMap, NSet, Row, DataSet, Geography, Tag, Vertex, Edge, Step, Path, HostAddr, KeyValue, LogInfo, DirInfo, NodeInfo, PartitionBackupInfo, CheckpointInfo, GraphSpaceID, PartitionID, TagID, EdgeType, EdgeRanking, LogID, TermID, Timestamp, IndexID, Port, SessionID, ExecutionPlanID

version = "2.6.0"

Loading

0 comments on commit fe2a856

Please sign in to comment.