summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2020-07-16 19:08:37 +0100
committerBen Hutchings <ben.hutchings@codethink.co.uk>2020-07-16 19:08:37 +0100
commit8daa6330396b7adbf408755882283f1520b48944 (patch)
tree3e0353da83c4bcc103319650c32c433073eb47c6
parentc93409d4493f1374d626f21f9f68def3a88f09a6 (diff)
downloadlorry-controller-8daa6330396b7adbf408755882283f1520b48944.tar.gz
status: Use integer division where appropriate
In Python 2, the / operator between two integer-typed values produces another integer. In Python 3, it produces a float. We need to use the // operator to get the old behaviour. The change to floats in get_free_disk_space resulted in unnecessarily precise values for free disk space. The change in formats_secs_nicely doesn't seem to make a difference since we format the quotients with '%d', but I'm making it use // so it's clearer what we want. Closes #14.
-rw-r--r--lorrycontroller/status.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/lorrycontroller/status.py b/lorrycontroller/status.py
index 8fbc1b7..8483485 100644
--- a/lorrycontroller/status.py
+++ b/lorrycontroller/status.py
@@ -103,8 +103,8 @@ class StatusRenderer(object):
free_bytes = result.f_bavail * result.f_bsize
return {
'disk_free': free_bytes,
- 'disk_free_mib': free_bytes / 1024**2,
- 'disk_free_gib': free_bytes / 1024**3,
+ 'disk_free_mib': free_bytes // 1024**2,
+ 'disk_free_gib': free_bytes // 1024**3,
}
def get_run_queue(self, statedb):
@@ -130,9 +130,9 @@ class StatusRenderer(object):
result = []
- hours = secs / 3600
+ hours = secs // 3600
secs %= 3600
- mins = secs / 60
+ mins = secs // 60
secs %= 60
if hours > 0: