summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@gytha>2008-06-10 22:52:08 +0300
committerLars Wirzenius <liw@gytha>2008-06-10 22:52:08 +0300
commitd72a5e7ee57e24a2c237a50643edf0f364f72f42 (patch)
tree69e7c82bafb82dc173a564ca7b5f575b6b6cca4f
parentd20e56b8c143dd0b432b1c755324acaaa25470e8 (diff)
downloadobnam-d72a5e7ee57e24a2c237a50643edf0f364f72f42.tar.gz
Remove odirect_read and odirect_pipe.
-rw-r--r--.bzrignore3
-rw-r--r--Makefile16
-rw-r--r--check-license-exceptions1
-rwxr-xr-xcheck-options2
-rwxr-xr-xobnam20
-rw-r--r--obnam.docbook19
-rw-r--r--obnamlib/config.py14
-rw-r--r--obnamlib/configTests.py14
-rw-r--r--obnamlib/defaultconfig.py2
-rw-r--r--obnamlib/io.py2
-rw-r--r--obnamlib/rsync.py12
-rw-r--r--obnamlib/rsyncTests.py7
-rwxr-xr-xodirect_pipe7
-rw-r--r--odirect_pipe.docbook72
-rw-r--r--odirect_read.c140
-rw-r--r--odirect_read.docbook77
-rwxr-xr-xshowblock16
-rwxr-xr-xtest_odirect_read80
18 files changed, 29 insertions, 475 deletions
diff --git a/.bzrignore b/.bzrignore
index 664822cf..7cd9bc21 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -1,6 +1,3 @@
-odirect_read
obnam.1
-odirect_read.1
sample-gpg-home/random_seed
-odirect_pipe.1
obnamfs.1
diff --git a/Makefile b/Makefile
index 9b09b32c..6ce6ee89 100644
--- a/Makefile
+++ b/Makefile
@@ -27,27 +27,18 @@ man1dir = $(mandir)/man1
pydir = $(libdir)/python2.5
sitedir = $(pydir)/site-packages
-all: odirect_read obnam.1 odirect_read.1 odirect_pipe.1 obnamfs.1
+all: obnam.1 obnamfs.1
version:
./obnam --version
-odirect_read: odirect_read.c
-
obnam.1: obnam.docbook
docbook2x-man --encoding utf8 obnam.docbook
obnamfs.1: obnamfs.docbook
docbook2x-man --encoding utf8 obnamfs.docbook
-odirect_read.1: odirect_read.docbook
- docbook2x-man --encoding utf8 odirect_read.docbook
-
-odirect_pipe.1: odirect_pipe.docbook
- docbook2x-man --encoding utf8 odirect_pipe.docbook
-
check: all
- ./test_odirect_read
python -m CoverageTestRunner --ignore-coverage
rm -f .coverage
sh blackboxtests tests/*
@@ -59,7 +50,7 @@ check: all
clean:
rm -rf *~ */*~ *.pyc *.pyo */*.pyc */*.pyo tmp.* *,cover */*,cover
- rm -f obnam.1 odirect_read.1 odirect_read odirect_pipe.1 obnamfs.1
+ rm -f obnam.1 obnamfs.1
rm -f .coverage
@@ -67,7 +58,6 @@ install: all
install -d $(bindir)
install obnam $(bindir)/obnam
install obnamfs.py $(bindir)/obnamfs
- install odirect_read odirect_pipe $(bindir)
install -d $(man1dir)
install -m 0644 *.1 $(man1dir)
install -d $(sitedir)/obnam
@@ -76,8 +66,6 @@ install: all
--gpg-encrypt-to= \
--gpg-home= \
--gpg-sign-with= \
- --odirect-read=odirect_read \
- --odirect-pipe=odirect_pipe \
--ssh-key= \
--store= \
--host-id= \
diff --git a/check-license-exceptions b/check-license-exceptions
index bed6531f..4220098c 100644
--- a/check-license-exceptions
+++ b/check-license-exceptions
@@ -15,7 +15,6 @@ debian/rules
HACKING
NEWS
obnamlib/defaultconfig.py
-odirect_pipe
sample-gpg-home/pubring.gpg
sample-gpg-home/secring.gpg
sample-gpg-home/trustdb.gpg
diff --git a/check-options b/check-options
index dd005a00..7afa7db4 100755
--- a/check-options
+++ b/check-options
@@ -29,7 +29,7 @@ from_manpage()
from_code()
{
- python -c 'import obnam; obnam.config.print_option_names()' |
+ python -c 'import obnamlib; obnamlib.config.print_option_names()' |
sort
}
diff --git a/obnam b/obnam
index 2922dd0b..2a3a6723 100755
--- a/obnam
+++ b/obnam
@@ -24,24 +24,24 @@ import logging
import sys
import traceback
-import obnam
+import obnamlib
def main():
try:
- context = obnam.context.Context()
- args = obnam.config.parse_options(context.config, sys.argv[1:])
- context.cache = obnam.cache.Cache(context.config)
- context.be = obnam.backend.init(context.config, context.cache)
+ context = obnamlib.context.Context()
+ args = obnamlib.config.parse_options(context.config, sys.argv[1:])
+ context.cache = obnamlib.cache.Cache(context.config)
+ context.be = obnamlib.backend.init(context.config, context.cache)
context.be.set_progress_reporter(context.progress)
- app = obnam.Application(context)
+ app = obnamlib.Application(context)
- obnam.log.setup(context.config)
+ obnamlib.log.setup(context.config)
- logging.info("%s %s starting up" % (obnam.NAME, obnam.VERSION))
+ logging.info("%s %s starting up" % (obnamlib.NAME, obnamlib.VERSION))
try:
- factory = obnam.OperationFactory(app)
+ factory = obnamlib.OperationFactory(app)
oper = factory.get_operation(args)
oper.do_it(args[1:])
@@ -60,7 +60,7 @@ def main():
if app.get_store():
app.get_store().close()
sys.exit(1)
- except obnam.ObnamException, e:
+ except obnamlib.ObnamException, e:
logging.error("%s" % str(e))
sys.stderr.write("%s\n" % str(e))
if app.get_store():
diff --git a/obnam.docbook b/obnam.docbook
index 62283334..69a0f51e 100644
--- a/obnam.docbook
+++ b/obnam.docbook
@@ -258,23 +258,6 @@ sftp://ulla@example.com/~/safe
</varlistentry>
<varlistentry>
- <term><option>--odirect-pipe</option>=<replaceable>DIR</replaceable></term>
- <listitem>
- <para>Use <replaceable>DIR</replaceable> as the odirect_pipe
- program (default is helper that avoids buffer cache).</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term><option>--odirect-read</option>=<replaceable>PROGRAM</replaceable></term>
- <listitem>
- <para>Use <replaceable>PROGRAM</replaceable> to read contents
- of plain files (default is helper that avoids buffer
- cache).</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
<term><option>--progress</option></term>
<listitem>
<para>Report progress of backups as they're made.</para>
@@ -338,8 +321,6 @@ host-id = dorfl
log-file =
log-level = warning
no-gpg = false
-odirect-pipe = ./odirect_pipe
-odirect-read = ./odirect_read
ssh-key = ssh-key
store = tmp.store</programlisting>
diff --git a/obnamlib/config.py b/obnamlib/config.py
index 32f7ae55..317ae39e 100644
--- a/obnamlib/config.py
+++ b/obnamlib/config.py
@@ -86,16 +86,6 @@ def build_parser():
help="read ssh private key from FILE (and public key " +
"from FILE.pub)")
- parser.add_option("--odirect-read",
- metavar="PROGRAM",
- help="use PROGRAM to read contents of plain files " +
- "(default is helper that avoids buffer cache)")
-
- parser.add_option("--odirect-pipe",
- metavar="PROGRAM",
- help="use PROGRAM as the odirect_pipe program " +
- "(default is helper that avoids buffer cache)")
-
parser.add_option("--gpg-home",
metavar="DIR",
help="use DIR as the location for GnuPG keyrings and " +
@@ -197,10 +187,6 @@ def parse_options(config, argv):
config.set("backup", "log-level", options.log_level)
if options.ssh_key is not None:
config.set("backup", "ssh-key", options.ssh_key)
- if options.odirect_read is not None:
- config.set("backup", "odirect-read", options.odirect_read)
- if options.odirect_pipe is not None:
- config.set("backup", "odirect-pipe", options.odirect_pipe)
if options.gpg_home is not None:
config.set("backup", "gpg-home", options.gpg_home)
if options.gpg_encrypt_to is not None:
diff --git a/obnamlib/configTests.py b/obnamlib/configTests.py
index 80e3cd0b..957f7efa 100644
--- a/obnamlib/configTests.py
+++ b/obnamlib/configTests.py
@@ -45,8 +45,8 @@ class CommandLineParsingTests(unittest.TestCase):
self.failUnless(config.has_section("backup"))
needed = ["block-size", "cache", "store", "target-dir",
"host-id", "object-cache-size", "log-level", "ssh-key",
- "odirect-read", "log-file", "gpg-home", "gpg-encrypt-to",
- "gpg-sign-with", "no-gpg", "exclude", "odirect-pipe",
+ "log-file", "gpg-home", "gpg-encrypt-to",
+ "gpg-sign-with", "no-gpg", "exclude",
"report-progress", "generation-times"]
needed.sort()
actual = config.options("backup")
@@ -91,16 +91,6 @@ class CommandLineParsingTests(unittest.TestCase):
obnamlib.config.parse_options(config, ["--object-cache-size=42"])
self.failUnlessEqual(config.get("backup", "object-cache-size"), "42")
- def testOdirectRead(self):
- config = obnamlib.config.default_config()
- obnamlib.config.parse_options(config, ["--odirect-read=x"])
- self.failUnlessEqual(config.get("backup", "odirect-read"), "x")
-
- def testOdirectPipe(self):
- config = obnamlib.config.default_config()
- obnamlib.config.parse_options(config, ["--odirect-pipe=x"])
- self.failUnlessEqual(config.get("backup", "odirect-pipe"), "x")
-
def testLogFile(self):
config = obnamlib.config.default_config()
obnamlib.config.parse_options(config, ["--log-file=x"])
diff --git a/obnamlib/defaultconfig.py b/obnamlib/defaultconfig.py
index 63a5c401..2f37c53f 100644
--- a/obnamlib/defaultconfig.py
+++ b/obnamlib/defaultconfig.py
@@ -12,8 +12,6 @@ items = (
("backup", "object-cache-size", "0"),
("backup", "log-file", ""),
("backup", "log-level", "warning"),
- ("backup", "odirect-read", "./odirect_read"),
- ("backup", "odirect-pipe", "./odirect_pipe"),
("backup", "gpg-home", "sample-gpg-home"),
("backup", "gpg-encrypt-to", "490C9ED1"),
("backup", "gpg-sign-with", "490C9ED1"),
diff --git a/obnamlib/io.py b/obnamlib/io.py
index 59c14976..b19e1cc9 100644
--- a/obnamlib/io.py
+++ b/obnamlib/io.py
@@ -196,7 +196,7 @@ def create_file_contents_object(context, filename):
"""Create and queue objects to hold a file's contents"""
object_id = obnamlib.obj.object_id_new()
part_ids = []
- odirect_read = context.config.get("backup", "odirect-read")
+ odirect_read = "cat"
block_size = context.config.getint("backup", "block-size")
f = subprocess.Popen([odirect_read, resolve(context, filename)],
stdout=subprocess.PIPE)
diff --git a/obnamlib/rsync.py b/obnamlib/rsync.py
index 8deaa562..8f70fa5a 100644
--- a/obnamlib/rsync.py
+++ b/obnamlib/rsync.py
@@ -56,13 +56,10 @@ def run_command(argv, stdin=None, stdout=None, stderr=None):
return p
-def compute_signature(context, filename):
+def compute_signature(context, filename, rdiff="rdiff"):
"""Compute an rsync signature for 'filename'"""
- argv = [context.config.get("backup", "odirect-pipe"),
- context.config.get("backup", "odirect-read"),
- filename,
- "rdiff", "--", "signature", "-", "-"]
+ argv = [rdiff, "--", "signature", filename, "-"]
p = run_command(argv)
stdout_data, stderr_data = p.communicate()
@@ -83,10 +80,7 @@ def compute_delta(context, signature, filename):
os.write(fd, signature)
os.close(fd)
- argv = [context.config.get("backup", "odirect-pipe"),
- context.config.get("backup", "odirect-read"),
- filename,
- "rdiff", "--", "delta", tempname, "-", "-"]
+ argv = ["rdiff", "--", "delta", tempname, filename, "-"]
p = run_command(argv)
list = []
diff --git a/obnamlib/rsyncTests.py b/obnamlib/rsyncTests.py
index c85c16ef..8e4ac5e2 100644
--- a/obnamlib/rsyncTests.py
+++ b/obnamlib/rsyncTests.py
@@ -48,10 +48,9 @@ class RsyncTests(unittest.TestCase):
os.close(fd)
context = obnamlib.context.Context()
- context.config.set("backup", "odirect-pipe", "/notexist")
self.failUnlessRaises(obnamlib.rsync.UnknownCommand,
obnamlib.rsync.compute_signature,
- context, empty_file)
+ context, empty_file, rdiff="unknown_command")
os.remove(empty_file)
@@ -60,10 +59,9 @@ class RsyncTests(unittest.TestCase):
os.close(fd)
context = obnamlib.context.Context()
- context.config.set("backup", "odirect-pipe", "false")
self.failUnlessRaises(obnamlib.rsync.CommandFailure,
obnamlib.rsync.compute_signature,
- context, empty_file)
+ context, empty_file, rdiff="false")
os.remove(empty_file)
@@ -72,7 +70,6 @@ class RsyncTests(unittest.TestCase):
os.close(fd)
context = obnamlib.context.Context()
- context.config.set("backup", "odirect-pipe", "false")
self.failUnlessRaises(obnamlib.rsync.CommandFailure,
obnamlib.rsync.compute_delta,
context, "pink", empty_file)
diff --git a/odirect_pipe b/odirect_pipe
deleted file mode 100755
index 210b6f1c..00000000
--- a/odirect_pipe
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-odirect="$1"
-filename="$2"
-shift 2
-"$odirect" "$filename" |
-exec "$@"
diff --git a/odirect_pipe.docbook b/odirect_pipe.docbook
deleted file mode 100644
index 4d3fbb44..00000000
--- a/odirect_pipe.docbook
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-
-Copyright 2007 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.,
-59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
--->
-
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN"
-"file:///usr/share/xml/docbook/schema/dtd/4.4/docbookx.dtd"
-[]>
-
-<refentry>
-
- <refentryinfo>
- <address>
- <email>liw@iki.fi</email>
- </address>
- <author>
- <firstname>Lars</firstname>
- <surname>Wirzenius</surname>
- </author>
- <date>2007-01-14</date>
- </refentryinfo>
-
- <refmeta>
- <refentrytitle>odirect_pipe</refentrytitle>
- <manvolnum>1</manvolnum>
- </refmeta>
-
- <refnamediv>
- <refname>odirect_pipe</refname>
- <refpurpose>run a filter and feed it's stdin via odirect_read</refpurpose>
- </refnamediv>
-
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>odirect_pipe</command>
- <arg><replaceable>odirect_read</replaceable></arg>
- <arg><replaceable>filename</replaceable></arg>
- <arg><replaceable>command</replaceable></arg>
- <arg><replaceable>arg...</replaceable></arg>
- </cmdsynopsis>
- </refsynopsisdiv>
-
- <refsect1>
- <title>DESCRIPTION</title>
-
- <para><command>odirect_pipe</command> runs a command that reads input
- from the standard input, and feeds it the input through
- <command>odirect_read</command>.</para>
-
- <para><command>odirect_read</command> is used by the
- <command>obnam</command> backup tool.</para>
-
- </refsect1>
-
-</refentry>
diff --git a/odirect_read.c b/odirect_read.c
deleted file mode 100644
index 5f92e005..00000000
--- a/odirect_read.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * odirect_read.c -- copy specified file to stdout, using O_DIRECT
- *
- * Copyright (C) 2006 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.
- */
-
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/vfs.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-
-int main(int argc, char **argv)
-{
- int fd;
- ssize_t num_read;
- ssize_t num_written;
- void *buf;
- int error;
- struct statfs sfs;
- size_t buf_size;
-
- if (argc != 2) {
- fprintf(stderr, "Usage: %s filename\n", argv[0]);
- fprintf(stderr, "Note: exactly one argument, this ain't cat\n");
- return EXIT_FAILURE;
- }
-
- fd = open(argv[1], O_RDONLY | O_DIRECT | O_LARGEFILE);
- if (fd == -1) {
- /*
- * Let's try this again without O_DIRECT, just in case we're trying
- * to read a device file, or a network filesystem, or something
- * else that won't work with O_DIRECT.
- */
- open_without_o_direct:
- fd = open(argv[1], O_RDONLY | O_LARGEFILE);
- }
- if (fd == -1) {
- fprintf(stderr, "%s: ERROR: Trying to open %s: %d: %s\n",
- argv[0], argv[1], errno, strerror(errno));
- return EXIT_FAILURE;
- }
-
- /*
- * Linux 2.4 requires the buffer to be aligned at the filesystem
- * block size, the transfer size needs to be a multiple of the block
- * size, and also for the file offset to be a multiple of the
- * filesystem block size. We allocate a block that is a multiple of
- * said size and that should take care of things.
- */
-
- if (fstatfs(fd, &sfs) == -1) {
- fprintf(stderr, "%s: ERROR: Trying to statfs %s: %d: %s\n",
- argv[1], errno, strerror(errno));
- return EXIT_FAILURE;
- }
-
- /*
- * In some quick testing, buffers much bigger than this did not make
- * things happen faster.
- */
- buf_size = sfs.f_bsize * 32;
-
- error = posix_memalign(&buf, sfs.f_bsize, buf_size);
- if (error != 0) {
- fprintf(stderr, "%s: ERROR: Allocating aligned memory: %d: %s\n",
- argv[0], error, strerror(error));
- return EXIT_FAILURE;
- }
-
- ssize_t total = 0;
- for (;;) {
- num_read = read(fd, buf, buf_size);
-
- if (num_read == -1 && errno == EINTR)
- continue;
-
- if (num_read == -1 && errno == EINVAL && total == 0) {
- /*
- * For some reason, O_DIRECT doesn't seem to work under 2.4
- * kernels anyway, at least not always. If so, it fails at
- * the first read, so we restart from the beginning, without
- * O_DIRECT.
- */
- (void) close(fd);
- goto open_without_o_direct;
- }
-
- if (num_read == -1) {
- fprintf(stderr, "%s: ERROR: Reading %s: %d: %s\n",
- argv[0], argv[1], errno, strerror(errno));
- return EXIT_FAILURE;
- }
-
- if (num_read == 0)
- break;
-
- total += num_read;
-
- do {
- num_written = write(1, buf, num_read);
- } while (num_written == -1 && errno == EINTR);
-
- if (num_written == -1) {
- fprintf(stderr, "%s: ERROR: Writing to stdout: %d: %s\n",
- argv[0], errno, strerror(errno));
- return EXIT_FAILURE;
- }
- }
-
- if (close(fd) == -1) {
- fprintf(stderr, "%s: ERROR: Closing %s: %d: %s\n",
- argv[0], argv[1], errno, strerror(errno));
- return EXIT_FAILURE;
- }
-
- return 0;
-}
diff --git a/odirect_read.docbook b/odirect_read.docbook
deleted file mode 100644
index 5687c53e..00000000
--- a/odirect_read.docbook
+++ /dev/null
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-
-Copyright 2006, 2007 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.,
-59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
--->
-
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN"
-"file:///usr/share/xml/docbook/schema/dtd/4.4/docbookx.dtd"
-[]>
-
-<refentry>
-
- <refentryinfo>
- <address>
- <email>liw@iki.fi</email>
- </address>
- <author>
- <firstname>Lars</firstname>
- <surname>Wirzenius</surname>
- </author>
- <date>2007-02-23</date>
- </refentryinfo>
-
- <refmeta>
- <refentrytitle>odirect_read</refentrytitle>
- <manvolnum>1</manvolnum>
- </refmeta>
-
- <refnamediv>
- <refname>odirect_read</refname>
- <refpurpose>copy file to standard output without touching cache</refpurpose>
- </refnamediv>
-
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>odirect_read</command>
- <arg><replaceable>filename</replaceable></arg>
- </cmdsynopsis>
- </refsynopsisdiv>
-
- <refsect1>
- <title>DESCRIPTION</title>
-
- <para><command>odirect_read</command> reads the (single) file named
- on the command line and writes the contents to the standard output.
- It reads the file using O_DIRECT so that reading it doesn't touch
- the disk buffer cache.</para>
-
- <para><command>odirect_read</command> is used by the
- <command>obnam</command> backup tool.</para>
-
- </refsect1>
-
- <refsect1>
- <title>BUGS</title>
-
- <para>Avoiding the cache might not work under Linux 2.4 kernels.</para>
-
- </refsect1>
-
-</refentry>
diff --git a/showblock b/showblock
index b743868e..78f92978 100755
--- a/showblock
+++ b/showblock
@@ -22,7 +22,7 @@
import sys
-import obnam
+import obnamlib
def format_objmap(data):
@@ -34,25 +34,25 @@ def format_objmap(data):
def format_octal(data):
- return "0%o" % obnam.varint.decode(data, 0)[0]
+ return "0%o" % obnamlib.varint.decode(data, 0)[0]
def format_decimal(data):
- return "%d" % obnam.varint.decode(data, 0)[0]
+ return "%d" % obnamlib.varint.decode(data, 0)[0]
component_data_formatters = {
- obnam.cmp.OBJKIND:
+ obnamlib.cmp.OBJKIND:
lambda data: \
- obnam.obj.kind_name(obnam.varint.decode(data, 0)[0]),
- obnam.cmp.OBJMAP: format_objmap,
+ obnamlib.obj.kind_name(obnamlib.varint.decode(data, 0)[0]),
+ obnamlib.cmp.OBJMAP: format_objmap,
}
def show_component(component, indent=0):
x = " " * (indent * 2)
kind = component.get_kind()
- print x + "Component:", kind, obnam.cmp.kind_name(kind)
+ print x + "Component:", kind, obnamlib.cmp.kind_name(kind)
if component.is_composite():
for c in component.get_subcomponents():
show_component(c, indent+1)
@@ -67,7 +67,7 @@ def show_block(filename):
str = f.read()
f.close()
pos = 0
- for c in obnam.obj.block_decode(str):
+ for c in obnamlib.obj.block_decode(str):
show_component(c)
print
diff --git a/test_odirect_read b/test_odirect_read
deleted file mode 100755
index c878a418..00000000
--- a/test_odirect_read
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/bin/sh
-#
-# test_odirect_read -- run tests on odirect_read
-#
-# Copyright (C) 2006 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.
-
-
-die()
-{
- echo "$@" 1>&2
- echo "Exit code: $exit_code" 1>&2
- echo "Stderr contents:" 1>&2
- sed 's/.*/ &/' "$stderr_file" 1>&2
- exit 1
-}
-
-run()
-{
- "$@" 2>"$stderr_file"
- exit_code=$?
-}
-
-require_exit_code()
-{
- if [ "$exit_code" != $1 ]
- then
- die "Program did not exit with code $1"
- fi
-}
-
-require_stderr_match()
-{
- if ! grep "$1" "$stderr_file" > /dev/null
- then
- die "Stderr does not match '$1'"
- fi
-}
-
-stderr_file=$(mktemp)
-
-# Check no arguments
-run ./odirect_read
-require_exit_code 1
-require_stderr_match "exactly one argument"
-
-# Check too many arguments
-run ./odirect_read foo bar
-require_exit_code 1
-require_stderr_match "exactly one argument"
-
-# Check non-existing file
-run ./odirect_read nonexisting
-require_exit_code 1
-require_stderr_match "Trying to open"
-
-# Check writing problems
-run ./odirect_read README > /dev/full
-require_exit_code 1
-require_stderr_match "Writing to stdout"
-
-# Check existing normal file, this should succeed
-run ./odirect_read README > /dev/null
-require_exit_code 0
-
-# Cleanup
-rm -f "$stderr_file"