Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/ambv/black
rev: stable
rev: 24.8.0
hooks:
- id: black
entry: black -l 79 src/api-engine src/agent/kubernetes-agent
language_version: python3.7
entry: black -l 79
language_version: python3.8
35 changes: 23 additions & 12 deletions build_image/docker/cello-hlf/scripts/notifier.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,50 @@
import pyinotify

wm = pyinotify.WatchManager() # Watch Manager
mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE | pyinotify.IN_MODIFY | pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO | pyinotify.IN_MOVE_SELF | pyinotify.IN_DELETE_SELF # watched events
mask = (
pyinotify.IN_DELETE
| pyinotify.IN_CREATE
| pyinotify.IN_MODIFY
| pyinotify.IN_MOVED_FROM
| pyinotify.IN_MOVED_TO
| pyinotify.IN_MOVE_SELF
| pyinotify.IN_DELETE_SELF
) # watched events


class EventHandler(pyinotify.ProcessEvent):
def process_IN_CREATE(self, event):
print "Creating:", event.pathname
print("Creating:", event.pathname)

def process_IN_DELETE(self, event):
print "Removing:", event.pathname
print("Removing:", event.pathname)

def process_IN_MODIFY(self, event):
print "Modifying:", event.pathname
print("Modifying:", event.pathname)

def process_IN_MOVED_FROM(self, event):
print "Moved From:", event.pathname
print("Moved From:", event.pathname)

def process_IN_MOVED_TO(self, event):
print "Moved To:", event.pathname
print("Moved To:", event.pathname)

def process_IN_MOVE_SELF(self, event):
print "Moving Self:", event.pathname
print("Moving Self:", event.pathname)

def process_IN_DELETE_SELF(self, event):
print "Deleting Self:", event.pathname
print("Deleting Self:", event.pathname)


handler = EventHandler()
notifier = pyinotify.Notifier(wm, handler)

# watch Hyperledger and HOME
from os.path import expanduser

home = expanduser("~")
dirs = ['/etc/hyperledger/', '/var/hyperledger/', home]
for d in dirs:
print "Add watcher to "+d
wdd = wm.add_watch(d, mask, rec=True, auto_add=True)
dirs = ["/etc/hyperledger/", "/var/hyperledger/", home]
for dir in dirs:
print("Add watcher to", dir)
wdd = wm.add_watch(dir, mask, rec=True, auto_add=True)

notifier.loop()
Loading
Loading