REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.97 KB
Close
/opt/cloudlinux/venv/lib64/python3.11/site-packages/lvestats/lib/commons/users_manager.py
Text
Base64
#!/usr/bin/python # coding=utf-8 # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENSE.TXT import logging from collections import namedtuple from typing import Optional, Dict, Generator, Tuple, List # NOQA from clcommon import cpapi, FormattedException from lvestats.lib.commons import func class UserNotFoundError(FormattedException): pass class User(namedtuple('User', ['username', 'domain', 'reseller'])): pass class UsersInfoManager(object): """ Implements some different functions for user management; """ def __init__(self): self.users_cache = {} # type: Dict[str, User] def build_users_cache(self, reseller): # type: (Optional[str]) -> None """Cache data from cpapi for given reseller""" try: self.users_cache = dict(self._iter_panel_users(reseller)) except cpapi.NotSupported: logging.info("Control panel API is not implemented, " "some features may not work properly") def _iter_panel_users(self, reseller): # type: (Optional[str]) -> Generator[Tuple[str, User]] for login, reseller_, domain in self._iter_panel_users_tuples(reseller): yield login, User(username=login, reseller=reseller_, domain=domain) @staticmethod def _iter_panel_users_tuples(reseller): # type: (Optional[str]) -> Tuple[str, str, str] if reseller is None: for login, reseller_, domain in cpapi.cpinfo(keyls=('cplogin', 'reseller', 'dns')): yield login, reseller_, domain else: # TODO: do we really need get_reseller_domains? for login, domain in list(func.get_reseller_domains(reseller).items()): yield login, reseller, domain def get_domain(self, username, raise_exc=True): # type: (str, bool) -> Optional[str] """Get domain for user""" try: return self.users_cache[username].domain except KeyError as e: if raise_exc: raise UserNotFoundError({ 'message': "An error occurred while getting domain for user %(username)s", 'context': {'username': username}}) from e return None def get_reseller(self, username, raise_exc=True): # type: (str, bool) -> Optional[str] """Get reseller for user""" try: return self.users_cache[username].reseller except KeyError as e: if raise_exc: raise UserNotFoundError({ 'message': "An error occurred while getting reseller for user %(username)s", 'context': {'username': username}}) from e return None def get_login_list(self): # type: () -> List[str] """Get list of cached users""" return list(self.users_cache.keys()) g_users_manager = UsersInfoManager()
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 16
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
__pycache__
DIR
-
drwxr-xr-x
2026-06-03 07:00:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
argparse_utils.py
11.25 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
dateutil.py
5.63 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
decorators.py
893 B
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
fileutil.py
1.14 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
func.py
15.89 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
htpasswd.py
2.18 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
litespeed.py
9.77 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
logsetup.py
4.50 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
proctitle.py
4.70 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
profiler.py
575 B
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
progress.py
1016 B
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
sentry.py
6.17 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
server_status.py
1.31 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
sizeutil.py
2.59 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
users_manager.py
2.97 KB
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
219 B
lrw-r--r--
2026-05-20 17:45:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).