idm
Base module IDM related classes and functions.
- exception wmflib.idm.IdmValueError[source]
Bases:
WmflibError
Raised by the IDM module value errors.
- __doc__ = 'Raised by the IDM module value errors.'
- __module__ = 'wmflib.idm'
- wmflib.idm.logoutd_args(description: str | None = None, args: List | None = None) Namespace [source]
Logout scripts common CLI for parsing the command line arguments.
When not using the higher level API
wmflib.idm.LogoutdBase
, a user could just implement their own script still using the same command line arguments processing, of the form:from wmflib.idm import logoutd_args args = logoutd_args("Some description") # write your own script
- class wmflib.idm.LogoutdBase(args: List | None = None)[source]
Bases:
ABC
abstract
Base class for a standardized API for logout scripts.A simple logout.d python script would then be of the form:
from wmflib.idm import LogoutdBase class MyLogoutd(LogoutdBase): """Some description.""" def logout_user(self, user): # logout the given user def query_user(self, user): # check the login status of a given user def list(self): # list all active login sessions logoutd = MyLogoutd() raise SystemExit(logoutd.run()) # This includes the parsing of command line arguments.
abstract
Init function.- Parameters:
args (list) – A list of arguments to use (used for testing)
- __init__(args: List | None = None) None [source]
Init function.
- Parameters:
args (list) – A list of arguments to use (used for testing)
- property user: str
Return either common_name or uid with a preference for common_name.
- Returns:
representing the user
- Return type:
(str)
- abstract logout_user(user: str) int [source]
abstract
Log out the specified user.- Parameters:
user (User) – object representing the user
- Returns:
0 if the users session was successfully cleared otherwise 1
- Return type:
(int)
- abstract query_user(user: str) int [source]
abstract
Return status of logged in user.- Parameters:
user (User) – object representing the user
- Returns:
1 if the user is logged in otherwise 0
- Return type:
(int)
- abstract list() int [source]
abstract
Return data of all logged in users.- Returns:
0 on success non-zero on fail
- Return type:
(int)
- run() int [source]
Execute the correct action.
- Returns:
exit code depends on command
- Return type:
(int)
- __abstractmethods__ = frozenset({'list', 'logout_user', 'query_user'})
- __annotations__ = {'user_identifier': <class 'str'>}
- __dict__ = mappingproxy({'__module__': 'wmflib.idm', '__annotations__': {'user_identifier': <class 'str'>}, '__doc__': 'Base class for a standardized API for logout scripts.\n\n A simple logout.d python script would then be of the form::\n\n from wmflib.idm import LogoutdBase\n\n class MyLogoutd(LogoutdBase):\n """Some description."""\n\n def logout_user(self, user):\n # logout the given user\n\n def query_user(self, user):\n # check the login status of a given user\n\n def list(self):\n # list all active login sessions\n\n logoutd = MyLogoutd()\n raise SystemExit(logoutd.run()) # This includes the parsing of command line arguments.\n\n ', 'user_identifier': 'cn', '__init__': <function LogoutdBase.__init__>, 'user': <property object>, 'logout_user': <function LogoutdBase.logout_user>, 'query_user': <function LogoutdBase.query_user>, 'list': <function LogoutdBase.list>, 'run': <function LogoutdBase.run>, '__dict__': <attribute '__dict__' of 'LogoutdBase' objects>, '__weakref__': <attribute '__weakref__' of 'LogoutdBase' objects>, '__abstractmethods__': frozenset({'query_user', 'logout_user', 'list'}), '_abc_impl': <_abc._abc_data object>})
- __doc__ = 'Base class for a standardized API for logout scripts.\n\n A simple logout.d python script would then be of the form::\n\n from wmflib.idm import LogoutdBase\n\n class MyLogoutd(LogoutdBase):\n """Some description."""\n\n def logout_user(self, user):\n # logout the given user\n\n def query_user(self, user):\n # check the login status of a given user\n\n def list(self):\n # list all active login sessions\n\n logoutd = MyLogoutd()\n raise SystemExit(logoutd.run()) # This includes the parsing of command line arguments.\n\n '
- __module__ = 'wmflib.idm'
- __weakref__
list of weak references to the object (if defined)
- _abc_impl = <_abc._abc_data object>