Debian Codegraph @

src/CedarBackup3/actions/initialize.py

raw
1 # vim: set ft=python ts=4 sw=4 expandtab:
2 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
3 #
4 # C E D A R
5 # S O L U T I O N S "Software done right."
6 # S O F T W A R E
7 #
8 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
9 #
10 # Copyright (c) 2007,2010,2015 Kenneth J. Pronovici.
11 # All rights reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License,
15 # Version 2, as published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 #
21 # Copies of the GNU General Public License are available from
22 # the Free Software Foundation website, http://www.gnu.org/.
23 #
24 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
25 #
26 # Author : Kenneth J. Pronovici <[email protected]>
27 # Language : Python 3
28 # Project : Cedar Backup, release 3
29 # Purpose : Implements the standard 'initialize' action.
30 #
31 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
32
33 ########################################################################
34 # Module documentation
35 ########################################################################
36
37 """
38 Implements the standard 'initialize' action.
39 :author: Kenneth J. Pronovici <[email protected]>
40 """
41
42
43 ########################################################################
44 # Imported modules
45 ########################################################################
46
47 import logging
48
49 from CedarBackup3.actions.util import initializeMediaState
50
51 ########################################################################
52 # Module-wide constants and variables
53 ########################################################################
54
55 logger = logging.getLogger("CedarBackup3.log.actions.initialize")
56
57
58 ########################################################################
59 # Public functions
60 ########################################################################
61
62 ###############################
63 # executeInitialize() function
64 ###############################
65
66
67 def executeInitialize(configPath, options, config): # ruff: ignore[unused-function-argument]
68 """
69 Executes the initialize action.
70
71 The initialize action initializes the media currently in the writer
72 device so that Cedar Backup can recognize it later. This is an optional
73 step; it's only required if checkMedia is set on the store configuration.
74
75 Args:
76 configPath (String representing a path on disk): Path to configuration file on disk
77 options (Options object): Program command-line options
78 config (Config object): Program configuration
79
80 """
81 logger.debug("Executing the 'initialize' action.")
82 if config.options is None or config.store is None:
83 raise ValueError("Store configuration is not properly filled in.")
84 initializeMediaState(config)
85 logger.info("Executed the 'initialize' action successfully.")