fosKeyMan
Loading...
Searching...
No Matches
src.backend.keyhandler.KeyHandler Class Reference

Handle keyfile operations related to activation and deactivation, as well as reading keyfiles from directories. More...

Public Member Functions

 __init__ (self, activated_path, deactivated_path, trash_path)
 Initialize the KeyHandler with the paths for activated and deactivated directories.
 
 activate_key (self, key_file)
 Move a keyfile from the deactivated directory to the activated directory.
 
 check_directories (self)
 Check if both the activated and deactivated directories exist.
 
 deactivate_key (self, key_file)
 Move a keyfile from the activated directory to the deactivated directory.
 
 delete_key (self, key_file)
 Move a keyfile from either the activated or deactivated directory into the trash directory.
 
 key_folder_path (self, serial_number, status)
 Find the folder path containing the given serial number by searching through the userProperties.json files.
 
 permanently_delete_key (self, key_file)
 Permanently delete a keyfile folder from the trash directory.
 
 read_keys (self, status)
 Read and return a list of serial numbers from userProperties.json files within the folders in the specified base directory.
 
 undo_delete_key (self, key_file)
 Restore a keyfile from the trash directory to the deactivated directory.
 

Public Attributes

 activated_path = activated_path
 
 deactivated_path = deactivated_path
 
 trash_path = trash_path
 

Detailed Description

Handle keyfile operations related to activation and deactivation, as well as reading keyfiles from directories.

The KeyHandler manages two directories: one for activated keyfiles and one for deactivated keyfiles. It provides methods to check if the directories exist, read keyfiles, and move keyfiles between activated and deactivated directories.

Definition at line 15 of file keyhandler.py.

Constructor & Destructor Documentation

◆ __init__()

src.backend.keyhandler.KeyHandler.__init__ ( self,
activated_path,
deactivated_path,
trash_path )

Initialize the KeyHandler with the paths for activated and deactivated directories.

Parameters
activated_path(str): The file path where activated keyfiles are stored.
deactivated_path(str): The file path where deactivated keyfiles are stored.

Definition at line 22 of file keyhandler.py.

Member Function Documentation

◆ activate_key()

src.backend.keyhandler.KeyHandler.activate_key ( self,
key_file )

Move a keyfile from the deactivated directory to the activated directory.

Parameters
key_file(str): The name of the keyfile (without extension) to activate.
Returns
(bool): True if the keyfile was successfully moved, False if the file path does not exist.

Definition at line 78 of file keyhandler.py.

◆ check_directories()

src.backend.keyhandler.KeyHandler.check_directories ( self)

Check if both the activated and deactivated directories exist.

Returns
(bool): True if both directories exist, False if one or both do not exist.

Definition at line 32 of file keyhandler.py.

◆ deactivate_key()

src.backend.keyhandler.KeyHandler.deactivate_key ( self,
key_file )

Move a keyfile from the activated directory to the deactivated directory.

Parameters
key_file(str): The name of the keyfile (without extension) to deactivate.
Returns
(bool): True if the keyfile was successfully moved, False if the file path does not exist.

Definition at line 92 of file keyhandler.py.

◆ delete_key()

src.backend.keyhandler.KeyHandler.delete_key ( self,
key_file )

Move a keyfile from either the activated or deactivated directory into the trash directory.

Parameters
key_file(str): The folder name of the keyfile to delete.
Returns
(bool): True if deleted (moved to trash), False if not found.

Definition at line 106 of file keyhandler.py.

◆ key_folder_path()

src.backend.keyhandler.KeyHandler.key_folder_path ( self,
serial_number,
status )

Find the folder path containing the given serial number by searching through the userProperties.json files.

Parameters
serial_number(str): The serial number to locate.
status(str): 'activated' or 'deactivated' to determine the base directory.
Returns
(str): The full folder path containing the specified serial number, or None if not found.

Definition at line 161 of file keyhandler.py.

◆ permanently_delete_key()

src.backend.keyhandler.KeyHandler.permanently_delete_key ( self,
key_file )

Permanently delete a keyfile folder from the trash directory.

Parameters
key_file(str): The folder name of the keyfile to delete.
Returns
(bool): True if deleted, False if not found.

Definition at line 148 of file keyhandler.py.

◆ read_keys()

src.backend.keyhandler.KeyHandler.read_keys ( self,
status )

Read and return a list of serial numbers from userProperties.json files within the folders in the specified base directory.

Parameters
status(str): 'activated' or 'deactivated'. Uses the activated_path or deactivated_path as the base directory.
Returns
(list): A list containing all sensorSerialNumber values found in the userProperties.json files.

Definition at line 45 of file keyhandler.py.

◆ undo_delete_key()

src.backend.keyhandler.KeyHandler.undo_delete_key ( self,
key_file )

Restore a keyfile from the trash directory to the deactivated directory.

Parameters
key_file(str): The folder name of the keyfile to restore.
Returns
(bool): True if restored, False if not found in trash.

Definition at line 130 of file keyhandler.py.

Member Data Documentation

◆ activated_path

src.backend.keyhandler.KeyHandler.activated_path = activated_path

Definition at line 28 of file keyhandler.py.

◆ deactivated_path

src.backend.keyhandler.KeyHandler.deactivated_path = deactivated_path

Definition at line 29 of file keyhandler.py.

◆ trash_path

src.backend.keyhandler.KeyHandler.trash_path = trash_path

Definition at line 30 of file keyhandler.py.


The documentation for this class was generated from the following file: