summaryrefslogtreecommitdiff
path: root/src/backend/checkenv.py
blob: 124ba76f5ab5c67197d34d6a4f8706d3d4354102 (plain)
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
35
36
37
38
39
40
41
#!/usr/bin/python3

import os
import subprocess
import sisyphus.getenv
import urllib.request


def connectivity():
    is_online = int()

    try:
        urllib.request.urlopen("http://www.google.com", timeout=5)
        is_online = int(1)
    except urllib.error.URLError:
        is_online = int(0)

    return is_online


def root():
    return True if os.getuid() == 0 else False


def sanity():
    actv_brch = sisyphus.getenv.sys_brch()
    bhst_addr = sisyphus.getenv.bhst_addr()
    is_sane = int()

    if "packages-next" in bhst_addr:
        if actv_brch == "next":
            is_sane = int(1)
        else:
            is_sane = int(0)
    else:
        if actv_brch == "master":
            is_sane = int(1)
        else:
            is_sane = int(0)

    return is_sane