X-Git-Url: https://svn.cri.ensmp.fr/git/minwii.git/blobdiff_plain/18017198ab84bb6482239ff5b621cd490b144c9a..a07152998dd50dab4e31a809158b3f5b430ac094:/src/minwii/logapp.py diff --git a/src/minwii/logapp.py b/src/minwii/logapp.py index a632d60..176d179 100755 --- a/src/minwii/logapp.py +++ b/src/minwii/logapp.py @@ -9,9 +9,11 @@ $URL$ from Tkinter import * import tkFileDialog from glob import glob +import os from os.path import join as pjoin from os.path import basename -from loganalyse import LogFileAnalyser +from os.path import getsize +from minwii.loganalyse import LogFileAnalyser from pprint import pprint class Application(Frame) : @@ -64,12 +66,27 @@ class Application(Frame) : self.logDir = tkFileDialog.askdirectory() if self.logDir : self.logFiles = glob(pjoin(self.logDir, '*.log')) + self._cleanupJunkFiles() self.logFiles.sort() self.dataFrame.grid(row=0, column=0, sticky=NW) self.nav.setSize(len(self.logFiles)) self.nav.grid(row=0, column=1) self.loadLogFile(self.nav) + def _cleanupJunkFiles(self) : + files = [] + while self.logFiles : + f = self.logFiles.pop() + if not getsize(f) : + os.remove(f) + continue + # TODO : vérifier qu'il existe des événements + else : + files.append(f) + + self.logFiles = files + + def loadLogFile(self, nav) : index = nav.index - 1 filepath = self.logFiles[index]