l.s.a.s.ParseApacheLogs(LaunchpadCronScript) : class documentation

Part of lp.services.apachelogparser.script View In Hierarchy

An abstract Apache log parser, finding download counts for each file.

This does the heavy lifting to turn a directory of Apache log files into a structure mapping files to days to countries to download counts.

Subclasses should override root, getDownloadKey, getDownloadCountUpdater, and optionally setUpUtilities.

Method setUpUtilities Prepare any utilities that might be used many times.
Method root Root directory in which to find the logs.
Method getDownloadKey Generate a value to use as a key in the download dict.
Method getDownloadCountUpdater Return a function which updates the download count of the object.
Method main Define the meat of your script here. Must be defined.

Inherited from LaunchpadCronScript:

Method __init__ Construct new LaunchpadScript.
Method get_last_activity Return the last activity, if any.
Method record_activity Record the successful completion of the script.

Inherited from LaunchpadScript (via LaunchpadCronScript):

Method handle_options Undocumented
Method name Enable subclasses to override with command-line arguments.
Method dbuser Enable subclasses to override with command-line arguments.
Method add_my_options Optionally customize this hook to define your own options.
Method login Super-convenience method that avoids the import.
Method lockfilename Return lockfilename.
Method lockfilepath Undocumented
Method setup_lock Create lockfile.
Method lock_or_die Attempt to lock, and sys.exit(1) if the lock's already taken.
Method unlock Release the lock. Do this before going home.
Method run Actually run the script, executing zcml and initZopeless.
Method lock_and_run Call lock_or_die(), and then run() the script.
Method _init_zca Initialize the ZCA, this can be overridden for testing purposes.
Method _init_db Initialize the database transaction.
def setUpUtilities(self):
Prepare any utilities that might be used many times.
@property
def root(self):
Root directory in which to find the logs.
def getDownloadKey(self, path):
Generate a value to use as a key in the download dict.

This will be called for every log line, so it should be very cheap. It's probably best not to return any complex objects, as there will be lots and lots and lots of these results sitting around for quite some time.

ParameterspathThe requested path.
ReturnsA hashable object identifying the object at the path, or None if a request with this path should be ignored.
def getDownloadCountUpdater(self, file_id):
Return a function which updates the download count of the object.
Parametersfile_idThe download key as calculated by getDownloadKey.
ReturnsA count updating function, called as f(day, country, count), or None if the count should not be updated (eg. target deleted).
def main(self):
Define the meat of your script here. Must be defined.

Raise LaunchpadScriptFailure if you encounter an error condition that makes it impossible for you to proceed; sys.exit(1) will be invoked in that situation.

API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.