Give extraction stderr more context, and suppress normal cpio stderr junk. trunk

Tue, 15 Jul 2008 22:18:03 -0400

author
Brett Smith <brettcsmith@brettcsmith.org>
date
Tue, 15 Jul 2008 22:18:03 -0400
branch
trunk
changeset 76
705642fcb92c
parent 75
856de7e8f494
child 77
3a1f49be7667

Give extraction stderr more context, and suppress normal cpio stderr junk.

cpio will write a useless "N blocks" message to stderr without --quiet, so
use that.

When we show extraction's stderr to the user, first write a line explaining
what it is, and also don't forget to strip the trailing newline, since
.warning() writes its own.

scripts/dtrx file | annotate | diff | comparison | revisions
tests/tests.yml file | annotate | diff | comparison | revisions
--- a/scripts/dtrx	Sun Jul 13 18:11:08 2008 -0400
+++ b/scripts/dtrx	Tue Jul 15 22:18:03 2008 -0400
@@ -130,8 +130,8 @@
 class BaseExtractor(object):
     decoders = {'bzip2': 'bzcat', 'gzip': 'zcat', 'compress': 'zcat',
                 'lzma': 'lzcat'}
-
     name_checker = DirectoryChecker
+    warning_header = "The extraction process output the following errors:\n"
 
     def __init__(self, filename, encoding):
         if encoding and (not self.decoders.has_key(encoding)):
@@ -247,7 +247,8 @@
         self.stderr.seek(0, 0)
         if self.stderr.read(1):
             self.stderr.seek(0, 0)
-            logger.warning(self.stderr.read(-1))
+            logger.warning(self.warning_header +
+                           self.stderr.read(-1).rstrip('\n'))
         self.stderr.close()
         error_index = self.first_bad_exit_code()
         if (not got_output) and (error_index is not None):
@@ -338,7 +339,7 @@
         return BaseExtractor.get_filenames(self)
 
     def extract_archive(self):
-        self.pipe(['cpio', '-i', '--make-directories',
+        self.pipe(['cpio', '-i', '--make-directories', '--quiet',
                    '--no-absolute-filenames'])
         self.run_pipes()
 
--- a/tests/tests.yml	Sun Jul 13 18:11:08 2008 -0400
+++ b/tests/tests.yml	Tue Jul 15 22:18:03 2008 -0400
@@ -46,6 +46,12 @@
   baseline: |
     lzcat $1 | tar -x
 
+- name: basic .cpio
+  filenames: test-1.23.cpio
+  baseline: |
+    cpio -i --make-directories <$1
+  antigrep: blocks?
+
 - name: .deb metadata
   filenames: test-1.23_all.deb
   options: --metadata

mercurial