Client
- class dazpy.DazClient(host='127.0.0.1', port=18811, token=None, timeout=30.0)[source]
Bases:
objectHTTP client for the DAZ Studio Script Server.
Handles authentication, request serialisation, and response mapping for all server endpoints. The token is loaded automatically from
~/.daz3d/dazscriptserver_token.txtwhen token isNone.- Parameters:
Example:
client = DazClient() # default 127.0.0.1:18811 client = DazClient(token="my-secret-token") # explicit token
- execute(script, args=None)[source]
Execute a DazScript string synchronously.
- Parameters:
- Returns:
The execution result containing the script return value and any console output.
- Raises:
ConnectionError – If the server cannot be reached.
AuthenticationError – If the token is invalid or the IP is blocked.
ScriptSyntaxError – If the script contains a parse error.
ScriptRuntimeError – If the script raises a runtime exception.
TimeoutError – If the request exceeds timeout seconds.
- Return type:
- execute_file(script_file, args=None)[source]
Execute a
.dsascript file that resides on the DAZ Studio host.- Parameters:
- Returns:
The execution result.
- Raises:
ConnectionError – If the server cannot be reached.
AuthenticationError – On auth failure.
ScriptSyntaxError – On parse error.
ScriptRuntimeError – On runtime error.
TimeoutError – On HTTP timeout.
- Return type:
- execute_async_submit(script, args=None)[source]
Submit a script for asynchronous execution and return immediately.
- Parameters:
- Returns:
The server-assigned
request_idstring. Use it withget_request_status()orget_request_result()to poll for the outcome.- Raises:
ConnectionError – If the server cannot be reached.
AuthenticationError – On auth failure.
- Return type:
- get_request_status(request_id)[source]
Return the current status of an async request.
- Parameters:
request_id (str) – The ID returned by
execute_async_submit().- Returns:
"queued","running","completed","failed","cancelled", or"not_found".- Return type:
A dict with at least a
"status"key. Possible values
- get_request_result(request_id, wait=False, wait_timeout=30)[source]
Fetch the result of a completed async request.
- Parameters:
request_id (str) – The ID returned by
execute_async_submit().wait (bool) – If
True, the server will long-poll until the request completes or wait_timeout is reached.wait_timeout (int) – Maximum number of seconds the server should wait before returning (only relevant when wait is
True).
- Returns:
A dict containing
success,result,output,error,duration_ms, andstatuskeys.- Return type:
- cancel_request(request_id)[source]
Cancel a queued or running async request.
- Parameters:
request_id (str) – The ID returned by
execute_async_submit().- Returns:
Trueif the server confirmed cancellation,Falseotherwise.- Return type: