File: 0014-performancecounter-handle-empty-result-gracefully.patch

package info (click to toggle)
pyrit 0.5.1%2Bgit20180801-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,596 kB
  • sloc: python: 4,667; ansic: 3,352; cpp: 1,490; asm: 394; lisp: 192; makefile: 15; sed: 7; sh: 6
file content (26 lines) | stat: -rw-r--r-- 1,031 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
From: Christian Kastner <ckk@kvr.at>
Date: Wed, 13 Apr 2011 21:16:23 +0200
Subject: PerformanceCounter: handle empty result gracefully

Handle cases in which no result is produced (eg: because of a window timeout)
gracefully.

Bug: http://code.google.com/p/pyrit/issues/detail?id=293
Bug-Debian: http://bugs.debian.org/620991
Origin: other, http://code.google.com/p/pyrit/issues/detail?id=293
Forwarded: not-needed
Last-Update: 2011-04-17

Index: pyrit-0.4.0/cpyrit/util.py
===================================================================
--- pyrit-0.4.0.orig/cpyrit/util.py	2011-04-13 21:21:49.063998293 +0200
+++ pyrit-0.4.0/cpyrit/util.py	2011-04-13 21:22:20.419996889 +0200
@@ -374,7 +374,7 @@
 
     def __purge(self):
         t = time.time()
-        if t - self.datapoints[0][0] > self.window:
+        if len(self.datapoints) > 0 and t - self.datapoints[0][0] > self.window:
             self.datapoints = filter(lambda x: (t - x[0]) < self.window, \
                                                 self.datapoints)