<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
mi                 @   s4   d dl Z d dlmZmZ dd Zdd Zdd ZdS )	    N)PIPEPopenc              C   sf   t jjdstdd} t| dttd}dd |j D \}}|rPtd| t|d	d jd
S )z
    Get user count using the common CloudLinux library.
    This number is more accurate for systems
    with a control panel installed.
    z/opt/cloudlinux/venv/binz(CloudLinux virtual environment not foundzZ/opt/cloudlinux/venv/bin/python3 -c "from clcommon.cpapi import cpusers; print(cpusers())"T)shellstdoutstderrc             S   s   g | ]}|j  j qS  )decodestrip).0resultr   r    /usr/lib/python3.6/statistics.py
<listcomp>   s    z.get_users_count_from_cllib.<locals>.<listcomp>z-Failed to get users from CloudLinux library:    z, )	ospathexists
ValueErrorr   r   Zcommunicatelensplit)cmdZprocessoutputerrorsr   r   r   get_users_count_from_cllib   s    r   c              C   s   ddl m}  |  }t|j S )zY
    Fallback method to get the user count
    by looking into the /etc/passwd file.
    r   )ClPwd)Zup2date_client.clpwdr   r   Zget_uid_dict)r   pwdr   r   r   get_users_count_generic   s    r   c              C   s*   y
t  } W n tk
r$   t } Y nX | S )z
    Get the total count of users on the server.
    Tries the CloudLinux library first, falls back to generic method if it fails.
    )r   	Exceptionr   )Zusers_countr   r   r   count_server_users"   s
    
r   )r   
subprocessr   r   r   r   r   r   r   r   r   <module>   s   
