Completed
Push — master ( 15c423...616cf9 )
by Kale
64:00
created

is_admin_on_unix()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2012 Anaconda, Inc
3
# SPDX-License-Identifier: BSD-3-Clause
4
from __future__ import absolute_import, division, print_function, unicode_literals
5
6
import os
7
8
from logging import getLogger
9
10
11
log = getLogger(__name__)
12
13
14
def get_free_space_on_unix(dir_name):
15
    st = os.statvfs(dir_name)
16
    return st.f_bavail * st.f_frsize
17
18
19
def is_admin_on_unix():
20
    # http://stackoverflow.com/a/1026626/2127762
21
    return os.geteuid() == 0 or os.getegid() == 0
22