diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-03-22 14:33:15 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-03-22 14:33:15 +0200 |
commit | ba2b0261cf5766ee2fcc4e11f1f25336d82af22c (patch) | |
tree | 45b74bdc897416c7c54b6627310c9ac96ff4061f | |
parent | 0cba6730e210fae49bd296a4498b111e88d550d2 (diff) | |
parent | aaa966f88ad7022f5c54f7a413e288a1b3004bbb (diff) | |
download | obnam-ba2b0261cf5766ee2fcc4e11f1f25336d82af22c.tar.gz |
Merge fixups from Thomas Waldmann
33 files changed, 65 insertions, 118 deletions
@@ -450,7 +450,7 @@ Bug fixes: by ROGERIO DE CARVALHO BASTOS and patched by Peter Valdemar Mørch. * Setuid and setgid bits are now restored correctly, when restore happens as root. Reported by Pavel Kokolemin. -* Obnam now complains if no backup roots have been specfied. +* Obnam now complains if no backup roots have been specified. Version 1.2, released 2012-10-06 -------------------------------- diff --git a/find-all-obnam-errors b/find-all-obnam-errors index c0403dd4..711f1f8c 100755 --- a/find-all-obnam-errors +++ b/find-all-obnam-errors @@ -17,7 +17,6 @@ # =*= License: GPL-3+ =*= -import collections import imp import inspect import os diff --git a/metadata-speed b/metadata-speed index c821bf46..b183a4b9 100755 --- a/metadata-speed +++ b/metadata-speed @@ -15,9 +15,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -import os -import random -import shutil import sys import time diff --git a/obnam-benchmark b/obnam-benchmark index 0b54c612..05e62b3b 100755 --- a/obnam-benchmark +++ b/obnam-benchmark @@ -23,7 +23,6 @@ import platform import re import shutil import stat -import sys import tempfile import time diff --git a/obnamlib/app.py b/obnamlib/app.py index a3159acc..476259ae 100644 --- a/obnamlib/app.py +++ b/obnamlib/app.py @@ -17,9 +17,7 @@ import cliapp import larch import logging -import os import socket -import StringIO import sys import time import tracing @@ -85,7 +83,7 @@ class App(cliapp.Application): metavar='TIMEOUT', default=60) - # Repositofy format selection. + # Repository format selection. self.settings.choice( ['repository-format'], diff --git a/obnamlib/encryption.py b/obnamlib/encryption.py index 775e008a..ddd50fd7 100644 --- a/obnamlib/encryption.py +++ b/obnamlib/encryption.py @@ -38,9 +38,9 @@ def generate_symmetric_key(numbits, filename='/dev/random'): tracing.trace('numbits=%d', numbits) - bytes = (numbits + 7) / 8 + count = (numbits + 7) / 8 f = open(filename, 'rb') - key = f.read(bytes) + key = f.read(count) f.close() return key.encode('hex') diff --git a/obnamlib/encryption_tests.py b/obnamlib/encryption_tests.py index 0cf58394..7781be43 100644 --- a/obnamlib/encryption_tests.py +++ b/obnamlib/encryption_tests.py @@ -16,7 +16,6 @@ import os import shutil -import subprocess import tempfile import unittest diff --git a/obnamlib/fmt_6/chunklist.py b/obnamlib/fmt_6/chunklist.py index e34aa652..f94d83cf 100644 --- a/obnamlib/fmt_6/chunklist.py +++ b/obnamlib/fmt_6/chunklist.py @@ -14,9 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -import hashlib import struct -import random import tracing import obnamlib diff --git a/obnamlib/fmt_6/clientmetadatatree.py b/obnamlib/fmt_6/clientmetadatatree.py index a652fb44..ac977504 100644 --- a/obnamlib/fmt_6/clientmetadatatree.py +++ b/obnamlib/fmt_6/clientmetadatatree.py @@ -88,11 +88,11 @@ class ClientMetadataTree(obnamlib.RepositoryTree): def default_file_id(self, filename): '''Return hash of filename suitable for use as main key.''' tracing.trace(repr(filename)) - def hash(s): + def shorthash(s): return hashlib.md5(s).digest()[:4] dirname = os.path.dirname(filename) basename = os.path.basename(filename) - return hash(dirname) + hash(basename) + return shorthash(dirname) + shorthash(basename) def _bad_default_file_id(self, filename): '''For use by unit tests.''' diff --git a/obnamlib/fmt_6/clientmetadatatree_tests.py b/obnamlib/fmt_6/clientmetadatatree_tests.py index 8576bdd9..32913204 100644 --- a/obnamlib/fmt_6/clientmetadatatree_tests.py +++ b/obnamlib/fmt_6/clientmetadatatree_tests.py @@ -270,23 +270,6 @@ class ClientMetadataTreeFileOpsTests(unittest.TestCase): self.assertEqual(list(self.client.tree.lookup_range(minkey, maxkey)), []) - def test_generation_has_no_chunk_refs_initially(self): - minkey = self.client.chunk_key(0, 0) - maxkey = self.client.chunk_key(obnamlib.MAX_ID, obnamlib.MAX_ID) - self.assertEqual(list(self.client.tree.lookup_range(minkey, maxkey)), - []) - - def test_sets_file_chunks(self): - self.client.set_file_chunks('/foo', [1, 2, 3]) - self.assertEqual(self.client.get_file_chunks(self.clientid, '/foo'), - [1, 2, 3]) - - def test_generation_has_no_chunk_refs_initially(self): - minkey = self.client.chunk_key(0, 0) - maxkey = self.client.chunk_key(obnamlib.MAX_ID, obnamlib.MAX_ID) - self.assertEqual(list(self.client.tree.lookup_range(minkey, maxkey)), - []) - def test_set_file_chunks_adds_chunk_refs(self): self.client.set_file_chunks('/foo', [1, 2]) file_id = self.client.get_file_id(self.client.tree, '/foo') diff --git a/obnamlib/fmt_6/metadata_codec.py b/obnamlib/fmt_6/metadata_codec.py index 2e281c6b..55405d55 100644 --- a/obnamlib/fmt_6/metadata_codec.py +++ b/obnamlib/fmt_6/metadata_codec.py @@ -14,6 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +import logging import struct import obnamlib diff --git a/obnamlib/fmt_6/repo_fmt_6.py b/obnamlib/fmt_6/repo_fmt_6.py index 7a938c50..9f94ad4e 100644 --- a/obnamlib/fmt_6/repo_fmt_6.py +++ b/obnamlib/fmt_6/repo_fmt_6.py @@ -22,7 +22,6 @@ import os import random import re import stat -import struct import time import tracing @@ -555,7 +554,7 @@ class RepositoryFormat6(obnamlib.RepositoryInterface): def set_generation_key( self, generation_id, key, value): # pragma: no cover - # FIXME: This no worky for generations other than the currently + # FIXME: This is not working for generations other than the currently # started one. There should at least be an assert about it. client_name, gen_number = self._unpack_gen_id(generation_id) @@ -882,7 +881,7 @@ class RepositoryFormat6(obnamlib.RepositoryInterface): try: expected_checksum = self._chunklist.get_checksum(chunk_id) except KeyError: # pragma: no cover - # Chunk is not in the checksum tree, so we cannot valide + # Chunk is not in the checksum tree, so we cannot validate # its checksum. We'll just assume it's OK. return True return actual_checksum == expected_checksum diff --git a/obnamlib/fmt_6/repo_tree.py b/obnamlib/fmt_6/repo_tree.py index 64302f5a..bd755074 100644 --- a/obnamlib/fmt_6/repo_tree.py +++ b/obnamlib/fmt_6/repo_tree.py @@ -17,8 +17,6 @@ import larch import tracing -import obnamlib - class RepositoryTree(object): diff --git a/obnamlib/fmt_simple/simple.py b/obnamlib/fmt_simple/simple.py index 7651ca0a..bc6f996a 100644 --- a/obnamlib/fmt_simple/simple.py +++ b/obnamlib/fmt_simple/simple.py @@ -18,6 +18,7 @@ import copy import hashlib +import errno import os import random import StringIO @@ -419,11 +420,11 @@ class SimpleClient(SimpleToplevel): generations = self._data.get('generations', []) ids = [int(gen['id']) for gen in generations] if ids: - newest = ids[-1] - next = newest + 1 + newest_id = ids[-1] + next_id = newest_id + 1 else: - next = 1 - return str(next) + next_id = 1 + return str(next_id) def remove_generation(self, gen_number): self._require_lock() diff --git a/obnamlib/metadata_tests.py b/obnamlib/metadata_tests.py index 98fbebe7..34afe602 100644 --- a/obnamlib/metadata_tests.py +++ b/obnamlib/metadata_tests.py @@ -18,7 +18,6 @@ import os import stat import tempfile import unittest -import platform import obnamlib diff --git a/obnamlib/pluginbase.py b/obnamlib/pluginbase.py index d1a75fb4..0e8916f5 100644 --- a/obnamlib/pluginbase.py +++ b/obnamlib/pluginbase.py @@ -16,8 +16,6 @@ import cliapp -import obnamlib - class ObnamPlugin(cliapp.Plugin): diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py index 6c63955a..cbc9f237 100644 --- a/obnamlib/plugins/backup_plugin.py +++ b/obnamlib/plugins/backup_plugin.py @@ -15,17 +15,14 @@ import errno -import gc import hashlib import logging import os import re import stat -import sys import time import traceback import tracing -import ttystatus import obnamlib import larch @@ -1016,7 +1013,7 @@ class BackupPlugin(obnamlib.ObnamPlugin): self.repo.append_file_chunk_id( self.new_generation, filename, chunk_id) else: - self.self.update_progress_with_upload(len(data)) + self.progress.update_progress_with_upload(len(data)) if not self.pretend and self.time_for_checkpoint(): logging.debug('making checkpoint in the middle of a file') diff --git a/obnamlib/plugins/compression_plugin.py b/obnamlib/plugins/compression_plugin.py index 54f08566..9f0d8b68 100644 --- a/obnamlib/plugins/compression_plugin.py +++ b/obnamlib/plugins/compression_plugin.py @@ -15,7 +15,6 @@ import logging -import os import zlib import obnamlib diff --git a/obnamlib/plugins/force_lock_plugin.py b/obnamlib/plugins/force_lock_plugin.py index 931a96fc..5eaf7be3 100644 --- a/obnamlib/plugins/force_lock_plugin.py +++ b/obnamlib/plugins/force_lock_plugin.py @@ -15,7 +15,6 @@ import logging -import os import obnamlib diff --git a/obnamlib/plugins/fsck_plugin.py b/obnamlib/plugins/fsck_plugin.py index 86c7ea9b..5b9c4a64 100644 --- a/obnamlib/plugins/fsck_plugin.py +++ b/obnamlib/plugins/fsck_plugin.py @@ -15,12 +15,9 @@ import hashlib -import larch.fsck import logging -import os import stat import sys -import ttystatus import obnamlib from obnamlib import WorkItem diff --git a/obnamlib/plugins/fuse_plugin.py b/obnamlib/plugins/fuse_plugin.py index 30531295..f438feb7 100644 --- a/obnamlib/plugins/fuse_plugin.py +++ b/obnamlib/plugins/fuse_plugin.py @@ -16,7 +16,6 @@ import os import stat -import sys import logging import errno import struct @@ -419,7 +418,7 @@ class ObnamFuse(fuse.Fuse): stv = fuse.StatVfs() stv.f_bsize = 65536 stv.f_frsize = 0 - stv.f_blocks = blocks/65536 + stv.f_blocks = total_data / 65536 stv.f_bfree = 0 stv.f_bavail = 0 stv.f_files = files @@ -555,7 +554,7 @@ class MountPlugin(obnamlib.ObnamPlugin): '''Mount backup repository as a user-space filesystem. - At the momemnt only a specific generation can be mounted + At the moment only a specific generation can be mounted ''' diff --git a/obnamlib/plugins/restore_plugin.py b/obnamlib/plugins/restore_plugin.py index 7d54f412..88ea15b7 100644 --- a/obnamlib/plugins/restore_plugin.py +++ b/obnamlib/plugins/restore_plugin.py @@ -19,7 +19,6 @@ import logging import os import stat import time -import ttystatus import obnamlib diff --git a/obnamlib/plugins/sftp_plugin.py b/obnamlib/plugins/sftp_plugin.py index 6329e520..59d83ecd 100644 --- a/obnamlib/plugins/sftp_plugin.py +++ b/obnamlib/plugins/sftp_plugin.py @@ -25,8 +25,8 @@ import socket import stat import subprocess import time -import traceback import urlparse +import getpass # As of 2010-07-10, Debian's paramiko package triggers @@ -244,12 +244,9 @@ class SftpFS(obnamlib.VirtualFileSystem): return True def _connect_paramiko(self): + remote = (self.host, self.port or 22) logging.debug( - 'connect_paramiko: host=%s port=%s' % (self.host, self.port)) - if self.port: - remote = (self.host, self.port) - else: - remote = (self.host) + 'connect_paramiko: host=%s port=%s' % remote) self.transport = paramiko.Transport(remote) self.transport.connect() logging.debug('connect_paramiko: connected') @@ -591,8 +588,9 @@ class SftpFS(obnamlib.VirtualFileSystem): @ioerror_to_oserror def write_file(self, pathname, contents): + mode = 'wbx' try: - f = self.open(pathname, 'wbx') + f = self.open(pathname, mode) except (IOError, OSError), e: # When the path to the file to be written does not # exist, we try to create the directories below. Note that @@ -604,7 +602,7 @@ class SftpFS(obnamlib.VirtualFileSystem): raise dirname = os.path.dirname(pathname) self.makedirs(dirname) - f = self.open(pathname, 'wx') + f = self.open(pathname, mode) self._write_helper(f, contents) f.close() diff --git a/obnamlib/plugins/show_plugin.py b/obnamlib/plugins/show_plugin.py index 00d478d4..a15c10a5 100644 --- a/obnamlib/plugins/show_plugin.py +++ b/obnamlib/plugins/show_plugin.py @@ -14,7 +14,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -import os import re import stat import sys @@ -159,12 +158,12 @@ class ShowPlugin(obnamlib.ObnamPlugin): # the repository is empty / the client does not exist self.app.output.write('CRITICAL: no backup found.\n') sys.exit(2) - elif (now - most_recent > critical_age): + elif now - most_recent > critical_age: self.app.output.write( 'CRITICAL: backup is old. last backup was %s.\n' % (self.format_time(most_recent))) sys.exit(2) - elif (now - most_recent > warn_age): + elif now - most_recent > warn_age: self.app.output.write( 'WARNING: backup is old. last backup was %s.\n' % self.format_time(most_recent)) @@ -200,9 +199,9 @@ class ShowPlugin(obnamlib.ObnamPlugin): ended = self.format_time(ended) hdr('Generation %s (%s - %s)\n' % (self.repo.make_generation_spec(gen_id), started, ended)) - for file in args: - file = self.remove_trailing_slashes(file) - self.show_objects(cb, gen_id, file) + for filename in args: + filename = self.remove_trailing_slashes(filename) + self.show_objects(cb, gen_id, filename) self.repo.close() @@ -291,7 +290,7 @@ class ShowPlugin(obnamlib.ObnamPlugin): enc_filename = enc_filename.replace(" ", "%20") enc_filename = enc_filename.replace("\t", "%09") - if (filename == "/"): return + if filename == "/": return self.app.output.write("%s%s\t%d\t%#x\n" % (mode_str, enc_filename, size, mtime_sec)) @@ -309,7 +308,7 @@ class ShowPlugin(obnamlib.ObnamPlugin): if self.app.settings['verbose']: sys.stdout.write('%s ' % change_char) - self.show_item(gen_id, fullname) + self.show_item_ls(gen_id, fullname) else: self.app.output.write('%s %s\n' % (change_char, fullname)) @@ -449,10 +448,6 @@ class ShowPlugin(obnamlib.ObnamPlugin): timestamp, name) - def format(self, fields): - return ' '. join(self.align(widths[i], fields[i], i) - for i in range(len(fields))) - def align(self, width, field, field_no): if field_no in self.leftists: return '%-*s' % (width, field) diff --git a/obnamlib/plugins/vfs_local_plugin.py b/obnamlib/plugins/vfs_local_plugin.py index 2851c5d6..d72ac91a 100644 --- a/obnamlib/plugins/vfs_local_plugin.py +++ b/obnamlib/plugins/vfs_local_plugin.py @@ -15,9 +15,6 @@ import logging -import os -import re -import stat import obnamlib diff --git a/obnamlib/repo_dummy.py b/obnamlib/repo_dummy.py index 3263a216..09664fee 100644 --- a/obnamlib/repo_dummy.py +++ b/obnamlib/repo_dummy.py @@ -222,7 +222,7 @@ class DummyClient(object): return ('file', gen_id, filename) def _is_filekey(self, key): - return (type(key) is tuple and len(key) == 3 and key[0] == 'file') + return type(key) is tuple and len(key) == 3 and key[0] == 'file' def file_exists(self, gen_id, filename): return self.data.get_value(self._filekey(gen_id, filename), False) @@ -248,7 +248,7 @@ class DummyClient(object): return ('filekey', gen_id, filename, key) def _is_filekeykey(self, key): - return (type(key) is tuple and len(key) == 4 and key[0] == 'filekey') + return type(key) is tuple and len(key) == 4 and key[0] == 'filekey' def _require_file(self, gen_id, filename): if not self.file_exists(gen_id, filename): diff --git a/obnamlib/repo_interface.py b/obnamlib/repo_interface.py index 6b5c2a20..b39f8abe 100644 --- a/obnamlib/repo_interface.py +++ b/obnamlib/repo_interface.py @@ -28,7 +28,7 @@ import obnamlib # The following is a canonical list of all keys that can be used with # the repository interface for key/value pairs. Not all formats need # to support all keys, but they all must support the test keys, for -# the test suite to function. All commong file metadata keys must also +# the test suite to function. All common file metadata keys must also # be supported by all formats. # # The keys may change in value from run to run. Treat them as opaque, @@ -239,7 +239,7 @@ class RepositoryInterface(object): implementation with the ``set_fs`` method. It must be stressed that ALL access to the repository go via - an implemention of RepositoryInterface. Further, all the + an implementation of RepositoryInterface. Further, all the implementation classes must be instantiated via RepositoryFactory. The abstraction RepositoryInterface provides for repositories @@ -479,7 +479,7 @@ class RepositoryInterface(object): raise NotImplementedError() def get_client_generation_ids(self, client_name): - '''Return a list of opague ids for generations in a client. + '''Return a list of opaque ids for generations in a client. The list is ordered: the first id in the list is the oldest generation. The ids needs not be sortable, and they may or @@ -712,7 +712,7 @@ class RepositoryInterface(object): '''Have we got the chunk index lock?''' raise NotImplementedError() - def force_chunk_indexex_lock(self): + def force_chunk_indexes_lock(self): '''Forces a chunk index lock open.''' raise NotImplementedError() @@ -801,7 +801,7 @@ class RepositoryInterface(object): # Fsck. - def get_fsck_work_items(self, settings): + def get_fsck_work_items(self): '''Returns fsck work items for checking this repository. This may be a generator or may return an iterable data @@ -810,9 +810,6 @@ class RepositoryInterface(object): The returned work items are of type obnamlib.WorkItem. It may return further work items. - The settings argument is of type cliapp.Settings, and lets - the user affect what work gets done. - ''' raise NotImplementedError() @@ -1208,7 +1205,7 @@ class RepositoryInterfaceTests(unittest.TestCase): # pragma: no cover 'fooclient', obnamlib.REPO_CLIENT_TEST_KEY) self.assertEqual(value, 'bar') - def test_setting_unallowed_client_key_fails(self): + def test_setting_disallowed_client_key_fails(self): self.setup_client() self.repo.lock_client('fooclient') self.assertRaises( @@ -1223,7 +1220,7 @@ class RepositoryInterfaceTests(unittest.TestCase): # pragma: no cover self.repo.set_client_key, 'fooclient', obnamlib.REPO_CLIENT_TEST_KEY, 'bar') - def test_committing_client_preserves_key_changs(self): + def test_committing_client_preserves_key_changes(self): if self.client_test_key_is_allowed(): self.setup_client() self.repo.lock_client('fooclient') @@ -1337,7 +1334,7 @@ class RepositoryInterfaceTests(unittest.TestCase): # pragma: no cover gen_id, obnamlib.REPO_GENERATION_TEST_KEY) self.assertEqual(value, 'bar') - def test_setting_unallowed_generation_key_fails(self): + def test_setting_disallowed_generation_key_fails(self): if self.generation_test_key_is_allowed(): gen_id = self.create_generation() self.assertRaises( @@ -1353,7 +1350,7 @@ class RepositoryInterfaceTests(unittest.TestCase): # pragma: no cover self.repo.set_generation_key, gen_id, obnamlib.REPO_GENERATION_TEST_KEY, 'bar') - def test_committing_client_preserves_generation_key_changs(self): + def test_committing_client_preserves_generation_key_changes(self): if self.generation_test_key_is_allowed(): gen_id = self.create_generation() self.repo.set_generation_key( @@ -1589,7 +1586,7 @@ class RepositoryInterfaceTests(unittest.TestCase): # pragma: no cover gen_id, '/foo/bar', obnamlib.REPO_FILE_TEST_KEY) self.assertEqual(value, 'yoyo') - def test_setting_unallowed_file_key_fails(self): + def test_setting_disallowed_file_key_fails(self): gen_id = self.create_generation() self.repo.add_file(gen_id, '/foo/bar') self.assertRaises( @@ -1875,7 +1872,7 @@ class RepositoryInterfaceTests(unittest.TestCase): # pragma: no cover set(self.repo.get_chunk_ids()), set([chunk_id_1, chunk_id_2])) - def test_have_not_got_chunk_indexes_lock_initally(self): + def test_have_not_got_chunk_indexes_lock_initially(self): self.setup_client() self.assertFalse(self.repo.got_chunk_indexes_lock()) diff --git a/obnamlib/structurederror.py b/obnamlib/structurederror.py index 18c13e5a..16051743 100644 --- a/obnamlib/structurederror.py +++ b/obnamlib/structurederror.py @@ -100,8 +100,8 @@ class StructuredError(Exception): summer = hashlib.md5() summer.update(self.__class__.__name__) summer.update(self.__class__.__module__) - hash = summer.hexdigest()[:5] - return 'R{0}X'.format(hash.upper()) + shorthash = summer.hexdigest()[:5] + return 'R{0}X'.format(shorthash.upper()) def _format_msg(self, template): # In case template is a docstring, remove leading whitespace diff --git a/obnamlib/structurederror_tests.py b/obnamlib/structurederror_tests.py index b11909c0..9b24238b 100644 --- a/obnamlib/structurederror_tests.py +++ b/obnamlib/structurederror_tests.py @@ -62,11 +62,11 @@ class StructuredErrorTests(unittest.TestCase): def test_str_returns_first_line_only(self): first = FirstError() - self.assertNotIn('\n', str(first)) + self.assertTrue('\n' not in str(first)) def test_formatted_returns_full_message(self): first = FirstError() - self.assertIn('\n', first.formatted()) + self.assertTrue('\n' in first.formatted()) def test_formatted_message_does_not_end_in_whitespace(self): first = FirstError() diff --git a/obnamlib/vfs.py b/obnamlib/vfs.py index 3f99c045..7bf75f6c 100644 --- a/obnamlib/vfs.py +++ b/obnamlib/vfs.py @@ -15,7 +15,6 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import errno import logging import os import stat @@ -359,7 +358,7 @@ class VfsTests(object): # pragma: no cover * self.basepath to the path to the base of the filesystem basepath must be operable as a pathname using os.path tools. If - the VFS implemenation operates remotely and wants to operate on a + the VFS implementation operates remotely and wants to operate on a URL like 'http://domain/path' as the baseurl, then basepath must be just the path portion of the URL. @@ -608,7 +607,7 @@ class VfsTests(object): # pragma: no cover self.assertEqual(self.fs.lstat('foo').st_atime_sec, 1) # not all filesystems support sub-second timestamps; those that # do not, return 0, so we have to accept either that or the correct - # value, but no other vlaues + # value, but no other values self.assert_(self.fs.lstat('foo').st_atime_nsec in [0, 2*1000]) self.assertEqual(self.fs.lstat('foo').st_mtime_sec, 3) diff --git a/obnamlib/vfs_local.py b/obnamlib/vfs_local.py index 595795c4..c9b105e3 100644 --- a/obnamlib/vfs_local.py +++ b/obnamlib/vfs_local.py @@ -19,7 +19,6 @@ import errno import fcntl import grp import logging -import math import os import pwd import tempfile @@ -38,6 +37,11 @@ class MallocError(obnamlib.ObnamError): msg = 'malloc out of memory while calling {function}' +class RootIsNotADirectory(obnamlib.ObnamError): + + msg = '{baserurl} is not a directory, but a VFS root must be a directory' + + class LocalFSFile(file): def read(self, amount=-1): @@ -95,7 +99,7 @@ class LocalFS(obnamlib.VirtualFileSystem): self.cwd = os.path.abspath(baseurl) if os.path.exists(self.cwd): # pragma: no cover if not os.path.isdir(self.cwd): - raise obnamlib.Error('%s is not a directory' % baseurl) + raise RootIsNotADirectory(baseurl=baseurl) if not self.isdir('.'): if create: tracing.trace('creating %s', baseurl) @@ -274,7 +278,7 @@ class LocalFS(obnamlib.VirtualFileSystem): return os.path.isdir(self.join(pathname)) def mknod(self, pathname, mode): - tracing.trace('pathmame=%s', pathname) + tracing.trace('pathname=%s', pathname) tracing.trace('mode=%o', mode) os.mknod(self.join(pathname), mode) @@ -402,7 +406,7 @@ class LocalFS(obnamlib.VirtualFileSystem): ino = st.st_ino result.append((ino, name, st)) - # We sort things in inode order, for speed when doing namei lookups + # We sort things in inode order, for speed when doing name lookups # when backing up. result.sort() return [(name, st) for ino, name, st in result] diff --git a/obnamlib/vfs_local_tests.py b/obnamlib/vfs_local_tests.py index 950675e4..eb497d2f 100644 --- a/obnamlib/vfs_local_tests.py +++ b/obnamlib/vfs_local_tests.py @@ -14,8 +14,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import platform -import errno import os import shutil import tempfile @@ -50,7 +48,7 @@ class LocalFSTests(obnamlib.VfsTests, unittest.TestCase): def test_get_groupname_returns_root_for_zero(self): # Some Unix systems have a wheel group instead of a root # group. We're fine with either. - self.assertIn(self.fs.get_groupname(0), ['root', 'wheel']) + self.assertTrue(self.fs.get_groupname(0) in ['root', 'wheel']) class XAttrTests(unittest.TestCase): @@ -71,13 +69,13 @@ class XAttrTests(unittest.TestCase): # attribute with the command line tool. try: - exit, out, err = cliapp.runcmd_unchecked( + exitcode, out, err = cliapp.runcmd_unchecked( ['setfattr', '-n', 'user.foo', 'bar', self.other]) except OSError: # Either xattr aren't supported, or setfattr isn't # installed and we can't test. return False - return exit == 0 + return exitcode == 0 def test_empty_list(self): '''A new file has no extended attributes.''' @@ -192,8 +192,8 @@ class Check(Command): os.remove('.coverage') def run_yarn(self): - for format in self.get_wanted_formats(): - self.run_yarn_for_repo_format(format) + for repo_format in self.get_wanted_formats(): + self.run_yarn_for_repo_format(repo_format) def get_wanted_formats(self): if 'REPOSITORY_FORMAT' in os.environ: @@ -201,11 +201,11 @@ class Check(Command): else: return ['6', 'simple'] - def run_yarn_for_repo_format(self, format): - print 'run yarn for repository format %s' % format + def run_yarn_for_repo_format(self, repo_format): + print 'run yarn for repository format %s' % repo_format runcmd( ['yarn', '-s', 'yarns/obnam.sh'] + - ['--env', 'REPOSITORY_FORMAT=' + format] + + ['--env', 'REPOSITORY_FORMAT=' + repo_format] + glob.glob('yarns/*.yarn')) def run_lock_test(self, num_clients, num_generations): |