diff options
author | Lars Wirzenius <liw@gytha> | 2008-03-23 14:10:09 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@gytha> | 2008-03-23 14:10:09 +0200 |
commit | 29d67398fa5e3ab5a8e8c73622839b6ad3ef591d (patch) | |
tree | 0499a65bf88d7790ef52e5445418dbb4726c3fe1 /obnam | |
parent | 239403b11fe95cde036ccde5ee833ba56f318fae (diff) | |
download | obnam-29d67398fa5e3ab5a8e8c73622839b6ad3ef591d.tar.gz |
Added a ListGenerations operation.
Diffstat (limited to 'obnam')
-rw-r--r-- | obnam/__init__.py | 1 | ||||
-rw-r--r-- | obnam/oper_generations.py | 52 |
2 files changed, 53 insertions, 0 deletions
diff --git a/obnam/__init__.py b/obnam/__init__.py index 310a0156..d45e680a 100644 --- a/obnam/__init__.py +++ b/obnam/__init__.py @@ -46,3 +46,4 @@ import walk from app import Application from oper import Operation, OperationFactory from oper_backup import Backup +from oper_generations import ListGenerations diff --git a/obnam/oper_generations.py b/obnam/oper_generations.py new file mode 100644 index 00000000..3ca1a293 --- /dev/null +++ b/obnam/oper_generations.py @@ -0,0 +1,52 @@ +# Copyright (C) 2008 Lars Wirzenius <liw@iki.fi> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +"""Operation to list generations in a backup store.""" + + +import logging + +import obnam + + +class ListGenerations(obnam.Operation): + + """List generations in the store.""" + + name = "generations" + + def do_it(self, *ignored): + app = self.get_application() + host = app.load_host() + context = app.get_context() + gentimes = context.config.getboolean("backup", "generation-times") + if gentimes: + app.load_maps() + + gen_ids = host.get_generation_ids() + for id in gen_ids: + if gentimes: + gen = obnam.io.get_object(context, id) + if not gen: + logging.warning("Can't find info about generation %s" % id) + else: + start = gen.get_start_time() + end = gen.get_end_time() + print id, obnam.format.timestamp(start), "--", \ + obnam.format.timestamp(end) + else: + print id |