Comenzado del desarrollo de Gestor.py

parent 4edf1a54
This diff could not be displayed because it is too large.
import Dato
from Dato import Dato
def identificacionUsuarios(reg):
aux=[]
ret=[]
#Cojo las IPs distintas del conjunto de datos
for r in reg:
aux.append(r.hostRemoto)
aux=set(aux)
#Ordeno los distintos registros de cada usuario de mas antiguos a mas nuevos
for usuario in aux:
con=[]
for r in reg:
if r.hostRemoto==usuario:
con.append(r)
#Ordeno
for i in range(len(con)):
for j in range(len(con)):
if con[i].marcaTiempo > con[j].marcaTiempo:
con[i],con[j]=con[j],con[i]
ret+=con
return ret
def leerFicheroLog(ruta):
registros=[]
f = open(ruta, "r")
total=0
for linea in f:
total+=1
try:
registros.append(Dato(linea))
except:
continue
f.close()
print("Procesados ",len(registros)," registros")
return registros
def leerFicheroLogEliminarFiltradas(ruta,extensionesNoDeseadas):
registros=[]
f = open(ruta, "r")
total=0
for linea in f:
total+=1
try:
aux=Dato(linea)
admitido=True
for ext in extensionesNoDeseadas:
if ext in aux.url:
admitido=false
if admitido:
registros.append(aux)
except:
continue
f.close()
print("Procesados ",len(registros)," registros")
return registros
def leerFicheroLogAceptarFiltradas(ruta,extensionesNoDeseadas):
registros=[]
f = open(ruta, "r")
total=0
for linea in f:
total+=1
try:
aux=Dato(linea)
admitido=False
for ext in extensionesNoDeseadas:
if ext in aux.url:
admitido=True
if admitido:
registros.append(aux)
except:
continue
f.close()
print("Procesados ",len(registros)," registros")
return registros
registros=leerFicheroLog("../access_log_Aug95_reducido")
registros=identificacionUsuarios(registros)
for i in registros:
print(i.hostRemoto," ",i.marcaTiempo)
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment