summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-08-08 17:48:23 +0100
committerLars Wirzenius <liw@liw.fi>2011-08-08 17:48:23 +0100
commitba20bfebd024c9a41a98a58ec8c2848dec0ce80c (patch)
treec6f4f1999ca59c8d096b107fd1dc5372160b97f8
parenta9bc9080137e5add15c81f6071567caa67a9f91b (diff)
downloadobnam-ba20bfebd024c9a41a98a58ec8c2848dec0ce80c.tar.gz
Only use obnamlib.Error, get rid of obnamlib.AppException.
-rw-r--r--obnamlib/__init__.py3
-rw-r--r--obnamlib/plugins/force_lock_plugin.py6
-rw-r--r--obnamlib/plugins/restore_plugin.py4
-rw-r--r--obnamlib/plugins/sftp_plugin.py16
-rw-r--r--obnamlib/plugins/verify_plugin.py2
-rw-r--r--obnamlib/repo.py6
-rw-r--r--obnamlib/sizeparse.py2
-rw-r--r--obnamlib/vfs_local.py3
8 files changed, 18 insertions, 24 deletions
diff --git a/obnamlib/__init__.py b/obnamlib/__init__.py
index 0fa8634d..25ccdd1f 100644
--- a/obnamlib/__init__.py
+++ b/obnamlib/__init__.py
@@ -23,12 +23,11 @@ __version__ = '0.19'
import _obnam
from pluginmgr import PluginManager
-class AppException(cliapp.AppException):
- pass
class Error(cliapp.AppException):
pass
+
DEFAULT_NODE_SIZE = 64 * 1024
DEFAULT_CHUNK_SIZE = 64 * 1024
DEFAULT_UPLOAD_QUEUE_SIZE = 1024
diff --git a/obnamlib/plugins/force_lock_plugin.py b/obnamlib/plugins/force_lock_plugin.py
index 30e93954..84b32aa3 100644
--- a/obnamlib/plugins/force_lock_plugin.py
+++ b/obnamlib/plugins/force_lock_plugin.py
@@ -39,9 +39,9 @@ class ForceLockPlugin(obnamlib.ObnamPlugin):
try:
repo = self.app.open_repository()
except OSError, e:
- raise obnamlib.AppException('Repository does not exist '
- 'or cannot be accessed.\n' +
- str(e))
+ raise obnamlib.Error('Repository does not exist '
+ 'or cannot be accessed.\n' +
+ str(e))
if client_name not in repo.list_clients():
logging.warning('Client does not exist in repository.')
diff --git a/obnamlib/plugins/restore_plugin.py b/obnamlib/plugins/restore_plugin.py
index 8faf9528..9c2ac83b 100644
--- a/obnamlib/plugins/restore_plugin.py
+++ b/obnamlib/plugins/restore_plugin.py
@@ -103,7 +103,7 @@ class RestorePlugin(obnamlib.ObnamPlugin):
self.restore_file(gen, '.', arg)
if self.errors:
- raise obnamlib.AppException('There were errors when restoring')
+ raise obnamlib.Error('There were errors when restoring')
def restore_recursively(self, gen, to_dir, root):
logging.debug('restoring dir %s' % root)
@@ -207,7 +207,7 @@ class RestorePlugin(obnamlib.ObnamPlugin):
# mean it is invalid. We'll assume it is valid.
return
if checksum != wanted:
- raise obnamlib.AppException('chunk %s checksum error' % chunkid)
+ raise obnamlib.Error('chunk %s checksum error' % chunkid)
def restore_fifo(self, gen, to_dir, filename, metadata):
logging.debug('restoring fifo %s' % filename)
diff --git a/obnamlib/plugins/sftp_plugin.py b/obnamlib/plugins/sftp_plugin.py
index d7242cdc..f2aeefad 100644
--- a/obnamlib/plugins/sftp_plugin.py
+++ b/obnamlib/plugins/sftp_plugin.py
@@ -146,13 +146,11 @@ class SftpFS(obnamlib.VirtualFileSystem):
known_hosts = os.path.expanduser('~/.ssh/known_hosts')
keys = paramiko.util.load_host_keys(known_hosts)
if hostname not in keys:
- raise obnamlib.AppException('Host not in known_hosts: %s' %
- hostname)
+ raise obnamlib.Error('Host not in known_hosts: %s' % hostname)
elif not keys[hostname].has_key(key.get_name()):
- raise obnamlib.AppException('No host key for %s' % hostname)
+ raise obnamlib.Error('No host key for %s' % hostname)
elif keys[hostname][key.get_name()] != key:
- raise obnamlib.AppException('Host key has changed for %s' %
- hostname)
+ raise obnamlib.Error('Host key has changed for %s' % hostname)
def _authenticate(self, username):
agent = paramiko.Agent()
@@ -163,8 +161,7 @@ class SftpFS(obnamlib.VirtualFileSystem):
return
except paramiko.SSHException:
pass
- raise obnamlib.AppException('Can\'t authenticate to SSH server '
- 'using agent.')
+ raise obnamlib.Error('Can\'t authenticate to SSH server using agent.')
def close(self):
self.sftp.close()
@@ -228,8 +225,7 @@ class SftpFS(obnamlib.VirtualFileSystem):
self.write_file(lockname, '')
except IOError, e:
if e.errno == errno.EEXIST:
- raise obnamlib.AppException('Lock %s already exists' %
- lockname)
+ raise obnamlib.Error('Lock %s already exists' % lockname)
else:
raise
@@ -328,7 +324,7 @@ class SftpFS(obnamlib.VirtualFileSystem):
self.sftp.utime(pathname, (atime, mtime))
def link(self, existing_path, new_path):
- raise obnamlib.AppException('Cannot hardlink on SFTP. Sorry.')
+ raise obnamlib.Error('Cannot hardlink on SFTP. Sorry.')
def readlink(self, symlink):
return self.sftp.readlink(symlink)
diff --git a/obnamlib/plugins/verify_plugin.py b/obnamlib/plugins/verify_plugin.py
index eb4bbf8d..acd50fcd 100644
--- a/obnamlib/plugins/verify_plugin.py
+++ b/obnamlib/plugins/verify_plugin.py
@@ -23,7 +23,7 @@ import urlparse
import obnamlib
-class Fail(obnamlib.AppException):
+class Fail(obnamlib.Error):
def __init__(self, filename, reason):
self.filename = filename
diff --git a/obnamlib/repo.py b/obnamlib/repo.py
index d46466b8..49e9a60e 100644
--- a/obnamlib/repo.py
+++ b/obnamlib/repo.py
@@ -28,12 +28,12 @@ import tracing
import obnamlib
-class LockFail(obnamlib.AppException):
+class LockFail(obnamlib.Error):
pass
-class BadFormat(obnamlib.AppException):
+class BadFormat(obnamlib.Error):
pass
@@ -278,7 +278,7 @@ class Repository(object):
msg = ('Invalid repository format version (%s) -- '
'forgot encryption?' %
repr(line))
- raise obnamlib.AppException(msg)
+ raise obnamlib.Error(msg)
return version
else:
return None
diff --git a/obnamlib/sizeparse.py b/obnamlib/sizeparse.py
index ef465fc8..753caadb 100644
--- a/obnamlib/sizeparse.py
+++ b/obnamlib/sizeparse.py
@@ -19,7 +19,7 @@ import re
import obnamlib
-class UnitError(obnamlib.AppException):
+class UnitError(obnamlib.Error):
def __str__(self):
return self.msg
diff --git a/obnamlib/vfs_local.py b/obnamlib/vfs_local.py
index c9a2b69e..c4b982f8 100644
--- a/obnamlib/vfs_local.py
+++ b/obnamlib/vfs_local.py
@@ -85,8 +85,7 @@ class LocalFS(obnamlib.VirtualFileSystem):
self.write_file(lockname, "")
except OSError, e:
if e.errno == errno.EEXIST:
- raise obnamlib.AppException("Lock %s already exists" %
- lockname)
+ raise obnamlib.Error("Lock %s already exists" % lockname)
else:
raise