Niv Sardi commited on
Commit
fa99063
1 Parent(s): ca301f7

watcher: show seen files

Browse files

Signed-off-by: Niv Sardi <xaiki@evilgiggle.com>

Files changed (1) hide show
  1. crawler/watcher.py +3 -1
crawler/watcher.py CHANGED
@@ -3,13 +3,15 @@ import inotify.adapters
3
  from imtool import read_bounding_boxes, crop
4
 
5
  def watch(dir):
 
6
  i = inotify.adapters.Inotify()
7
  i.add_watch(dir)
8
  for event in i.event_gen(yield_nones=False):
9
  (_, type_names, path, filename) = event
10
 
11
  if filename.endswith(".png") and type_names[0] in ['IN_CLOSE_WRITE']:
12
- print(f"--PATH=[{path}] FILENAME=[{filename}] EVENT_TYPES={type_names}")
 
13
  try:
14
  bbs = read_bounding_boxes(os.path.join(path, filename.replace('.png', '.txt')))
15
  crop(os.path.join(path, filename), bbs)
 
3
  from imtool import read_bounding_boxes, crop
4
 
5
  def watch(dir):
6
+ seen = 0
7
  i = inotify.adapters.Inotify()
8
  i.add_watch(dir)
9
  for event in i.event_gen(yield_nones=False):
10
  (_, type_names, path, filename) = event
11
 
12
  if filename.endswith(".png") and type_names[0] in ['IN_CLOSE_WRITE']:
13
+ seen += 1
14
+ print(f"{seen} PATH=[{path}] FILENAME=[{filename}] EVENT_TYPES={type_names}")
15
  try:
16
  bbs = read_bounding_boxes(os.path.join(path, filename.replace('.png', '.txt')))
17
  crop(os.path.join(path, filename), bbs)