summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/Utils.py14
-rw-r--r--module/plugins/Account.py4
-rw-r--r--module/remote/thriftbackend/ThriftClient.py2
3 files changed, 16 insertions, 4 deletions
diff --git a/module/Utils.py b/module/Utils.py
index 2d8a0423e..5f36c2d77 100644
--- a/module/Utils.py
+++ b/module/Utils.py
@@ -37,17 +37,27 @@ def compare_time(start, end):
elif start < now and end < now and start > end: return True
else: return False
+def formatSize(size):
+ """formats size of bytes"""
+ size = int(size)
+ steps = 0
+ sizes = ["B", "KiB", "MiB", "GiB", "TiB"]
+ while size > 1000:
+ size /= 1024.0
+ steps += 1
+ return "%.2f %s" % (size, sizes[steps])
+
def freeSpace(folder):
if sys.platform == 'nt':
import ctypes
free_bytes = ctypes.c_ulonglong(0)
ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(folder), None, None, ctypes.pointer(free_bytes))
- return free_bytes.value / 1024 / 1024 #megabyte
+ return free_bytes.value
else:
from os import statvfs
s = statvfs(folder)
- return s.f_bsize * s.f_bavail / 1024 / 1024 #megabyte
+ return s.f_bsize * s.f_bavail
def uniqify(seq, idfun=None):
# order preserving
diff --git a/module/plugins/Account.py b/module/plugins/Account.py
index ae9038eed..b8de4ddf0 100644
--- a/module/plugins/Account.py
+++ b/module/plugins/Account.py
@@ -22,6 +22,8 @@ from random import choice
from time import time
from traceback import print_exc
+from module.utils import compare_time
+
class WrongPassword(Exception):
pass
@@ -164,7 +166,7 @@ class Account():
try:
time_data = data["options"]["time"][0]
start, end = time_data.split("-")
- if not self.core.compare_time(start.split(":"), end.split(":")):
+ if not compare_time(start.split(":"), end.split(":")):
continue
except:
self.core.log.warning(_("Your Time %s has wrong format, use: 1:22-3:44") % time_data)
diff --git a/module/remote/thriftbackend/ThriftClient.py b/module/remote/thriftbackend/ThriftClient.py
index 68c2d25ed..9fcabc4e7 100644
--- a/module/remote/thriftbackend/ThriftClient.py
+++ b/module/remote/thriftbackend/ThriftClient.py
@@ -24,7 +24,7 @@ class NoConnection(Exception):
class NoSSL(Exception):
pass
-class ThriftClient():
+class ThriftClient:
def __init__(self, host="localhost", port=7228, user="", password=""):
self.createConnection(host, port)