| 1 | From: Tobias Geerinckx-Rice <[email protected]>
|
| 2 | Date: Sun, 16 Jun 2019 02:34:10 +0200
|
| 3 | Subject: [PATCH] gnu: dstat: Fix crash when specifying a delay.
|
| 4 |
|
| 5 | Taken verbatim from a pull request[0] that will never be merged.
|
| 6 |
|
| 7 | [0]: https://github.com/dagwieers/dstat/pull/167
|
| 8 |
|
| 9 | From 220a785321b13b6df92a536080aca6ef1cb644ad Mon Sep 17 00:00:00 2001
|
| 10 | From: Falko Goettsch <[email protected]>
|
| 11 | Date: Mon, 11 Mar 2019 20:12:49 -0700
|
| 12 | Subject: [PATCH] Fixed bug when specifying a delay
|
| 13 |
|
| 14 | The division in the 'loop' calculation in perform() was returning floating point values
|
| 15 | after the migration to Python 3, rather than rounding down. Changed to floor division.
|
| 16 |
|
| 17 | I think the floating point values kept 'loop == 0' from ever being
|
| 18 | true and the variables inside that conditional were never initialized,
|
| 19 | causing the following error when a delay other than 1 was specified:
|
| 20 |
|
| 21 | You did not select any stats, using -cdngy by default.
|
| 22 | Traceback (most recent call last):
|
| 23 | File "/home/falko/repos/dstat/dstat", line 2825, in <module>
|
| 24 | main()
|
| 25 | File "/home/falko/repos/dstat/dstat", line 2684, in main
|
| 26 | scheduler.run()
|
| 27 | File "/home/falko/.conda/envs/python3/lib/python3.7/sched.py", line 151, in run
|
| 28 | action(*argument, **kwargs)
|
| 29 | File "/home/falko/repos/dstat/dstat", line 2729, in perform
|
| 30 | oldcols = cols
|
| 31 | NameError: name 'cols' is not defined
|
| 32 | ---
|
| 33 | dstat | 2 +-
|
| 34 | 1 file changed, 1 insertion(+), 1 deletion(-)
|
| 35 |
|
| 36 | diff --git a/dstat b/dstat
|
| 37 | index 9359965..3b4980f 100755
|
| 38 | |
| 39 | |
| 40 | @@ -2697,7 +2697,7 @@ def perform(update):
|
| 41 |
|
| 42 | starttime = time.time()
|
| 43 |
|
| 44 | - loop = (update - 1 + op.delay) / op.delay
|
| 45 | + loop = (update - 1 + op.delay) // op.delay
|
| 46 | step = ((update - 1) % op.delay) + 1
|
| 47 |
|
| 48 | ### Get current time (may be different from schedule) for debugging
|