$40 GRAYBYTE WORDPRESS FILE MANAGER $80

SERVER : premium134.web-hosting.com #1 SMP Thu Mar 13 14:29:12 UTC 2025
SERVER IP : 162.0.232.104 | ADMIN IP 216.73.216.173
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/usr/lib/python3.6/site-packages/up2date_client/

HOME
Current File : /usr/lib/python3.6/site-packages/up2date_client//statistics.py
import os
from subprocess import PIPE, Popen


def get_users_count_from_cllib():
    """
    Get user count using the common CloudLinux library.
    This number is more accurate for systems
    with a control panel installed.
    """
    if not os.path.exists('/opt/cloudlinux/venv/bin'):
        raise ValueError("CloudLinux virtual environment not found")

    cmd = '/opt/cloudlinux/venv/bin/python3 -c "from clcommon.cpapi import cpusers; print(cpusers())"'
    process = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
    output, errors = [result.decode().strip() for result in process.communicate()]

    if errors:
        raise ValueError(f"Failed to get users from CloudLinux library: {errors}")

    return len(output[1:-1].split(', '))


def get_users_count_generic():
    """
    Fallback method to get the user count
    by looking into the /etc/passwd file.
    """
    from up2date_client.clpwd import ClPwd
    pwd = ClPwd()
    return len(pwd.get_uid_dict())


def count_server_users():
    """
    Get the total count of users on the server.
    Tries the CloudLinux library first, falls back to generic method if it fails.
    """
    try:
        users_count = get_users_count_from_cllib()
    except Exception:
        users_count = get_users_count_generic()
    return users_count


Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
9 Jun 2026 7.03 AM
root / root
0755
__pycache__
--
29 May 2026 7.16 AM
root / root
0755
__init__.py
0 KB
24 Apr 2026 3.42 PM
root / root
0644
clpwd.py
3.558 KB
24 Apr 2026 3.42 PM
root / root
0644
config.py
13.259 KB
24 Apr 2026 3.42 PM
root / root
0644
hardware.py
5.094 KB
24 Apr 2026 3.42 PM
root / root
0644
pkgplatform.py
0.302 KB
27 Apr 2026 12.46 PM
root / root
0644
rhncli.py
7.461 KB
24 Apr 2026 3.42 PM
root / root
0644
rhnreg.py
10.517 KB
24 Apr 2026 3.42 PM
root / root
0644
rhnserver.py
8.536 KB
24 Apr 2026 3.42 PM
root / root
0644
rpcServer.py
11.097 KB
24 Apr 2026 3.42 PM
root / root
0644
statistics.py
1.274 KB
24 Apr 2026 3.42 PM
root / root
0644
up2dateAuth.py
10.492 KB
24 Apr 2026 3.42 PM
root / root
0644
up2dateErrors.py
7.986 KB
24 Apr 2026 3.42 PM
root / root
0644
up2dateLog.py
2.059 KB
24 Apr 2026 3.42 PM
root / root
0644
up2dateUtils.py
1.729 KB
27 Apr 2026 12.46 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF Static GIF