# Path: yubioath/gui/ccid.py
# class CardStatus:
#     NoCard, InUse, Present = range(3)
# 
# Path: yubioath/yubicommon/compat.py
# def byte2int(i):
#     if _PY2:
#         return ord(i)
#     return i
# 
# def int2byte(i):
#     if _PY2:
#         return chr(i)
#     return bytes((i,))


from .ccid import CardStatus
from yubioath.yubicommon.compat import byte2int, int2byte
from smartcard.scard import (
    SCardTransmit, SCardGetErrorMessage, SCardConnect, SCardDisconnect,
    SCardEstablishContext, SCardReleaseContext, SCardListReaders,
    SCARD_S_SUCCESS, SCARD_UNPOWER_CARD, SCARD_SCOPE_USER, SCARD_SHARE_SHARED,
    SCARD_PROTOCOL_T0, SCARD_PROTOCOL_T1
)
from PySide import QtCore
import threading
import time
            time.sleep(2)

    def _list(self):
        try:
            hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
            if hresult != SCARD_S_SUCCESS:
                raise Exception('Failed to establish context : ' +
                                SCardGetErrorMessage(hresult))

            try:
                hresult, readers = SCardListReaders(hcontext, [])
                if hresult != SCARD_S_SUCCESS:
                    raise Exception('Failed to list readers: ' +
                                    SCardGetErrorMessage(hresult))
                return readers
            finally:
                hresult = SCardReleaseContext(hcontext)
                if hresult != SCARD_S_SUCCESS:
                    raise Exception('Failed to release context: ' +
                                    SCardGetErrorMessage(hresult))
        except:
            return []


class CardWatcher(QtCore.QObject):
    status_changed = QtCore.Signal(int)

    def __init__(self, reader_name, callback, parent=None):
        super(CardWatcher, self).__init__(parent)


# Path: yubioath/gui/ccid.py
# class CardStatus:
#     NoCard, InUse, Present = range(3)
# 
# Path: yubioath/yubicommon/compat.py
# def byte2int(i):
#     if _PY2:
#         return ord(i)
#     return i
# 
# def int2byte(i):
#     if _PY2:
#         return chr(i)
#     return bytes((i,))


# Path: yubioath/gui/ccid_poll.py
from .ccid import CardStatus
from yubioath.yubicommon.compat import byte2int, int2byte
from smartcard.scard import (
    SCardTransmit, SCardGetErrorMessage, SCardConnect, SCardDisconnect,
    SCardEstablishContext, SCardReleaseContext, SCardListReaders,
    SCARD_S_SUCCESS, SCARD_UNPOWER_CARD, SCARD_SCOPE_USER, SCARD_SHARE_SHARED,
    SCARD_PROTOCOL_T0, SCARD_PROTOCOL_T1
)
from PySide import QtCore
import threading
import time

            time.sleep(2)

    def _list(self):
        try:
            hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
            if hresult != SCARD_S_SUCCESS:
                raise Exception('Failed to establish context : ' +
                                SCardGetErrorMessage(hresult))

            try:
                hresult, readers = SCardListReaders(hcontext, [])
                if hresult != SCARD_S_SUCCESS:
                    raise Exception('Failed to list readers: ' +
                                    SCardGetErrorMessage(hresult))
                return readers
            finally:
                hresult = SCardReleaseContext(hcontext)
                if hresult != SCARD_S_SUCCESS:
                    raise Exception('Failed to release context: ' +
                                    SCardGetErrorMessage(hresult))
        except:
            return []


class CardWatcher(QtCore.QObject):
    status_changed = QtCore.Signal(int)

    def __init__(self, reader_name, callback, parent=None):
        super(CardWatcher, self).__init__(parent)


        self._status = CardStatus.NoCard