✏️ 正在编辑: statistics.cpython-36.pyc
路径:
/lib/python3.6/site-packages/up2date_client/__pycache__/statistics.cpython-36.pyc
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
3 m��i � @ s4 d dl Z d dlmZmZ dd� Zdd� Zdd� ZdS ) � N)�PIPE�Popenc C sf t jjd�std��d} t| dttd�}dd� |j� D �\}}|rPtd|� ���t|d d� jd ��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� �qS � )�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 Zcommunicate�len�split)�cmdZprocess�output�errorsr r r �get_users_count_from_cllib s r c C s ddl m} | � }t|j� �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* y t � } W n tk r$ t� } Y nX | 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"