# HG changeset patch # User Pascal Volk # Date 1297448557 0 # Node ID 7f931c1ca0591fe6ddd659f09a67f498bb48defd # Parent 0a13849243f205d84469e5ef068db63c27229575 VMM/common: human_size() size argument can be also a string. Because the default value of misc.quota_bytes is '0', a string in order to accept also settings like '500M'. diff -r 0a13849243f2 -r 7f931c1ca059 VirtualMailManager/common.py --- a/VirtualMailManager/common.py Fri Feb 11 11:52:59 2011 +0000 +++ b/VirtualMailManager/common.py Fri Feb 11 18:22:37 2011 +0000 @@ -69,8 +69,13 @@ def human_size(size): """Converts the `size` in bytes in human readable format.""" - if not isinstance(size, (long, int)) or size < 0: - raise TypeError("'size' must be a positive long or int.") + if not isinstance(size, (long, int)): + try: + size = long(size) + except ValueError: + raise TypeError("'size' must be a positive long or int.") + if size < 0: + raise ValueError("'size' must be a positive long or int.") if not size: return '0b' unit_limit = (('T', 1 << 40), ('G', 1 << 30), ('M', 1 << 20),