Skip to content

Serverresponse

ServerResponse

Classes

ServerResponse

ServerResponse(httObj: HTTPResponse)

Object for parsing incomming HTTPResponse from Robot

Source code in dod/ServerResponse.py
def __init__(self, httObj: HTTPResponse):
    try:
        dat = httObj.read().decode('utf-8')
        response = json.loads(dat)
    except ValueError:
        raise Exception(f"Server did not respond in JSON; Something is wrong\n, {dat}")

    self.TIME = response["Time"]
    self.STATUS = response["Status"]
    self.LAST_ID = response["LastID"]
    self.ERROR_CODE = response["ErrorCode"]
    self.ERROR_MESSAGE = response["ErrorMessage"]
    self.RESULTS = response["Result"]
Attributes
ERROR_CODE instance-attribute
ERROR_CODE = response['ErrorCode']
ERROR_MESSAGE instance-attribute
ERROR_MESSAGE = response['ErrorMessage']
LAST_ID instance-attribute
LAST_ID = response['LastID']
RESULTS instance-attribute
RESULTS = response['Result']
STATUS instance-attribute
STATUS = response['Status']
TIME instance-attribute
TIME = response['Time']
Functions
__str__
__str__()
Source code in dod/ServerResponse.py
def __str__(self):
    return f" TIME: {self.TIME}\n STATUS: {self.STATUS}\n LAST_ID: {self.LAST_ID}\n ERROR_CODE: {self.ERROR_CODE}\n ERROR_MESSAGE: {self.ERROR_MESSAGE}\n RESULTS: {self.RESULTS}\n"