|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /proc/self/root/opt/alt-old/python37/usr/share/python-cllib/scripts/ |
Upload File : |
#!/opt/alt/python37/bin/python3 -bb
# -*- coding: utf-8 -*-
# Utility to get panel users. This utility will be run by cron
#
# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2021 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENCE.TXT
from __future__ import absolute_import
import os
from clcommon.cpapi import cpusers, is_admin
from clcommon.cpapi.cpapiexceptions import NotSupported
PANEL_USERS_COUNT_FILE = '/var/lve/panel_users_count'
if __name__ == '__main__':
users_count = 0
try:
users_list = cpusers()
except NotSupported:
raise NotSupported("cpusers() method not supported")
for user in users_list:
if not is_admin(user):
users_count += 1
with open(PANEL_USERS_COUNT_FILE, 'w') as f:
f.write(str(users_count))
# Change permission to let users read this file
os.chmod(PANEL_USERS_COUNT_FILE, 0o644)