diff --git a/src/util.py b/src/util.py --- a/src/util.py +++ b/src/util.py @@ -5,7 +5,7 @@ import collections from datetime import datetime -def spawnDaemon(fun): +def spawn_daemon(fun): # do the UNIX double-fork magic, see Stevens' "Advanced # Programming in the UNIX Environment" for details (ISBN 0201563177) try: @@ -14,7 +14,7 @@ def spawnDaemon(fun): # parent process, return and keep running return except OSError as e: - print("fork #1 failed: {0} ({1})".format(e.errno,e.strerror),file=sys.stderr) + print("fork #1 failed: {0} ({1})".format(e.errno, e.strerror), file=sys.stderr) sys.exit(1) os.setsid() @@ -36,9 +36,9 @@ def spawnDaemon(fun): os._exit(os.EX_OK) -def splitHost(host, defaultPort=0): +def split_host(host, default_port=0): address, _, port = host.partition(":") - if not port: port = defaultPort + if not port: port = default_port return (address, port) @@ -61,7 +61,7 @@ class Progress: if len(self._past)==0 or (now-self._past[-1][0]).total_seconds()>1: self._past.append((now, i)) if res!=self._last or (now-self._past[0][0]).total_seconds()>5: - eta = formatSeconds(self.eta(i)) + eta = format_seconds(self.eta(i)) self._print("{0} (ETA {1})".format(res, eta)) self._last = res while (now-self._past[0][0]).total_seconds()>5: @@ -86,7 +86,7 @@ class Progress: print("\r"+s, end=end) -def formatSeconds(secs): +def format_seconds(secs): if math.isnan(secs): return "?" secs = round(secs) if secs<60: return "{0}s".format(secs)