<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><title>Python: module bgservice.bgservice</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head><body bgcolor="#f0f0f8"> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="bgservice.html"><font color="#ffffff">bgservice</font></a>.bgservice</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/nkenschaft/Sysadmin/skoolos/bgservice/bgservice.py">/home/nkenschaft/Sysadmin/skoolos/bgservice/bgservice.py</a></font></td></tr></table> <p><tt>A simple background service to log events in a directory,<br> check for git commands in bash/zsh history,<br> and check for non-whitelisted files in the watched directory.</tt></p> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#aa55cc"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="bgservice.checker.html">bgservice.checker</a><br> <a href="os.html">os</a><br> </td><td width="25%" valign=top><a href="pyinotify.html">pyinotify</a><br> <a href="sys.html">sys</a><br> </td><td width="25%" valign=top><a href="time.html">time</a><br> </td><td width="25%" valign=top></td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ee77aa"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> <td width="100%"><dl> <dt><font face="helvetica, arial"><a href="pyinotify.html#ProcessEvent">pyinotify.ProcessEvent</a>(<a href="pyinotify.html#_ProcessEvent">pyinotify._ProcessEvent</a>) </font></dt><dd> <dl> <dt><font face="helvetica, arial"><a href="bgservice.bgservice.html#EventHandler">EventHandler</a> </font></dt></dl> </dd> </dl> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="EventHandler">class <strong>EventHandler</strong></a>(<a href="pyinotify.html#ProcessEvent">pyinotify.ProcessEvent</a>)</font></td></tr> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt><a href="#EventHandler">EventHandler</a>(pevent=None, **kargs)<br> <br> Custom event handler for watching a SkoolOS work directory<br> </tt></td></tr> <tr><td> </td> <td width="100%"><dl><dt>Method resolution order:</dt> <dd><a href="bgservice.bgservice.html#EventHandler">EventHandler</a></dd> <dd><a href="pyinotify.html#ProcessEvent">pyinotify.ProcessEvent</a></dd> <dd><a href="pyinotify.html#_ProcessEvent">pyinotify._ProcessEvent</a></dd> <dd><a href="builtins.html#object">builtins.object</a></dd> </dl> <hr> Methods defined here:<br> <dl><dt><a name="EventHandler-process_IN_CLOSE_WRITE"><strong>process_IN_CLOSE_WRITE</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_CLOSE_WRITE events<br> param event: event automatically passed to function<br> return: none</tt></dd></dl> <dl><dt><a name="EventHandler-process_IN_CREATE"><strong>process_IN_CREATE</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_CREATE events<br> param event: event automatically passed to function<br> return: none</tt></dd></dl> <dl><dt><a name="EventHandler-process_IN_DELETE"><strong>process_IN_DELETE</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_DELETE events<br> param event: event automatically passed to function<br> return: none</tt></dd></dl> <dl><dt><a name="EventHandler-process_IN_MOVED_FROM"><strong>process_IN_MOVED_FROM</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_MOVED_FROM events<br> param event: event automatically passed to function<br> return: none</tt></dd></dl> <dl><dt><a name="EventHandler-process_IN_MOVED_TO"><strong>process_IN_MOVED_TO</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_MOVED_TO events<br> param event: event automatically passed to function<br> return: none</tt></dd></dl> <dl><dt><a name="EventHandler-process_IN_OPEN"><strong>process_IN_OPEN</strong></a>(self, event)</dt><dd><tt>Generates an output to record for IN_OPEN events<br> param event: event automatically passed to function<br> return: none</tt></dd></dl> <hr> Methods inherited from <a href="pyinotify.html#ProcessEvent">pyinotify.ProcessEvent</a>:<br> <dl><dt><a name="EventHandler-__call__"><strong>__call__</strong></a>(self, event)</dt><dd><tt>To behave like a functor the object must be callable.<br> This method is a dispatch method. Its lookup order is:<br> 1. process_MASKNAME method<br> 2. process_FAMILY_NAME method<br> 3. otherwise calls process_default<br> <br> @param event: Event to be processed.<br> @type event: Event object<br> @return: By convention when used from the <a href="pyinotify.html#ProcessEvent">ProcessEvent</a> class:<br> - Returning False or None (default value) means keep on<br> executing next chained functors (see chain.py example).<br> - Returning True instead means do not execute next<br> processing functions.<br> @rtype: bool<br> @raise ProcessEventError: Event object undispatchable,<br> unknown event.</tt></dd></dl> <dl><dt><a name="EventHandler-__init__"><strong>__init__</strong></a>(self, pevent=None, **kargs)</dt><dd><tt>Enable chaining of <a href="pyinotify.html#ProcessEvent">ProcessEvent</a> instances.<br> <br> @param pevent: Optional callable object, will be called on event<br> processing (before self).<br> @type pevent: callable<br> @param kargs: This constructor is implemented as a template method<br> delegating its optionals keyworded arguments to the<br> method <a href="#EventHandler-my_init">my_init</a>().<br> @type kargs: dict</tt></dd></dl> <dl><dt><a name="EventHandler-my_init"><strong>my_init</strong></a>(self, **kargs)</dt><dd><tt>This method is called from <a href="pyinotify.html#ProcessEvent">ProcessEvent</a>.<a href="#EventHandler-__init__">__init__</a>(). This method is<br> empty here and must be redefined to be useful. In effect, if you<br> need to specifically initialize your subclass' instance then you<br> just have to override this method in your subclass. Then all the<br> keyworded arguments passed to <a href="pyinotify.html#ProcessEvent">ProcessEvent</a>.<a href="#EventHandler-__init__">__init__</a>() will be<br> transmitted as parameters to this method. Beware you MUST pass<br> keyword arguments though.<br> <br> @param kargs: optional delegated arguments from <a href="#EventHandler-__init__">__init__</a>().<br> @type kargs: dict</tt></dd></dl> <dl><dt><a name="EventHandler-nested_pevent"><strong>nested_pevent</strong></a>(self)</dt></dl> <dl><dt><a name="EventHandler-process_IN_Q_OVERFLOW"><strong>process_IN_Q_OVERFLOW</strong></a>(self, event)</dt><dd><tt>By default this method only reports warning messages, you can overredide<br> it by subclassing <a href="pyinotify.html#ProcessEvent">ProcessEvent</a> and implement your own<br> process_IN_Q_OVERFLOW method. The actions you can take on receiving this<br> event is either to update the variable max_queued_events in order to<br> handle more simultaneous events or to modify your code in order to<br> accomplish a better filtering diminishing the number of raised events.<br> Because this method is defined, IN_Q_OVERFLOW will never get<br> transmitted as arguments to process_default calls.<br> <br> @param event: IN_Q_OVERFLOW event.<br> @type event: dict</tt></dd></dl> <dl><dt><a name="EventHandler-process_default"><strong>process_default</strong></a>(self, event)</dt><dd><tt>Default processing event method. By default does nothing. Subclass<br> <a href="pyinotify.html#ProcessEvent">ProcessEvent</a> and redefine this method in order to modify its behavior.<br> <br> @param event: Event to be processed. Can be of any type of events but<br> IN_Q_OVERFLOW events (see method process_IN_Q_OVERFLOW).<br> @type event: Event instance</tt></dd></dl> <hr> Data and other attributes inherited from <a href="pyinotify.html#ProcessEvent">pyinotify.ProcessEvent</a>:<br> <dl><dt><strong>pevent</strong> = None</dl> <hr> Methods inherited from <a href="pyinotify.html#_ProcessEvent">pyinotify._ProcessEvent</a>:<br> <dl><dt><a name="EventHandler-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl> <hr> Data descriptors inherited from <a href="pyinotify.html#_ProcessEvent">pyinotify._ProcessEvent</a>:<br> <dl><dt><strong>__dict__</strong></dt> <dd><tt>dictionary for instance variables (if defined)</tt></dd> </dl> <dl><dt><strong>__weakref__</strong></dt> <dd><tt>list of weak references to the object (if defined)</tt></dd> </dl> </td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#eeaa77"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> <td width="100%"><dl><dt><a name="-stop_watching"><strong>stop_watching</strong></a>()</dt><dd><tt>Stops the watch started by <a href="#-watch_dir">watch_dir</a>()<br> return: none</tt></dd></dl> <dl><dt><a name="-watch_dir"><strong>watch_dir</strong></a>(watched_dir='/home/nkenschaft', log_dir='SkoolOS/logs')</dt><dd><tt>Watches the specified directory for changes and outputs it in<br> human readable format to a log file in the specified log directory.<br> param watched_dir: directory to watch for changes<br> param log_dir: directory to store log files<br> return: none</tt></dd></dl> </td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#55aa55"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> <td width="100%"><strong>DIR</strong> = None<br> <strong>NOTIFIER</strong> = None<br> <strong>START_TIME</strong> = None<br> <strong>STDOUT</strong> = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'></td></tr></table> </body></html>