Trying to implement a little script to move the older log files out of apache (actually using a simple bash script to do this in 'real life' - this is just an exercise to practice using Python). I'm getting the filename as a string as the variable f, but I want this to actually be a file when i pass it to self.processFile(root, f, age, inString).
I tried opening the actual file a few different ways, but I'm missing the target, and end up getting an error, a path that doesn't always seem to be correct, or just a string. I'll blame it on the late night, but I'm blanking on the best way to open f as a file right before passing to self.processFile (where it will be gzipped). Usually its something very simple that i'm missing, so I have to assume that's the case here. I'd appreciate any constructive advice/direction.
"""recursive walk through /usr/local/apache2.2/logs"""
for root, dirs, files in os.walk(basedir):
for f in files:
m=self.fileFormatRegex.match(f)
if m:
if (('access_log.' in f) or
('error.' in f) or
('access.' in f) or
('error_log.' in f) or
('mod_jk.log.' in f)):
#This is where i'd like to open the file using the filename f
self.processFile(root, f, age, inString)