def __init__(self, client, method, *args, timeout=15, encode_json=True, response_id=True):
"""
Initiate a Scripted Query.
:param client: Client instance
:param method: Method name
:param args: Arguments
:param timeout: Timeout to wait for future result.
:param encode_json: Is body json? True by default.
:param response_id: Is request requiring response_id?
:type client: pyplanet.core.gbx.client.GbxClient
"""
# Make sure we call the script stuff with TriggerModeScriptEventArray.
gbx_method = 'TriggerModeScriptEventArray'
gbx_args = list()
# Make sure we generate a response_id.
if response_id is True:
self.response_id = uuid.uuid4().hex
else:
self.response_id = None
# Encode to json if args are given, and encode_json is true (default).
if encode_json and len(args) > 0:
gbx_args.append(json.dumps(args))
elif not encode_json and len(args) > 0:
gbx_args.extend(args)
# Add the response_id to the end of the argument list.
if self.response_id:
gbx_args.append(str(self.response_id))
super().__init__(client, gbx_method, method, gbx_args, timeout=timeout)
评论列表
文章目录