Esempio n. 1
0
def bc_words():
    try:
        tmp = len(hl_utils.shexec("pdftotext {} -".format(\
                    hl_utils.hlpath(".bcpdf",use_hostname=False))).split(" "))
        with open(hl_utils.hlpath(BC_WORD_LOG), 'w') as g:
            g.write(str(tmp))
    except subprocess.CalledProcessError:
        pass
Esempio n. 2
0
def cip_logins(ignore=""):
    MAX_LOGINS = 5
    cmd = "wget -q -O- --user cip --password " + pw(
    ) + " 'https://atlantishq.de:/cipactive/active_logins'"
    try:
        l = hl_utils.shexec(cmd).split("\n")
    except:
        return ""

    if len(l) > MAX_LOGINS:
        ret = hl_utils.color_panel("Logins: " + str(len(l)), RED)
    elif len(l) <= 1:
        ret = ""
    else:
        #color = hl_utils.get_color(len(l),0,MAX_LOGINS+3)
        #color = color[0:2]+color[4:6]+color[2:4]+color[6:8]

        ret = ''
        l = sorted(l)
        for line in l:
            if line == '' or line == ignore:
                continue
            ret = ret + line + ", "
        ret = ret[:-len(", ")]
        ret = hl_utils.color_panel("Logins: " + ret, GREEN)
    with open(hl_utils.hlpath(LOGINS_LOG), 'w') as f:
        f.write(ret)
Esempio n. 3
0
def quota():
    q = ''
    if not hl_utils.is_cip():
        return ''
    else:
        with open(hl_utils.hlpath("quota.cip")) as f:
            return f.read()
Esempio n. 4
0
def quota():
    if True:
        return
    if hl_utils.is_cip():
        q = hl_utils.shexec("cip-quota")
        ciptmp = "WTF"
        home = "WTF"
        test = []
        print(q)
        for l in q:
            test += [l]

        try:
            #if l.endswith("ciptmp\n"):
            ciptmp = test[2].split("(")[1].split(")")[0]
            #elif l.endswith("ik15ydit\n"):
            home = test[1].split("(")[1].split(")")[0]
            #break
        except Exception:
            return

        tmp = "Quota: " + home + "/" + ciptmp
        with open(hl_utils.hlpath("quota.cip"), "w") as f:
            print(tmp)
            f.write(tmp)
Esempio n. 5
0
def pw():
    pw = "NOPE"
    try:
        with open(hl_utils.hlpath("password.cip", False)) as f:
            return f.read().strip("\n")
    except:
        return ""
Esempio n. 6
0
def bcw():
    try:
        with open(hl_utils.hlpath(BC_WORD_LOG), 'r') as f:
            tmp = int(f.read())
            string = "{} words".format(tmp)
            return hl_utils.color_panel(
                string, hl_utils.get_color(tmp, 0, 7000, reverse=False))
    except:
        return ""
Esempio n. 7
0
def guthaben():
    guthaben = ''
    if hl_utils.is_cip():
        raw = ""
        with open(hl_utils.hlpath(PRINT_LOG)) as f:
            raw = f.read()
        guthaben = "Druckerguthaben: " + raw + " Euro"
        col = hl_utils.get_color(float(raw), 0, COLOR_BORDER)
        guthaben = hl_utils.color_panel(guthaben, col)
    return guthaben
Esempio n. 8
0
def ip():
    try:
        with open(hl_utils.hlpath(IP_LOG)) as f:
            tmp = f.read()
            if "[" in tmp:
                tmp = hl_utils.color_panel("Public IP: IP6 ", GREEN)
            tmp = ' ' + tmp
            return tmp
    except Exception:
        return hl_utils.color_panel("Public IP: No Data", YELLOW)
Esempio n. 9
0
def trace_login():
    if hl_utils.is_cip():
        try:
            tmp = hl_utils.shexec(
                "wget --timeout=3 -O- --user cip --password " + pw() +
                " --quiet 'https://atlantishq.de/ciplog/" +
                socket.gethostname() + "&active&" + str(datetime.now()) + "'")
        except:
            tmp = "Service Unreachable"
        with open(hl_utils.hlpath("cip_logins.log"), 'w') as f:
            f.write(tmp)
