summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-wireless/eyefiserver/files/human_readable.patch')
-rw-r--r--net-wireless/eyefiserver/files/human_readable.patch52
1 files changed, 52 insertions, 0 deletions
diff --git a/net-wireless/eyefiserver/files/human_readable.patch b/net-wireless/eyefiserver/files/human_readable.patch
new file mode 100644
index 0000000..707e54d
--- /dev/null
+++ b/net-wireless/eyefiserver/files/human_readable.patch
@@ -0,0 +1,52 @@
+# Display transfer message as INFO and not as DEBUG.
+# Display kbps as human readable speed.
+
+--- src/eyefiserver.orig 2012-10-17 15:44:55.000000000 +0200
++++ src/eyefiserver 2013-01-29 16:46:50.315732000 +0100
+@@ -81,6 +81,19 @@
+ eyeFiLogger = logging.Logger("eyeFiLogger", logging.DEBUG)
+
+
++def human_bps(bps):
++ """
++ human-readable bytes per second, e.g. 13 KB/s, 4.1 MB/s, 102 bytes/s, etc.
++ """
++ bps = float(bps)
++ if bps < 1024:
++ return "%d Byte%s/s" % (bps, bps != 1 and "s" or "")
++ if bps < 1024 * 1024:
++ return "%.1f KB/s" % (bps / 1024)
++ if bps < 1024 * 1024 * 1024:
++ return "%.1f MB/s" % (bps / (1024 * 1024))
++ return "%.1f GB/s" % (bps / (1024 * 1024 * 1024))
++
+
+ class IntegrityDigestFile(file):
+ """
+@@ -610,13 +623,14 @@
+ + elapsed_time.seconds \
+ + elapsed_time.microseconds / 1000000.
+
+- speed = (received_length-speedtest_startsize)/elapsed_seconds*8
+- eyeFiLogger.debug("%s: Read %s / %s bytes (%02.02f%%) %d kbps",
++ speed = (received_length - speedtest_startsize) / elapsed_seconds * 8
++ human_speed = human_bps(speed)
++ eyeFiLogger.info("%s: Read %s / %s bytes (%02.02f%%) %s",
+ soapdata['filename'],
+ received_length,
+ content_length,
+ received_length * 100. / content_length,
+- speed/1000
++ human_speed
+ )
+
+ speedtest_starttime = datetime.utcnow()
+@@ -629,7 +643,7 @@
+ execute_cmd = [execute_cmd,
+ tarpath,
+ str(tarfinalsize),
+- str(speed)]
++ human_speed]
+ eyeFiLogger.debug('Executing command "%s"',
+ ' '.join(execute_cmd))
+ subprocess.Popen(execute_cmd)