~activity-log-manager/activity-log-manager/trunk

« back to all changes in this revision

Viewing changes to alm/crawler.py

  • Committer: Karl Relton
  • Date: 2012-01-20 15:10:50 UTC
  • Revision ID: karllinuxtest.relton@ntlworld.com-20120120151050-74gthtsglgeoekn0
Corrected timerange checking, and also avoided a potential divide by zero bug.

Should fix LP: #903791

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
 
78
78
        def _process(self):
79
79
                valid_files = set(self._retrieved_subjects) - set(self._sub_hash)
80
 
 
81
80
                valid_uris = []
82
81
                for key in valid_files:
83
82
                        valid_uris.append(self._retrieved_subjects[key])
84
83
 
85
84
                self.progress.set_pulse_step(
86
 
                        ((1 - self.progress.get_fraction()) / len(valid_uris)) * (2.0 / 3))
 
85
                        ((1 - self.progress.get_fraction()) / (len(valid_uris) + 1)) * (2.0 / 3))
87
86
 
88
87
                events = map(self._create_new_event, valid_uris)
89
88
                events = [e for e in events if e]
122
121
 
123
122
                        event = Event()
124
123
                        event.interpretation = Interpretation.CREATE_EVENT
125
 
                        event.manifestation = Manifestation.HEURISTIC_ACTIVITY
 
124
                        event.manifestation = Manifestation.USER_ACTIVITY
126
125
                        event.timestamp = str(int(1000 * os.path.getmtime(subject.uri[len(Crawler.FILE_SCHEME):])))
127
 
 
128
 
                        if event.timestamp >= self.timerange[0] and event.timestamp <= self.timerange[1]:
 
126
                        if int(event.timestamp) >= self.timerange[0] and int(event.timestamp) <= self.timerange[1]:
129
127
                                event.subjects = [subject]
130
128
                                event.actor = Crawler._actor
131
129
                                return event
141
139
                                self._sub_hash.append(hash(uri))
142
140
 
143
141
                self.progress.set_fraction(self.progress.get_fraction() + 0.1)
144
 
 
145
142
                self._finished()
146
143
 
147
144
        def _retrieve_subjects(self):
157
154
                                        self._retrieved_subjects[hash(uri)] = uri
158
155
 
159
156
                self.progress.set_fraction(self.progress.get_fraction() + 0.1)
160
 
 
161
157
                self._finished()