# Path: pyhaystack/util/state.py
# @property
# def state(self):
#     """
#     Return the current state machine's state.
#     """
#     return self._state_machine.current
# 
# Path: pyhaystack/util/asyncexc.py
# class AsynchronousException(object):
#     def __init__(self):
#         self._exc_info = exc_info()
# 
#     def reraise(self):
#         reraise(*self._exc_info)


import fysom
import hmac
import base64
import hashlib
import re
from ....util import state
from ....util.asyncexc import AsynchronousException
            self._session._post(
                self._login_uri,
                callback=self._on_login,
                body="nonce:%s\ndigest:%s" % (self._nonce, self._digest),
                body_type="text/plain; charset=utf-8",
                headers={},
                exclude_cookies=True,
                exclude_headers=True,
                api=False,
            )
        except:  # Catch all exceptions to pass to caller.
            self._state_machine.exception(result=AsynchronousException())

    def _on_login(self, response):
        """
        See if the login succeeded.
        """
        try:
            if isinstance(response, AsynchronousException):
                response.reraise()

            # Locate the cookie in the response.
            cookie_match = self._COOKIE_RE.match(response.text)
            if not cookie_match:
                raise IOError("No cookie in response, log-in failed.")

            (cookie_name, cookie_value) = cookie_match.groups()

            self._state_machine.login_done(result={cookie_name: cookie_value})
        except:  # Catch all exceptions to pass to caller.

# Path: pyhaystack/util/state.py
# @property
# def state(self):
#     """
#     Return the current state machine's state.
#     """
#     return self._state_machine.current
# 
# 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/vendor/skyspark.py
import fysom
import hmac
import base64
import hashlib
import re
from ....util import state
from ....util.asyncexc import AsynchronousException

            self._session._post(
                self._login_uri,
                callback=self._on_login,
                body="nonce:%s\ndigest:%s" % (self._nonce, self._digest),
                body_type="text/plain; charset=utf-8",
                headers={},
                exclude_cookies=True,
                exclude_headers=True,
                api=False,
            )
        except:  # Catch all exceptions to pass to caller.
            self._state_machine.exception(result=AsynchronousException())

    def _on_login(self, response):
        """
        See if the login succeeded.
        """
        try:
            if isinstance(response, AsynchronousException):
                response.reraise()

            # Locate the cookie in the response.
            cookie_match = self._COOKIE_RE.match(response.text)
            if not cookie_match:
                raise IOError("No cookie in response, log-in failed.")

            (cookie_name, cookie_value) = cookie_match.groups()

            self._state_machine.login_done(result={cookie_name: cookie_value})
        except:  # Catch all exceptions to pass to caller.

            self._state_machine.exception(result=AsynchronousException())