summaryrefslogtreecommitdiff
path: root/obnam
diff options
context:
space:
mode:
authorLars Wirzenius <liw@gytha>2008-03-23 14:00:40 +0200
committerLars Wirzenius <liw@gytha>2008-03-23 14:00:40 +0200
commit5d88efe0a457052959b458da2ef7cc44f9ceff09 (patch)
tree90994467596dbf9659d03889ab66cf6b17747e75 /obnam
parent17c5383940e9b665af1980adb50454f56e1217ed (diff)
downloadobnam-5d88efe0a457052959b458da2ef7cc44f9ceff09.tar.gz
Moved operation Backup to its own module. This will make unit testing nicer.
Diffstat (limited to 'obnam')
-rw-r--r--obnam/__init__.py1
-rw-r--r--obnam/oper.py12
-rw-r--r--obnam/oper_backup.py43
3 files changed, 47 insertions, 9 deletions
diff --git a/obnam/__init__.py b/obnam/__init__.py
index fc46bb9b..310a0156 100644
--- a/obnam/__init__.py
+++ b/obnam/__init__.py
@@ -45,3 +45,4 @@ import walk
from app import Application
from oper import Operation, OperationFactory
+from oper_backup import Backup
diff --git a/obnam/oper.py b/obnam/oper.py
index e27f89bd..bc4d999c 100644
--- a/obnam/oper.py
+++ b/obnam/oper.py
@@ -86,9 +86,10 @@ class OperationFactory:
self._app = app
def find_operations(self):
- """Find operations defined in this module."""
+ """Find operations defined in obnam."""
list = []
- for x in globals().values():
+ for name in dir(obnam):
+ x = getattr(obnam, name)
if inspect.isclass(x) and issubclass(x, Operation):
list.append(x)
return list
@@ -108,10 +109,3 @@ class OperationFactory:
return oper(self._app, args[1:])
raise OperationNotFound(args[0])
-
-
-class Backup(Operation):
-
- """Backup files the user specifies."""
-
- name = "backup"
diff --git a/obnam/oper_backup.py b/obnam/oper_backup.py
new file mode 100644
index 00000000..ca2aeb25
--- /dev/null
+++ b/obnam/oper_backup.py
@@ -0,0 +1,43 @@
+# 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.
+
+
+"""A backup operation for Obnam."""
+
+
+import obnam
+
+
+class Backup(obnam.Operation):
+
+ """Backup files the user has specified."""
+
+ name = "backup"
+
+ def do_it(self, roots):
+ logging.info("Starting backup")
+ logging.info("Getting and decoding host block")
+ app = self.get_application()
+ host = app.load_host()
+ app.load_maps()
+ # We don't need to load in file data, therefore we don't load
+ # the content map blocks.
+
+ gen = app.backup(self._roots)
+
+ app.finish([gen])
+
+ logging.info("Backup done")