python safe scripting

Simon Hibbs simon.hibbs at
Fri Nov 23 19:47:21 CET 2007

> > 2007/11/21, Vladimir Rusinov <vladi... at>:

> Yes, but apache, nginx and others does not uses logger.
> I wanna write an application which would handle all my (Linux) logs:
> rotating, compressing, analysing and so on (logrotate replacement), it would
> require some nontrivial configuration, something like "If size of this log
> bigger then 2Mb or today is sunday. If size of this log bigger then 30 Mb,
> and today is not sunday, then rotate it, and make alert".
> Is there any module to parse such configuration files?

I don't think there's a module for this. Those kinds of tests are
fairly easy though.

import datetime, os

filename = 'myfile.log'
if ( == 0) or (os.stat(filename)[6] >

The individual tests would be better wrapped in utility functions of

Simon Hibbs

More information about the Python-list mailing list