Part of lp.services.apachelogparser.script View In Hierarchy
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.|
|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||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.|
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.
|Parameters||path||The requested path.|
|Returns||A hashable object identifying the object at the path, or None if a request with this path should be ignored.|
|Parameters||file_id||The download key as calculated by getDownloadKey.|
|Returns||A count updating function, called as f(day, country, count), or None if the count should not be updated (eg. target deleted).|
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.