summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-02-08 09:49:37 +0000
committerLars Wirzenius <liw@liw.fi>2013-02-08 09:49:37 +0000
commitc19a4f2fdd3be0dee624de61477533d7d0532402 (patch)
treed8452b1728384bf747cdc9a13c977a164d4eecff
parent3c8f442f2a7c7d0f09b9071e68d8420a655dc7b3 (diff)
parent5b865b3d1d33512bb0bacd192bfacbd04a2cd953 (diff)
downloadobnam-c19a4f2fdd3be0dee624de61477533d7d0532402.tar.gz
Make ls take list of files, instead of generations
-rw-r--r--NEWS2
-rw-r--r--obnamlib/plugins/restore_plugin.py11
-rw-r--r--obnamlib/plugins/show_plugin.py11
-rw-r--r--obnamlib/plugins/verify_plugin.py5
4 files changed, 22 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index 6329f1c0..f92850b8 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ This file summarizes changes between releases of Obnam.
Version X.Y, released UNRELEASED
--------------------------------
+* The``ls` command now takes filenames as (optional) arguments, instead
+ of a list of generations. Based on patch by Damien Couroussé.
* Even more detailed progress reporting during a backup.
* Add --fsck-skip-generations option to tell fsck to not check any
generation metadata.
diff --git a/obnamlib/plugins/restore_plugin.py b/obnamlib/plugins/restore_plugin.py
index 29bef635..e5f4c430 100644
--- a/obnamlib/plugins/restore_plugin.py
+++ b/obnamlib/plugins/restore_plugin.py
@@ -65,9 +65,9 @@ class RestorePlugin(obnamlib.ObnamPlugin):
self.app.add_subcommand('restore', self.restore,
arg_synopsis='[DIRECTORY]...')
self.app.settings.string(['to'], 'where to restore')
- self.app.settings.string(['generation'],
+ self.app.settings.string_list(['generation'],
'which generation to restore',
- default='latest')
+ default=['latest'])
@property
def write_ok(self):
@@ -118,7 +118,12 @@ class RestorePlugin(obnamlib.ObnamPlugin):
self.errors = False
- gen = self.repo.genspec(self.app.settings['generation'])
+ generations = self.app.settings['generation']
+ if len(generations) != 1:
+ raise obnamlib.Error(
+ 'The restore command wants exactly one generation option')
+
+ gen = self.repo.genspec(generations[0])
self.configure_ttystatus()
self.app.ts['total'] = self.repo.client.get_generation_file_count(gen)
diff --git a/obnamlib/plugins/show_plugin.py b/obnamlib/plugins/show_plugin.py
index 60bb5bc1..f13480f2 100644
--- a/obnamlib/plugins/show_plugin.py
+++ b/obnamlib/plugins/show_plugin.py
@@ -39,7 +39,7 @@ class ShowPlugin(obnamlib.ObnamPlugin):
self.app.add_subcommand('clients', self.clients)
self.app.add_subcommand('generations', self.generations)
self.app.add_subcommand('genids', self.genids)
- self.app.add_subcommand('ls', self.ls, arg_synopsis='[GENERATION]...')
+ self.app.add_subcommand('ls', self.ls, arg_synopsis='[FILE]...')
self.app.add_subcommand('diff', self.diff,
arg_synopsis='[GENERATION1] GENERATION2')
self.app.add_subcommand('nagios-last-backup-age',
@@ -134,14 +134,19 @@ class ShowPlugin(obnamlib.ObnamPlugin):
def ls(self, args):
'''List contents of a generation.'''
self.open_repository()
- for gen in args or [self.app.settings['generation']] or ["latest"]:
+
+ if len(args) is 0:
+ args = ['/']
+
+ for gen in self.app.settings['generation']:
gen = self.repo.genspec(gen)
started, ended = self.repo.client.get_generation_times(gen)
started = self.format_time(started)
ended = self.format_time(ended)
self.app.output.write(
'Generation %s (%s - %s)\n' % (gen, started, ended))
- self.show_objects(gen, '/')
+ for ls_file in args:
+ self.show_objects(gen, ls_file)
self.repo.fs.close()
def format_time(self, timestamp):
diff --git a/obnamlib/plugins/verify_plugin.py b/obnamlib/plugins/verify_plugin.py
index 170625fc..cdd055c7 100644
--- a/obnamlib/plugins/verify_plugin.py
+++ b/obnamlib/plugins/verify_plugin.py
@@ -49,6 +49,9 @@ class VerifyPlugin(obnamlib.ObnamPlugin):
self.app.settings.require('repository')
self.app.settings.require('client-name')
self.app.settings.require('generation')
+ if len(self.app.settings['generation']) != 1:
+ raise obnamlib.Error(
+ 'verify must be given exactly one generation')
logging.debug('verifying generation %s' %
self.app.settings['generation'])
@@ -71,7 +74,7 @@ class VerifyPlugin(obnamlib.ObnamPlugin):
self.fs.reinit(root_url)
self.failed = False
- gen = self.repo.genspec(self.app.settings['generation'])
+ gen = self.repo.genspec(self.app.settings['generation'][0])
self.app.ts['done'] = 0
self.app.ts['total'] = 0