| Home | Trees | Indices | Help |
|
|---|
|
|
1 # -*- coding: iso-8859-1 -*-
2 # vim: set ft=python ts=3 sw=3 expandtab:
3 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
4 #
5 # C E D A R
6 # S O L U T I O N S "Software done right."
7 # S O F T W A R E
8 #
9 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
10 #
11 # Copyright (c) 2004-2007,2010 Kenneth J. Pronovici.
12 # All rights reserved.
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License,
16 # Version 2, as published by the Free Software Foundation.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 #
22 # Copies of the GNU General Public License are available from
23 # the Free Software Foundation website, http://www.gnu.org/.
24 #
25 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
26 #
27 # Author : Kenneth J. Pronovici <pronovic@ieee.org>
28 # Language : Python 2 (>= 2.7)
29 # Project : Cedar Backup, release 2
30 # Purpose : Implements the standard 'purge' action.
31 #
32 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
33
34 ########################################################################
35 # Module documentation
36 ########################################################################
37
38 """
39 Implements the standard 'purge' action.
40 @sort: executePurge
41 @author: Kenneth J. Pronovici <pronovic@ieee.org>
42 """
43
44
45 ########################################################################
46 # Imported modules
47 ########################################################################
48
49 # System modules
50 import logging
51
52 # Cedar Backup modules
53 from CedarBackup2.filesystem import PurgeItemList
54
55
56 ########################################################################
57 # Module-wide constants and variables
58 ########################################################################
59
60 logger = logging.getLogger("CedarBackup2.log.actions.purge")
61
62
63 ########################################################################
64 # Public functions
65 ########################################################################
66
67 ##########################
68 # executePurge() function
69 ##########################
70
71 # pylint: disable=W0613
73 """
74 Executes the purge backup action.
75
76 For each configured directory, we create a purge item list, remove from the
77 list anything that's younger than the configured retain days value, and then
78 purge from the filesystem what's left.
79
80 @param configPath: Path to configuration file on disk.
81 @type configPath: String representing a path on disk.
82
83 @param options: Program command-line options.
84 @type options: Options object.
85
86 @param config: Program configuration.
87 @type config: Config object.
88
89 @raise ValueError: Under many generic error conditions
90 """
91 logger.debug("Executing the 'purge' action.")
92 if config.options is None or config.purge is None:
93 raise ValueError("Purge configuration is not properly filled in.")
94 if config.purge.purgeDirs is not None:
95 for purgeDir in config.purge.purgeDirs:
96 purgeList = PurgeItemList()
97 purgeList.addDirContents(purgeDir.absolutePath) # add everything within directory
98 purgeList.removeYoungFiles(purgeDir.retainDays) # remove young files *from the list* so they won't be purged
99 purgeList.purgeItems() # remove remaining items from the filesystem
100 logger.info("Executed the 'purge' action successfully.")
101
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 | http://epydoc.sourceforge.net |