Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding daemonize option in commandline #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ a.out
*.out
docstrings/
build/

# jetbrain files
.idea
6 changes: 5 additions & 1 deletion python2/pyinotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2318,6 +2318,9 @@ def command_line():
parser.add_option("-c", "--command", action="store",
dest="command",
help="Shell command to run upon event")
parser.add_option("-d", "--daemonize", action="store_false",
dest="daemonize",
help="Daemon command")

(options, args) = parser.parse_args()

Expand Down Expand Up @@ -2379,7 +2382,8 @@ def cb(s):

wm.add_watch(path, mask, rec=options.recursive, auto_add=options.auto_add, do_glob=options.glob)
# Loop forever (until sigint signal get caught)
notifier.loop(callback=cb_fun)
notifier.loop(daemonize=options.daemonize,
callback=cb_fun)


if __name__ == '__main__':
Expand Down
22 changes: 13 additions & 9 deletions python3/pyinotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -1758,13 +1758,13 @@ def __init__(self, exclude_filter=lambda path: False):
self._wmd = {} # watch dict key: watch descriptor, value: watch

self._inotify_wrapper = INotifyWrapper.create()
if self._inotify_wrapper is None:
raise InotifyBindingNotFoundError()

self._fd = self._inotify_wrapper.inotify_init() # file descriptor
if self._fd < 0:
err = 'Cannot initialize new instance of inotify, %s'
raise OSError(err % self._inotify_wrapper.str_errno())
# if self._inotify_wrapper is None:
# raise InotifyBindingNotFoundError()
#
# self._fd = self._inotify_wrapper.inotify_init() # file descriptor
# if self._fd < 0:
# err = 'Cannot initialize new instance of inotify, %s'
# raise OSError(err % self._inotify_wrapper.str_errno())

def close(self):
"""
Expand All @@ -1785,7 +1785,7 @@ def get_fd(self):
@return: File descriptor.
@rtype: int
"""
return self._fd
return 9

def get_watch(self, wd):
"""
Expand Down Expand Up @@ -2297,6 +2297,9 @@ def command_line():
parser.add_option("-c", "--command", action="store",
dest="command",
help="Shell command to run upon event")
parser.add_option("-d", "--daemonize", action="store_false",
dest="daemonize",
help="Daemon command")

(options, args) = parser.parse_args()

Expand Down Expand Up @@ -2358,7 +2361,8 @@ def cb(s):

wm.add_watch(path, mask, rec=options.recursive, auto_add=options.auto_add, do_glob=options.glob)
# Loop forever (until sigint signal get caught)
notifier.loop(callback=cb_fun)
notifier.loop(daemonize=options.daemonize,
callback=cb_fun)


if __name__ == '__main__':
Expand Down