ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     import logging
import ctypes
import os

import inotify.library

_LOGGER = logging.getLogger(__name__)

_LIB = inotify.library.instance


class InotifyError(Exception):
    def __init__(self, message, *args, **kwargs):
        self._errno = ctypes.get_errno()

        try:
            self._errmsg = os.strerror(self.errno)
        except:
            self._errmsg = ''

        message += " ERRNO=({}) [{}]".format(self._errno, self._errmsg)

        super(InotifyError, self).__init__(message, *args, **kwargs)

    @property
    def errno(self):
        return self._errno

    @property
    def errmsg(self):
        return self._errmsg


def _check_zero(result):
    if result != 0:
        raise InotifyError("Call failed (should return zero): (%d)" % 
                           (result,))

    return result

def _check_nonzero(result):
    if result == 0:
        raise InotifyError("Call failed (should return nonzero): (%d)" % 
                           (result,))

    return result

def _check_nonnegative(result):
    if result == -1:
        raise InotifyError("Call failed (should not be -1): (%d)" % 
                           (result,))

    return result

inotify_init = _LIB.inotify_init
inotify_init.argtypes = []
inotify_init.restype = _check_nonnegative

inotify_add_watch = _LIB.inotify_add_watch
inotify_add_watch.argtypes = [
    ctypes.c_int, 
    ctypes.c_char_p, 
    ctypes.c_uint32]

inotify_add_watch.restype = _check_nonnegative

inotify_rm_watch = _LIB.inotify_rm_watch
inotify_rm_watch.argtypes = [ctypes.c_int, ctypes.c_int]
inotify_rm_watch.restype = _check_nonnegative

if getattr(_LIB, 'errno', None) is not None:
    errno = _LIB.errno
elif getattr(_LIB, 'err', None) is not None:
    errno = _LIB.err
else:
    raise EnvironmentError("'errno' not found in library")
