Python pyinotify.IN_CLOSE_WRITE Examples
The following are 12
code examples of pyinotify.IN_CLOSE_WRITE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyinotify
, or try the search function
.
Example #1
Source File: wlt_2_nextion.py From WLANThermo_v2 with GNU General Public License v3.0 | 5 votes |
def process_IN_CLOSE_WRITE(self, event): global temps, channels, pitmaster, pitconf, Config, configfile global temps_event, channels_event, pitmaster_event, pitconf_event, logger logger.debug("IN_CLOSE_WRITE: %s " % os.path.join(event.path, event.name)) if event.path == curPath and event.name == curFile: logger.debug(_(u'New temperature values available')) temps_event.set() elif event.path == confPath and event.name == confFile: logger.debug(_(u'New configuration data available')) channels_event.set() pitconf_event.set() config_event.set() elif event.path == pitPath and event.name == pitFile: logger.debug(_(u'New pitmaster data available')) pitmaster_event.set() elif event.path == pit2Path and event.name == pit2File: logger.debug(_(u'New pitmaster data available')) pitmaster2_event.set()
Example #2
Source File: desktop_parser.py From opensnitch with GNU General Public License v3.0 | 5 votes |
def run(self): self.running = True wm = pyinotify.WatchManager() notifier = pyinotify.Notifier(wm) def inotify_callback(event): if event.mask == pyinotify.IN_CLOSE_WRITE: self._parse_desktop_file(event.pathname) elif event.mask == pyinotify.IN_DELETE: with self.lock: for cmd, data in self.apps.items(): if data[2] == event.pathname: del self.apps[cmd] break for p in DESKTOP_PATHS: if os.path.exists(p): wm.add_watch(p, pyinotify.IN_CLOSE_WRITE | pyinotify.IN_DELETE, inotify_callback) notifier.loop()
Example #3
Source File: watch.py From pyrocore with GNU General Public License v2.0 | 5 votes |
def setup(self): """ Set up inotify manager. See https://github.com/seb-m/pyinotify/. """ if not pyinotify.WatchManager: raise error.UserError("You need to install 'pyinotify' to use %s (%s)!" % ( self.__class__.__name__, pyinotify._import_error)) # pylint: disable=E1101, W0212 self.manager = pyinotify.WatchManager() self.handler = TreeWatchHandler(job=self) self.notifier = pyinotify.AsyncNotifier(self.manager, self.handler) if self.LOG.isEnabledFor(logging.DEBUG): mask = pyinotify.ALL_EVENTS else: mask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_MOVED_TO # bogus pylint: disable=E1101 # Add all configured base dirs for path in self.config.path: self.manager.add_watch(path.strip(), mask, rec=True, auto_add=True)
Example #4
Source File: filewatch.py From doit with MIT License | 5 votes |
def _loop_linux(self, loop_callback): """loop implementation for linux platform""" import pyinotify handler = self._handle class EventHandler(pyinotify.ProcessEvent): def process_default(self, event): handler(event) watch_manager = pyinotify.WatchManager() event_handler = EventHandler() notifier = pyinotify.Notifier(watch_manager, event_handler) mask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_MOVED_TO for watch_this in self.watch_dirs: watch_manager.add_watch(watch_this, mask) notifier.loop(loop_callback)
Example #5
Source File: wlt_2_lcd_204.py From WLANThermo_v2 with GNU General Public License v3.0 | 4 votes |
def process_IN_CLOSE_WRITE(self, event): logger.debug("IN_CLOSE_WRITE: %s " % os.path.join(event.path, event.name)) show_values()
Example #6
Source File: wlt_2_watchdog.py From WLANThermo_v2 with GNU General Public License v3.0 | 4 votes |
def process_IN_CLOSE_WRITE(self, event): if (os.path.join(event.path, event.name) == "/var/www/conf/WLANThermo.conf"): #print "IN_CLOSE_WRITE: %s " % os.path.join(event.path, event.name) read_config()
Example #7
Source File: runas2daemon.py From pyas2 with GNU General Public License v2.0 | 4 votes |
def process_default(self, event): """ for each incoming event: place route to run in a set. Main thread sends actual job. """ # ~ if event.mask == pyinotify.IN_CLOSE_WRITE and event.dir and self.watch_data[event.wd][2]: # ~ logger.info(u'new directory!!"%s %s".',event.) # ~ print 'event detected',event.name,event.maskname, event.wd if not event.dir: for dir_watch in self.dir_watch_data: if event.pathname.startswith(dir_watch['path']): # if fnmatch.fnmatch(event.name, dir_watch['filemask']): self.cond.acquire() self.tasks.add((dir_watch['organization'], dir_watch['partner'], event.pathname)) self.cond.notify() self.cond.release()
Example #8
Source File: runas2daemon.py From pyas2 with GNU General Public License v2.0 | 4 votes |
def linux_event_handler(logger, dir_watch_data, cond, tasks): watch_manager = pyinotify.WatchManager() mask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_MOVED_TO | pyinotify.IN_MODIFY | pyinotify.IN_CREATE for dir_watch in dir_watch_data: logger.info(_(u'Watching directory %s' % dir_watch['path'])) watch_manager.add_watch(path=dir_watch['path'], mask=mask, rec=False, auto_add=True, do_glob=True) handler = LinuxEventHandler(logger=logger, dir_watch_data=dir_watch_data, cond=cond, tasks=tasks) notifier = pyinotify.Notifier(watch_manager, handler) notifier.loop() # end of linux-specific ##################################################################################
Example #9
Source File: screen.py From dyode with GNU General Public License v3.0 | 4 votes |
def watch_folder(module, params): log.debug('Watching folder %s for screenshots ...' % params['in']) screen_wm = pyinotify.WatchManager() screen_mask = pyinotify.IN_CLOSE_WRITE screen_notifier = pyinotify.AsyncNotifier(screen_wm, ScreenshotHandler()) screen_wdd = screen_wm.add_watch(params['in'], screen_mask, rec = True) asyncore.loop()
Example #10
Source File: dyode_in.py From dyode with GNU General Public License v3.0 | 4 votes |
def watch_folder(properties): log.debug('Function "folder" launched with params %s: ' % properties) # inotify kernel watchdog stuff wm = pyinotify.WatchManager() mask = pyinotify.IN_CLOSE_WRITE notifier = pyinotify.AsyncNotifier(wm, EventHandler()) wdd = wm.add_watch(properties['in'], mask, rec = True) log.debug('watching :: %s' % properties['in']) asyncore.loop()
Example #11
Source File: torrents.py From putio-automator with MIT License | 4 votes |
def watch(parent_id=None, mount=False): "Watch a folder for new torrents to add" if parent_id == None: parent_id = app.config.get('PUTIO_ROOT', 0) if mount and not os.path.exists(app.config['TORRENTS']): subprocess.call([ 'mount', '-a' ]) add() class EventHandler(pyinotify.ProcessEvent): "Event handler for responding to a new or updated torrent file" def process_IN_CLOSE_WRITE(self, event): "Do the above" app.logger.debug('adding torrent, received event: %s' % event) transfer = app.client.Transfer.add_torrent(event.pathname, parent_id=parent_id) os.unlink(event.pathname) app.logger.info('added transfer: %s' % transfer) watch_manager = pyinotify.WatchManager() mask = pyinotify.IN_CLOSE_WRITE handler = EventHandler() notifier = pyinotify.Notifier(watch_manager, handler) wdd = watch_manager.add_watch(app.config['TORRENTS'], mask, rec=True) app.logger.debug('added watch: %s' % wdd) notifier.loop()
Example #12
Source File: __main__.py From recursive-gobuster with MIT License | 4 votes |
def main(args_ns: argparse.Namespace) -> None: tmpdir = tempfile.mkdtemp(prefix="rcrsv-gbstr") # directory for gobuster scan results # watch manager stores the watches and provides operations on watches wm = pyinotify.WatchManager() version = get_gobuster_version() handler = EventHandler( target=args_ns.target, tmpdir=tmpdir, wordlist=args_ns.wordlist, threads=args_ns.threads, extensions=args_ns.extensions, devnull=args.devnull, user=args_ns.user, password=args_ns.password, proxy=args_ns.proxy, version=version, status=args_ns.status, ) notifier = pyinotify.Notifier(wm, handler) # watch for file appends (found dir/file) and files closing (scan complete) mask = pyinotify.IN_MODIFY | pyinotify.IN_CLOSE_WRITE wm.add_watch(tmpdir, mask) handler.run_gobuster(args_ns.target) # kick off first scan against initial target signal.signal(signal.SIGINT, handler.cleanup) # register signal handler to handle SIGINT notifier.loop()