cssefclient package¶
Submodules¶
cssefclient.errors module¶
-
exception
cssefclient.errors.CssefException¶ Bases:
exceptions.Exception-
value= None¶
-
message= None¶
-
as_return_dict()¶
-
-
exception
cssefclient.errors.NonExistantCommand¶ Bases:
cssefclient.errors.CssefException-
value= -5¶
-
message= ['Invalid command.']¶
-
cssefclient.tasks module¶
-
class
cssefclient.tasks.AvailablePlugins(config)¶
-
class
cssefclient.tasks.RenewToken(config)¶ Bases:
cssefclient.utils.RPCEndpoint-
execute(**kwargs)¶
-
-
class
cssefclient.tasks.Login(config)¶ Bases:
cssefclient.utils.RPCEndpoint-
execute(**kwargs)¶
-
cssefclient.utils module¶
-
class
cssefclient.utils.RPCEndpoint(config, rpc_name)¶ Bases:
objectBase class to represent an endpoint task on the server.
This class gets subclassed by other classes to define a specific task on the cssef server.
-
execute(server_connection, **kwargs)¶ Calls the rpc endpoint on the remote server
Parameters: **kwargs – Keyword arguments to pass to the rpc endpoint on the server. Returns: The task data is cast to a CommandOutput object if the task completed successfully. If the task experiences an unhandled error, it is caught and a CommandOutput object is created with values describing the encountered exception. Return type: CommandOutput
-
-
cssefclient.utils.load_token_file(token_file)¶ Load token from a file
This will try to load the token from the token cache file. If successful, it will save the token it finds in the token attribute for use while sending requests to the server.
Returns: True if token was successfully loaded, otherwise False. Return type: bool
-
cssefclient.utils.save_token_file(token_file_path, token)¶
-
cssefclient.utils.parse_time_notation(value)¶
Module contents¶
-
class
cssefclient.CssefClient¶ Bases:
object-
connect()¶ Establishes a connection to the celery server
-
load_endpoints()¶
-
load_auth()¶
-
-
class
cssefclient.Configuration¶ Bases:
objectContains and loads configuration values
There is one attribute for each configuration that can be set. Configurations can be loaded from a file or dictionary. When loading configurations, any hyphens wihtin key values will be converted to underscores so that the attribute can be set.
-
filepath_configs= ['token_file', 'endpoint_cache_file']¶
-
server_url¶
-
endpoint_cache_time¶
-
load_config_file(config_path)¶ Load configuration from a file
This will read a yaml configuration file. The yaml file is converted to a dictionary object, which is just passed to loadConfigDict.
Parameters: config_path (str) – A filepath to the yaml config file Returns: None
-
load_config_dict(config_dict)¶ Load configurations from a dictionary
This will convert strings with hyphens (-) to underscores (_) that way attributes can be added. Underscores are not used in the config files because I think they look ugly. That’s my only reasoning - deal with it. Any key within the dictionary that is not an attribute of the class will be ignored (this will be logged).
Parameters: config_dict (dict) – A dictionary containing configurations and values Returns: None
-
load_token()¶
-
-
class
cssefclient.AuthBuilder¶ Bases:
object-
load_from_config(config)¶
-
prompt_for_password()¶
-
get_auth_strategy()¶
-
auth_invalid()¶
-
auth_admin_token()¶
-
auth_token()¶
-
auth_password()¶
-
as_dict()¶
-
is_valid()¶
-
-
class
cssefclient.EndpointsLoader(config, server_connection)¶ Bases:
object-
load()¶
-
from_cache()¶
-
load_from_server()¶ Retrieves the available endpoints from the server.
Here we’re manually creating an RPCEndpoint with the hardcoded name ‘availableendpoints’. We can get away with this because this will always exist on the server.
-
load_from_file()¶ Retrieves the available endpoints from the cache
-
update_cache()¶ Writes the received endpoints to the cache file
-