File: test_getqcarg.py

package info (click to toggle)
python-fsquota 0.1.0%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 392 kB
  • sloc: ansic: 2,670; python: 545; makefile: 8
file content (34 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python3
#
# Author: T. Zoerner
#
# This program is in the public domain and can be used and
# redistributed without restrictions.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

import os
import sys
from stat import *
import FsQuota

try:
    for fsname, path, fstyp, opt in FsQuota.MntTab():
        try:
            qObj = FsQuota.Quota(path)
            qcarg = qObj.dev
        except:
            qcarg = "*UNDEF*"

        try:
            st_dev = os.stat(path).st_dev
        except OSError:
           st_dev = -1

        print("%s # %s # %s # %s # %d # %s #"
                    % (fsname, path, fstyp, opt, st_dev, qcarg))

except FsQuota.error as e:
    print("ERROR: %s" % e, file=sys.stderr)