0i3ddlZddlZddlZddlZddlZddlZddlmZmZddl Z ddl Z dZ dZ dZejeZej$dgdZej(e Zeeej0j3dd ZGd d eZGd d eZGddeZGddeZ Gdde Z!Gdde Z"y)N)EINTRENOENTiIII) IN_Q_OVERFLOW IN_UNMOUNT_INOTIFY_EVENT)wdmaskcookielenDEBUG0c eZdZy)EventTimeoutExceptionN)__name__ __module__ __qualname__?/opt/hc_python/lib/python3.12/site-packages/inotify/adapters.pyrr(srrceZdZfdZxZS)TerminalEventExceptionc:tt| |||_yN)superr__init__event)self type_namer __class__s rrzTerminalEventException.__init__-s $d4Y? r)rrrr __classcell__r!s@rrr,s rrceZdZgefdZdZdZejjfdZ d dZ d dZ dZ dZd d d efd Zed Zy )Inotifyc||_i|_i|_d|_tj j |_tjd|jtj|_ |jj|jtjd|_|D]}|j!|y)NrzInotify handle is (%d).)_Inotify__block_duration_Inotify__watches_Inotify__watches_r_Inotify__bufferinotifycalls inotify_init_Inotify__inotify_fd_LOGGERdebugselectepoll_Inotify__epollregisterPOLLIN_Inotify__last_success_return add_watch)rpathsblock_duration_spaths rrzInotify.__init__3s 0 #MM668 /1B1BC||~  d//?%)"D NN4 rcZ |jS#t$r|jcYSwxYw)z=Allow the block-duration to be an integer or a function-call.)r' TypeErrorrs r__get_block_durationzInotify.__get_block_durationDs1 )((* * )(( ( )s **cltjdtj|jy)NzCleaning-up inotify.)r/r0oscloser.r=s r__del__zInotify.__del__Ms! ,- ""#rc^tjd|||jvrtjd|y|j d}t j j|j||}tjd||||j|<||j|<|S)NzAdding watch: [%s]z Path already being watched: [%s]utf8zAdded watch (%d): [%s]) r/r0r(warningencoder+r,inotify_add_watchr.r))r path_unicoder path_bytesr s rr7zInotify.add_watchQs *L9 4>> ) OO> M !((0 ]] , ,T->-> D Q .LA')|$+ rc|jj|}|ytjd|||j|=|j ||y)zRemove our tracking information and call inotify to stop watching the given path. When a directory is removed, we'll just have to remove our tracking since inotify already cleans-up the watch. Nz*Removing watch for watch-handle (%d): [%s])r(getr/r0remove_watch_with_id)rr: superficialr s r remove_watchzInotify.remove_watchgsR ^^   % :  B$  NN4  !!"k2rc|j|=|durAtjd|tjj |j |yy)NFz%Removing watch for watch-handle (%d).)r)r/r0r+r,inotify_rm_watchr.)rr rMs rrLzInotify.remove_watch_with_idxsF   R %  MMA2 F MM * *4+<+ICC T"c! ? ?Q L;zmK L rc#Ktj|d}|sy|xj|z c_ t|j}|tkrt j dy|jdt}tjt|}t|}|j|j}t j dj|t|jz}||kry|jt|} | jd} |j|d|_|jj!|j"} | | j%d} ||| | ft|j} | tkryZw)z1Handle a series of events coming-in from inotify.iNzNot enough bytes for a header.zEvents received in stream: {}rD)r@readr*r _STRUCT_HEADER_LENGTHr/r0structunpack_HEADER_STRUCT_FORMATr rZr formatrstripr)rKr decode)rr blength peek_slice header_rawheader type_names event_lengthfilenamefilename_bytesr:filename_unicode buffer_lengths r_handle_inotify_eventzInotify._handle_inotify_eventsc GGB    'F-- >?'=(=>J1&(J$Z0F..v{{;J MM9@@L M1FJJ>L $}}%:<HH&__U3N MM,-8DM##'' 2D#1#8#8#@ z41ABB .M44KsF F NTc#Kd|_tj} |j} |jj |}|D]\} } |j| } tjdj| |j| D]V\} }}}tj}| |||f}|D],}||||dur ||f|_y||vs"t|||X|tj|z } | |kDry|durd#t $rB}|j tk7r|!tj|z } | |kDrYd}~yYd}~Dd}~wwxYww)zYield one event after another. If `timeout_s` is provided, we'll break when no event is received for that many seconds. NTzEvents received from epoll: {}F)r6time_Inotify__get_block_durationr3pollIOErrorerrnorrZr/r0rbrpr)r timeout_s yield_nonesfilter_predicateterminal_events last_hit_sr9eventsetime_since_event_sfdrVrWrirjr:rlr s r event_genzInotify.event_gens&*"YY[ #88:  **+;<#)J--j9 >EEeLM 55b99VZx!%JT8rs  #$ '  H %'''$((=> RZZ^^GS12 3  I Y M*fM*`ggT () ( "9 "r