# Path: pyhaystack/util/state.py
# @property
# def state(self):
#     """
#     Return the current state machine's state.
#     """
#     return self._state_machine.current
# 
# Path: pyhaystack/exception.py
# class HaystackError(Exception):
#     """
#     Exception thrown when an error grid is returned by the Haystack server.
#     See http://project-haystack.org/doc/Rest#errorGrid
#     """
# 
#     def __init__(self, message, traceback=None, *args, **kwargs):
#         super(HaystackError, self).__init__(message, *args, **kwargs)
#         self.traceback = traceback
# 
# class AuthenticationProblem(Exception):
#     pass
# 
# Path: pyhaystack/util/asyncexc.py
# class AsynchronousException(object):
#     def __init__(self):
#         self._exc_info = exc_info()
# 
#     def reraise(self):
#         reraise(*self._exc_info)


import hszinc
import fysom
from ...util import state
from ...exception import HaystackError, AuthenticationProblem
from ...util.asyncexc import AsynchronousException
from six import string_types
from time import time
                self._state_machine.response_ok(result=response)
                return

            # What format grid did we get back?
            content_type = response.content_type
            body = response.text

            if content_type in ("text/zinc", "text/plain"):
                # We have been given a grid in ZINC format.
                decoded = hszinc.parse(body, mode=hszinc.MODE_ZINC, single=False)
            elif content_type == "application/json":
                # We have been given a grid in JSON format.
                decoded = hszinc.parse(body, mode=hszinc.MODE_JSON, single=False)
            elif content_type in ("text/html"):
                # We probably fell back to a login screen after auto logoff.
                self._state_machine.exception(AsynchronousException())
            else:
                # We don't recognise this!
                raise ValueError("Unrecognised content type %s" % content_type)

            # Check for exceptions
            def _check_err(grid):
                try:
                    if "err" in grid.metadata:
                        raise HaystackError(
                            grid.metadata.get("dis", "Unknown Error"),
                            grid.metadata.get("traceback", None),
                        )
                    return grid
                except:

# Path: pyhaystack/util/state.py
# @property
# def state(self):
#     """
#     Return the current state machine's state.
#     """
#     return self._state_machine.current
# 
# Path: pyhaystack/exception.py
# class HaystackError(Exception):
#     """
#     Exception thrown when an error grid is returned by the Haystack server.
#     See http://project-haystack.org/doc/Rest#errorGrid
#     """
# 
#     def __init__(self, message, traceback=None, *args, **kwargs):
#         super(HaystackError, self).__init__(message, *args, **kwargs)
#         self.traceback = traceback
# 
# class AuthenticationProblem(Exception):
#     pass
# 
# Path: pyhaystack/util/asyncexc.py
# class AsynchronousException(object):
#     def __init__(self):
#         self._exc_info = exc_info()
# 
#     def reraise(self):
#         reraise(*self._exc_info)


# Path: pyhaystack/client/ops/grid.py
import hszinc
import fysom
from ...util import state
from ...exception import HaystackError, AuthenticationProblem
from ...util.asyncexc import AsynchronousException
from six import string_types
from time import time

                self._state_machine.response_ok(result=response)
                return

            # What format grid did we get back?
            content_type = response.content_type
            body = response.text

            if content_type in ("text/zinc", "text/plain"):
                # We have been given a grid in ZINC format.
                decoded = hszinc.parse(body, mode=hszinc.MODE_ZINC, single=False)
            elif content_type == "application/json":
                # We have been given a grid in JSON format.
                decoded = hszinc.parse(body, mode=hszinc.MODE_JSON, single=False)
            elif content_type in ("text/html"):
                # We probably fell back to a login screen after auto logoff.
                self._state_machine.exception(AsynchronousException())
            else:
                # We don't recognise this!
                raise ValueError("Unrecognised content type %s" % content_type)

            # Check for exceptions
            def _check_err(grid):
                try:
                    if "err" in grid.metadata:
                        raise HaystackError(
                            grid.metadata.get("dis", "Unknown Error"),
                            grid.metadata.get("traceback", None),
                        )
                    return grid
                except:

                    return AsynchronousException()