mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[mod] style
This commit is contained in:
parent
dfbfc0cfc7
commit
d85657a5c6
1 changed files with 13 additions and 5 deletions
|
@ -399,30 +399,38 @@ def user_info(auth, username):
|
||||||
|
|
||||||
if 'mailuserquota' in user:
|
if 'mailuserquota' in user:
|
||||||
userquota = user['mailuserquota'][0]
|
userquota = user['mailuserquota'][0]
|
||||||
if isinstance( userquota, int ):
|
|
||||||
|
if isinstance(userquota, int):
|
||||||
userquota = str(userquota)
|
userquota = str(userquota)
|
||||||
|
|
||||||
# Test if userquota is '0' or '0M' ( quota pattern is ^(\d+[bkMGT])|0$ )
|
# Test if userquota is '0' or '0M' ( quota pattern is ^(\d+[bkMGT])|0$ )
|
||||||
is_limited = not re.match('0[bkMGT]?', userquota)
|
is_limited = not re.match('0[bkMGT]?', userquota)
|
||||||
storage_use = '?'
|
storage_use = '?'
|
||||||
|
|
||||||
cmd = 'doveadm -f flow quota get -u %s' % user['uid'][0]
|
cmd = 'doveadm -f flow quota get -u %s' % user['uid'][0]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cmd_result = subprocess.check_output(cmd,stderr=subprocess.STDOUT,
|
cmd_result = subprocess.check_output(cmd, stderr=subprocess.STDOUT,
|
||||||
shell=True)
|
shell=True)
|
||||||
# Exemple of return value for cmd:
|
# Exemple of return value for cmd:
|
||||||
# """Quota name=User quota Type=STORAGE Value=0 Limit=- %=0
|
# """Quota name=User quota Type=STORAGE Value=0 Limit=- %=0
|
||||||
# Quota name=User quota Type=MESSAGE Value=0 Limit=- %=0"""
|
# Quota name=User quota Type=MESSAGE Value=0 Limit=- %=0"""
|
||||||
has_value=re.search(r'Value=(\d+)', cmd_result)
|
has_value = re.search(r'Value=(\d+)', cmd_result)
|
||||||
|
|
||||||
if has_value:
|
if has_value:
|
||||||
storage_use = int(has_value.group(1))
|
storage_use = int(has_value.group(1))
|
||||||
storage_use = _convertSize(storage_use)
|
storage_use = _convertSize(storage_use)
|
||||||
|
|
||||||
if is_limited:
|
if is_limited:
|
||||||
has_percent=re.search(r'%=(\d+)', cmd_result)
|
has_percent = re.search(r'%=(\d+)', cmd_result)
|
||||||
|
|
||||||
if has_percent:
|
if has_percent:
|
||||||
percentage = int(has_percent.group(1))
|
percentage = int(has_percent.group(1))
|
||||||
storage_use += ' (%s%s)' % (percentage, '%')
|
storage_use += ' (%s%%)' % percentage
|
||||||
|
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
logger.warning(m18n.n('mailbox_used_space_dovecot_down'))
|
logger.warning(m18n.n('mailbox_used_space_dovecot_down'))
|
||||||
|
|
||||||
result_dict['mailbox-quota'] = {
|
result_dict['mailbox-quota'] = {
|
||||||
'limit' : userquota if is_limited else m18n.n('unlimit'),
|
'limit' : userquota if is_limited else m18n.n('unlimit'),
|
||||||
'use' : storage_use
|
'use' : storage_use
|
||||||
|
|
Loading…
Add table
Reference in a new issue