bgservice.bgservice
index
/home/nkenschaft/Sysadmin/skoolos/bgservice/bgservice.py

A simple background service to log events in a directory,
check for git commands in bash/zsh history,
and check for non-whitelisted files in the watched directory.

 
Modules
       
bgservice.checker
os
pyinotify
sys
time

 
Classes
       
pyinotify.ProcessEvent(pyinotify._ProcessEvent)
EventHandler

 
class EventHandler(pyinotify.ProcessEvent)
    EventHandler(pevent=None, **kargs)
 
Custom event handler for watching a SkoolOS work directory
 
 
Method resolution order:
EventHandler
pyinotify.ProcessEvent
pyinotify._ProcessEvent
builtins.object

Methods defined here:
process_IN_CLOSE_WRITE(self, event)
Generates an output to record for IN_CLOSE_WRITE events
param event: event automatically passed to function
return: none
process_IN_CREATE(self, event)
Generates an output to record for IN_CREATE events
param event: event automatically passed to function
return: none
process_IN_DELETE(self, event)
Generates an output to record for IN_DELETE events
param event: event automatically passed to function
return: none
process_IN_MOVED_FROM(self, event)
Generates an output to record for IN_MOVED_FROM events
param event: event automatically passed to function
return: none
process_IN_MOVED_TO(self, event)
Generates an output to record for IN_MOVED_TO events
param event: event automatically passed to function
return: none
process_IN_OPEN(self, event)
Generates an output to record for IN_OPEN events
param event: event automatically passed to function
return: none

Methods inherited from pyinotify.ProcessEvent:
__call__(self, event)
To behave like a functor the object must be callable.
This method is a dispatch method. Its lookup order is:
  1. process_MASKNAME method
  2. process_FAMILY_NAME method
  3. otherwise calls process_default
 
@param event: Event to be processed.
@type event: Event object
@return: By convention when used from the ProcessEvent class:
         - Returning False or None (default value) means keep on
         executing next chained functors (see chain.py example).
         - Returning True instead means do not execute next
           processing functions.
@rtype: bool
@raise ProcessEventError: Event object undispatchable,
                          unknown event.
__init__(self, pevent=None, **kargs)
Enable chaining of ProcessEvent instances.
 
@param pevent: Optional callable object, will be called on event
               processing (before self).
@type pevent: callable
@param kargs: This constructor is implemented as a template method
              delegating its optionals keyworded arguments to the
              method my_init().
@type kargs: dict
my_init(self, **kargs)
This method is called from ProcessEvent.__init__(). This method is
empty here and must be redefined to be useful. In effect, if you
need to specifically initialize your subclass' instance then you
just have to override this method in your subclass. Then all the
keyworded arguments passed to ProcessEvent.__init__() will be
transmitted as parameters to this method. Beware you MUST pass
keyword arguments though.
 
@param kargs: optional delegated arguments from __init__().
@type kargs: dict
nested_pevent(self)
process_IN_Q_OVERFLOW(self, event)
By default this method only reports warning messages, you can overredide
it by subclassing ProcessEvent and implement your own
process_IN_Q_OVERFLOW method. The actions you can take on receiving this
event is either to update the variable max_queued_events in order to
handle more simultaneous events or to modify your code in order to
accomplish a better filtering diminishing the number of raised events.
Because this method is defined, IN_Q_OVERFLOW will never get
transmitted as arguments to process_default calls.
 
@param event: IN_Q_OVERFLOW event.
@type event: dict
process_default(self, event)
Default processing event method. By default does nothing. Subclass
ProcessEvent and redefine this method in order to modify its behavior.
 
@param event: Event to be processed. Can be of any type of events but
              IN_Q_OVERFLOW events (see method process_IN_Q_OVERFLOW).
@type event: Event instance

Data and other attributes inherited from pyinotify.ProcessEvent:
pevent = None

Methods inherited from pyinotify._ProcessEvent:
__repr__(self)
Return repr(self).

Data descriptors inherited from pyinotify._ProcessEvent:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
stop_watching()
Stops the watch started by watch_dir()
return: none
watch_dir(watched_dir='/home/nkenschaft', log_dir='SkoolOS/logs')
Watches the specified directory for changes and outputs it in
human readable format to a log file in the specified log directory.
param watched_dir: directory to watch for changes
param log_dir: directory to store log files
return: none

 
Data
        DIR = None
NOTIFIER = None
START_TIME = None
STDOUT = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>