author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
Mon, 11 Oct 2010 12:44:33 -0500 | |
changeset 12702 | f747c085b789 |
parent 10263 | 25e572394f5c |
child 13400 | 14f3795a5ed7 |
permissions | -rw-r--r-- |
6239 | 1 |
# __init__.py - low-level interfaces to the Linux inotify subsystem |
2 |
||
3 |
# Copyright 2006 Bryan O'Sullivan <bos@serpentine.com> |
|
4 |
||
5 |
# This library is free software; you can redistribute it and/or modify |
|
6 |
# it under the terms of version 2.1 of the GNU Lesser General Public |
|
10263 | 7 |
# License, or any later version. |
6239 | 8 |
|
9 |
'''Low-level interface to the Linux inotify subsystem. |
|
10 |
||
11 |
The inotify subsystem provides an efficient mechanism for file status |
|
12 |
monitoring and change notification. |
|
13 |
||
14 |
This package provides the low-level inotify system call interface and |
|
15 |
associated constants and helper functions. |
|
16 |
||
17 |
For a higher-level interface that remains highly efficient, use the |
|
18 |
inotify.watcher package.''' |
|
19 |
||
20 |
__author__ = "Bryan O'Sullivan <bos@serpentine.com>" |
|
21 |
||
22 |
from _inotify import * |
|
23 |
||
24 |
procfs_path = '/proc/sys/fs/inotify' |
|
25 |
||
26 |
def _read_procfs_value(name): |
|
27 |
def read_value(): |
|
28 |
try: |
|
29 |
return int(open(procfs_path + '/' + name).read()) |
|
7875
553aa0cbeab6
cleanup: drop unused assignments
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
6239
diff
changeset
|
30 |
except OSError: |
6239 | 31 |
return None |
32 |
||
33 |
read_value.__doc__ = '''Return the value of the %s setting from /proc. |
|
34 |
||
35 |
If inotify is not enabled on this system, return None.''' % name |
|
36 |
||
37 |
return read_value |
|
38 |
||
39 |
max_queued_events = _read_procfs_value('max_queued_events') |
|
40 |
max_user_instances = _read_procfs_value('max_user_instances') |
|
41 |
max_user_watches = _read_procfs_value('max_user_watches') |