View | Details | Raw Unified | Return to bug 56575
Collapse All | Expand All

(-)base/univention-quota/umc/python/quota/tools.py (-5 / +4 lines)
Lines 42-49 import os Link Here
42
import re
42
import re
43
import subprocess
43
import subprocess
44
44
45
import tornado.process
46
47
import univention.management.console as umc
45
import univention.management.console as umc
48
from univention.config_registry import handler_set
46
from univention.config_registry import handler_set
49
from univention.lib import fstab
47
from univention.lib import fstab
Lines 83-89 class UserQuota(dict): Link Here
83
            self[time] = value
81
            self[time] = value
84
82
85
83
86
def repquota(partition, callback):
84
def repquota(partition):
87
    # find filesystem type
85
    # find filesystem type
88
    fs = fstab.File()
86
    fs = fstab.File()
89
    part = fs.find(spec=partition)
87
    part = fs.find(spec=partition)
Lines 94-101 def repquota(partition, callback): Link Here
94
    # -C == do not try to resolve all users at once
92
    # -C == do not try to resolve all users at once
95
    # -v == verbose
93
    # -v == verbose
96
    cmd = ['/usr/sbin/repquota', '-C', '-v', partition] + args
94
    cmd = ['/usr/sbin/repquota', '-C', '-v', partition] + args
97
    proc = tornado.process.Subprocess(cmd, stdout=subprocess.PIPE)
95
    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
98
    proc.set_exit_callback(functools.partial(callback, proc.stdout))
96
    stdout, stderr = proc.communicate()
97
    return (stdout, proc.returncode)
99
98
100
99
101
def repquota_parse(partition, output):
100
def repquota_parse(partition, output):
(-)base/univention-quota/umc/python/quota/user.py (-6 / +9 lines)
Lines 42-48 from univention.lib import fstab Link Here
42
from univention.management.console import Translation
42
from univention.management.console import Translation
43
from univention.management.console.error import UMC_Error
43
from univention.management.console.error import UMC_Error
44
from univention.management.console.log import MODULE
44
from univention.management.console.log import MODULE
45
from univention.management.console.modules.decorators import sanitize, simple_response, threaded
45
from univention.management.console.modules.decorators import sanitize, simple_response, threaded, SimpleThread
46
from univention.management.console.modules.quota import tools
46
from univention.management.console.modules.quota import tools
47
from univention.management.console.modules.sanitizers import IntegerSanitizer, PatternSanitizer, StringSanitizer
47
from univention.management.console.modules.sanitizers import IntegerSanitizer, PatternSanitizer, StringSanitizer
48
48
Lines 68-75 class Commands(object): Link Here
68
        partitionDevice = request.options['partitionDevice']
68
        partitionDevice = request.options['partitionDevice']
69
        self._check_error(partitionDevice)
69
        self._check_error(partitionDevice)
70
70
71
        callback = functools.partial(self._users_query, partitionDevice, request)
71
        def _thread(request):
72
        tools.repquota(request.options['partitionDevice'], callback)
72
            stdout, returncode = tools.repquota(request.options['partitionDevice'])
73
            return self._users_query(partitionDevice, request, stdout, returncode)
74
75
        thread = SimpleThread('repquota', _thread, lambda r, t: self.thread_finished_callback(r, t, request))
76
        thread.run(request)
73
77
74
    def _users_query(self, partition, request, stdout, status):
78
    def _users_query(self, partition, request, stdout, status):
75
        """
79
        """
Lines 82-88 class Commands(object): Link Here
82
        devs = fstab.File()
86
        devs = fstab.File()
83
        devs.find(spec=partition)
87
        devs.find(spec=partition)
84
88
85
        callbackResult = stdout.read().splitlines()
89
        callbackResult = stdout.splitlines()
86
90
87
        # skip header
91
        # skip header
88
        header = 0
92
        header = 0
Lines 93-100 class Commands(object): Link Here
93
            pass
97
            pass
94
        output = [x.decode('UTF-8', 'replace') for x in callbackResult[header + 1:]]
98
        output = [x.decode('UTF-8', 'replace') for x in callbackResult[header + 1:]]
95
        quotas = tools.repquota_parse(partition, output)
99
        quotas = tools.repquota_parse(partition, output)
96
        result = [q for q in quotas if request.options['filter'].match(q['user'])]
100
        return [q for q in quotas if request.options['filter'].match(q['user'])]
97
        self.finished(request.id, result)
98
101
99
    @sanitize(
102
    @sanitize(
100
        partitionDevice=StringSanitizer(required=True),
103
        partitionDevice=StringSanitizer(required=True),

Return to bug 56575