creds.utils

sudo_check() Return the string ‘sudo’ if current user isn’t root.
check_platform
execute_command([command]) Execute a command and return the stdout and stderr.
random_string([length]) Generate a random string of ASCII characters.
base64encode([_input]) Return base64 encoded representation of a string.
base64decode([_input]) Take a base64 encoded string and return the decoded string.
creds.utils.base64decode(_input=None)[source]

Take a base64 encoded string and return the decoded string.

creds.utils.base64encode(_input=None)[source]

Return base64 encoded representation of a string.

creds.utils.execute_command(command=None)[source]

Execute a command and return the stdout and stderr.

creds.utils.get_missing_commands(_platform)[source]

Check I can identify the necessary commands for managing users.

creds.utils.get_platform()[source]

Return platform name

creds.utils.get_sudoers_entry(username=None, sudoers_entries=None)[source]

Find the sudoers entry in the sudoers file for the specified user.

Parameters:
  • username (str) – username.
  • sudoers_entries (list) – list of lines from the sudoers file.
returns:`r
str: sudoers entry for the specified user.
creds.utils.random_string(length=None)[source]

Generate a random string of ASCII characters.

creds.utils.read_sudoers()[source]

Read the sudoers entry for the specified user.

Parameters:username (str) – username.
returns:`r
str: sudoers entry for the specified user.
creds.utils.remove_sudoers_entry(username=None)[source]

Remove sudoers entry.

Parameters:user (User) – Instance of User containing sudoers entry.
Returns:sudoers entry for the specified user.
Return type:str
creds.utils.sudo_check()[source]

Return the string ‘sudo’ if current user isn’t root.

creds.utils.write_sudoers_entry(username=None, sudoers_entry=None)[source]

Write sudoers entry.

Parameters:user (User) – Instance of User containing sudoers entry.
Returns:sudoers entry for the specified user.
Return type:str