/
lib
/
python3.9
/
site-packages
/
up2date_client
/
__pycache__
/
up file
home
a m��i � @ s4 d dl Z d dlmZmZ dd� Zdd� Zdd� ZdS ) � N)�PIPE�Popenc C sf t j�d�std��d} t| dttd�}dd� |�� D �\}}|rPtd|� ���t|d d � �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 | ]}|� � �� �qS � )�decode�strip)�.0�resultr r �=/usr/lib/python3.9/site-packages/up2date_client/statistics.py� <listcomp> � z.get_users_count_from_cllib.<locals>.<listcomp>z-Failed to get users from CloudLinux library: � ���z, ) �os�path�exists� ValueErrorr r Zcommunicate�len�split)�cmdZprocess�output�errorsr r r �get_users_count_from_cllib s r c C s ddl m} | � }t|�� �S )zY Fallback method to get the user count by looking into the /etc/passwd file. r )�ClPwd)Zup2date_client.clpwdr r Zget_uid_dict)r �pwdr r r �get_users_count_generic s r c C s( z t � } W n ty" t� } Y n0 | 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 )Zusers_countr r r �count_server_users"