Arrangements API¶
- class adaptystanalyser.arrangements.Arrangement(**kwargs)¶
Bases:
BaseA class describing a saved window arrangement, using SQLAlchemy ORM.
- check_token(user_token)¶
Return whether a given update token is valid for the arrangement.
- Parameters:
user_token (str) – The update token to validate.
- gen_token()¶
Generate, store, and return an update token for the arrangement.
- to_dict()¶
Return the public metadata of the arrangement as a dictionary.
- class adaptystanalyser.arrangements.Context(url=None, password=None)¶
Bases:
objectA class managing connections to a database storing window arrangements.
- check_name(name: str) bool¶
Return whether an arrangement with a given name exists.
- Parameters:
name (str) – The arrangement name to check.
- close()¶
Close the context.
- delete(name, token)¶
Delete a saved arrangement.
- Parameters:
name (str) – The arrangement name.
token (str) – The update token for the arrangement.
- Raises:
FileNotFoundError – When the arrangement does not exist.
PermissionError – When the update token is invalid.
- edit_name(name: str, new_name: str, token: str)¶
Rename a saved arrangement.
- Parameters:
name (str) – The current arrangement name.
new_name (str) – The new arrangement name.
token (str) – The update token for the arrangement.
- Raises:
FileExistsError – When the new name is already in use.
FileNotFoundError – When the arrangement does not exist.
PermissionError – When the update token is invalid.
- get_by_id(identifier, storage_path)¶
Return saved arrangement data by identifier.
- Parameters:
identifier (int) – The arrangement identifier.
storage_path (pathlib.Path) – The parent path of performance analysis sessions referenced by the arrangement.
- Raises:
FileNotFoundError – When the arrangement does not exist.
ValueError – When a referenced session has changed or is unavailable.
- get_by_name(name, storage_path)¶
Return saved arrangement data by name.
- Parameters:
name (str) – The arrangement name.
storage_path (pathlib.Path) – The parent path of performance analysis sessions referenced by the arrangement.
- Raises:
FileNotFoundError – When the arrangement does not exist.
ValueError – When a referenced session has changed or is unavailable.
- get_list(search, limit, page, sort, types)¶
Query the saved arrangements and return information necessary for displaying the query results with pagination: a tuple
(<number of all arrangements matching the query>, <total number of arrangement pages matching the query>, <list of arrangements in form of dictionaries obtained by Arrangement.to_dict()>).- Parameters:
search (str) – A regular expression used to filter names. Use None if you don’t want to filter names.
limit – The maximum number of arrangements to return at once.
page – Number indicating what page of the query results should be returned.
sort (str) – The query result sorting method. Use one of “last_update_desc”, “last_update_asc”, “name_desc”, and “name_asc”.
types (str) – The arrangement type to display. Use one of “W” (window arrangements), “SW” (single window arrangements), and “both”.
- Raises:
ValueError – When the value of “limit”, “page”, “sort”, and/or “types” is invalid.
- is_closed()¶
Return whether the database context has been closed.
- save(name: str, data: str, storage_path: Path) -> (<class 'str'>, <class 'str'>)¶
Save a new window arrangement in the database and return a tuple
(<arrangement identifier>, <arrangement update token>).- Parameters:
name (str) – The name of the arrangement.
data (str) – The JSON data describing the arrangement.
storage_path (pathlib.Path) – The parent path of referenced performance analysis sessions.
- Raises:
FileExistsError – When an arrangement with the given name exists.
- class adaptystanalyser.arrangements.Session(**kwargs)¶
Bases:
BaseA class representing a performance analysis session that can be linked to one or more arrangements. This uses SQLAlchemy ORM.
- check_fingerprint(storage_path: Path)¶
Return whether the linked session directory matches the fingerprint stored in the object.
If the check succeeds, the last successful check time is refreshed accordingly.
- Parameters:
storage_path (pathlib.Path) – The parent path of the session.
- gen_fingerprint(storage_path: Path)¶
Generate and store a fingerprint of the session, based on its directory contents. Nothing is returned.
- Parameters:
storage_path (pathlib.Path) – The parent path of the session.
- Raises:
FileNotFoundError – When the session directory does not exist.