I am attempting to read the access log for squid and store the last position read so it does not have to reread the file. I am running into many problems with my current code for it. I was wondering if you can help me write a more efficient code and/or help with my current error which is:
Traceback (most recent call last):
File "./bot.py", line 22, in <module>
update_cache()
File "./bot.py", line 14, in update_cache
mapa = mmap.mmap(f.fileno(),0)
mmap.error: [Errno 13] Permission denied
The permissions for that file is: -rwxrwxrwx 1 nobody nobody 3665356 Dec 17 19:03 /var/logs/squid/access.log
the function for updating the cache of the file:
def update_cache():
global i
global mapa
with open("/var/logs/squid/access.log", 'r') as f:
f.seek(i)
mapa = mmap.mmap(f.fileno(),0)
u = 0
mapa.write(line)
u += 1
print("%d : %s", u, line)
i = f.tell()
f.close()
I almost forgot to say I am using python 3.1.1