Esempio n. 10
0
def bc_pages():
    try:
        arr = hl_utils.shexec("pdftk {} dump_data".format(\
                        hl_utils.hlpath(".bcpdf",use_hostname=False)))
        arr = arr.split("\n")
        lol = "lolcannon"
        for el in arr:
            if "NumberOfPages" in el:
                try:
                    with open(hl_utils.hlpath(BC_PAGE_LOG), 'r') as f:
                        if int(f.read()) == int(el):
                            break
                except:
                    pass
                lol = el
                break
        with open(hl_utils.hlpath(BC_PAGE_LOG), "w") as g:
            g.write(el.split()[1])
    except subprocess.CalledProcessError:
        pass
Esempio n. 11
0
def bwp():
    tmp = ""
    cur = 29
    try:
        with open(hl_utils.hlpath(BC_PAGE_LOG), 'r') as f:
            tmp = "{} pages".format(f.read().strip())
    except:
        tmp = "{} pages".format(cur)
    tmp = hl_utils.color_panel(tmp,
                               hl_utils.get_color(cur, 0, 44, reverse=False))
    return tmp
Esempio n. 12
0
def battery():
    if hl_utils.is_laptop():
        try:
            with open(hl_utils.hlpath(BATTERY_LOG)) as f:
                tmp = f.read()
                tmp = ' ' + tmp
                return tmp
        except FileNotFoundError as e:
            return hl_utils.color_panel(str(e), RED)
    else:
        return ""
Esempio n. 13
0
def vpn_status():
    try:
        if not hl_utils.is_cip():
            out_vpn = hl_utils.shexec("ip r g 8.8.8.8").split("\n")[0]
            if "dev athq_tun" in out_vpn:
                out_vpn = hl_utils.color_panel("VPN: In Use", GREEN)
            else:
                out_vpn = hl_utils.color_panel("VPN: Link Down", RED)
            with open(hl_utils.hlpath(VPN_LOG), 'w') as g:
                g.write(out_vpn)
    except Exception:
        pass
Esempio n. 14
0
def vpn():
    vpn = ''
    if hl_utils.is_cip():
        return ''
    else:
        try:
            with open(hl_utils.hlpath(VPN_LOG)) as f:
                tmp = f.read()
                tmp = ' ' + tmp
                return tmp
        except FileNotFoundError:
            return hl_utils.color_panel("NO VPN INFORMATION", YELLOW)
Esempio n. 15
0
def ip_status():
    global last_ip
    try:
        ip = "Public IP: " + hl_utils.shexec(
            "wget -4 --no-proxy --timeout=3 -O- --quiet ipcheck.atlantishq.de")
        if last_ip == ip:
            return
        else:
            last_ip = ip
        tmp = hl_utils.color_panel(ip, GREEN)
    except:
        last_ip = ""
        try:
            hl_utils.shexec(
                "wget --timeout=2 -O- --quiet https://wwwcip.cs.fau.de/")
            tmp = hl_utils.color_panel("AtlantisHQ Unreachable", RED)
        except:
            tmp = hl_utils.color_panel("No Internet Connection", RED)
    with open(hl_utils.hlpath(IP_LOG), 'w') as g:
        g.write(tmp)
Esempio n. 16
0
def battery_status():
    if hl_utils.is_laptop():
        stat = battery()
        with open(hl_utils.hlpath(BATTERY_LOG), 'w') as g:
            g.write(stat)
Esempio n. 17
0
def pr_acct_status():
    if hl_utils.is_cip():
        out = hl_utils.color_remove(
            hl_utils.shexec("pr_acct").split("\n")[0]).split(' ')[-1]
        with open(hl_utils.hlpath(PRINT_LOG), 'w') as f:
            f.write(out)
Esempio n. 18
0
def logins():
    try:
        with open(hl_utils.hlpath(LOGINS_LOG), 'r') as f:
            return f.read()
    except:
        return ""