summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-06-14 20:59:05 +1200
committerLars Wirzenius <liw@liw.fi>2010-06-14 20:59:05 +1200
commit5efc8b829f868e13ddfee92f4548244838081889 (patch)
tree0bc45fb31d46286c71da9c7ac20e64dfa30329b7
parent1e5a6c631ba3033045560b6e0a98cad9b6d1dd89 (diff)
downloadobnam-5efc8b829f868e13ddfee92f4548244838081889.tar.gz
Fix --quiet option in terminal_status_plugin.py.
-rw-r--r--obnamlib/app.py2
-rw-r--r--obnamlib/plugins/terminal_status_plugin.py20
2 files changed, 14 insertions, 8 deletions
diff --git a/obnamlib/app.py b/obnamlib/app.py
index a6e1494a..8f7401f0 100644
--- a/obnamlib/app.py
+++ b/obnamlib/app.py
@@ -50,6 +50,7 @@ class App(object):
self.register_command = self.interp.register
self.hooks.new('plugins-loaded')
+ self.hooks.new('config-loaded')
self.hooks.new('shutdown')
self.fsf = obnamlib.VfsFactory()
@@ -82,6 +83,7 @@ class App(object):
self.pm.enable_plugins()
self.hooks.call('plugins-loaded')
self.config.load()
+ self.hooks.call('config-loaded')
self.setup_logging()
if self.config.args:
self.interp.execute(self.config.args[0], self.config.args[1:])
diff --git a/obnamlib/plugins/terminal_status_plugin.py b/obnamlib/plugins/terminal_status_plugin.py
index b71a7f29..6675ee93 100644
--- a/obnamlib/plugins/terminal_status_plugin.py
+++ b/obnamlib/plugins/terminal_status_plugin.py
@@ -32,28 +32,33 @@ class TerminalStatusPlugin(obnamlib.ObnamPlugin):
self.ts = ttystatus.TerminalStatus(period=0.25)
self.ts['data_done'] = 0
- self.ts.add(ttystatus.ElapsedTime())
- self.ts.add(ttystatus.Literal(' '))
- self.ts.add(ttystatus.Counter('current'))
- self.ts.add(ttystatus.Literal(' files; '))
- self.ts.add(ttystatus.ByteSize('data_done'))
- self.ts.add(ttystatus.Literal(' '))
- self.ts.add(ttystatus.Pathname('current'))
self.app.hooks.new('status')
self.app.hooks.new('progress-found-file')
self.app.hooks.new('progress-data-done')
self.app.hooks.new('error-message')
+
self.add_callback('status', self.status_cb)
self.add_callback('progress-found-file', self.found_file_cb)
self.add_callback('progress-data-done', self.data_done_cb)
self.add_callback('error-message', self.error_message_cb)
+ self.add_callback('config-loaded', self.config_loaded_cb)
self.add_callback('shutdown', self.shutdown_cb)
def disable(self):
self.ts.finish()
self.ts = None
+ def config_loaded_cb(self):
+ if not self.app.config['quiet']:
+ self.ts.add(ttystatus.ElapsedTime())
+ self.ts.add(ttystatus.Literal(' '))
+ self.ts.add(ttystatus.Counter('current'))
+ self.ts.add(ttystatus.Literal(' files; '))
+ self.ts.add(ttystatus.ByteSize('data_done'))
+ self.ts.add(ttystatus.Literal(' '))
+ self.ts.add(ttystatus.Pathname('current'))
+
def found_file_cb(self, filename, size):
self.ts['current'] = filename
@@ -69,4 +74,3 @@ class TerminalStatusPlugin(obnamlib.ObnamPlugin):
def shutdown_cb(self):
self.ts.finish()
-