Browse Source

merged master

Thomas Waldmann 10 năm trước cách đây
mục cha
commit
f9d90482c4
8 tập tin đã thay đổi với 20 bổ sung5 xóa
  1. 2 0
      CHANGES
  2. 6 0
      attic/archive.py
  3. 2 0
      attic/archiver.py
  4. 1 1
      attic/cache.py
  5. 4 3
      attic/testsuite/archiver.py
  6. 1 0
      docs/global.rst.inc
  7. 1 1
      docs/index.rst
  8. 3 0
      docs/installation.rst

+ 2 - 0
CHANGES

@@ -7,6 +7,8 @@ Version 0.16
 ------------
 
 (bugfix release, released on X)
+- Fix typo preventing the security confirmation prompt from working (#303)
+- Improve handling of systems with improperly configured file system encoding (#289)
 - Fix "All archives" output for attic info. (#183)
 - More user friendly error message when repository key file is not found (#236)
 - Fix parsing of iso 8601 timestamps with zero microseconds (#282)

+ 6 - 0
attic/archive.py

@@ -122,6 +122,10 @@ class Archive:
     class AlreadyExists(Error):
         """Archive {} already exists"""
 
+    class IncompatibleFilesystemEncodingError(Error):
+        """Failed to encode filename "{}" into file system encoding "{}". Consider configuring the LANG environment variable."""
+
+
     def __init__(self, repository, key, manifest, name, cache=None, create=False,
                  checkpoint_interval=300, numeric_owner=False, progress=False):
         self.cwd = os.getcwd()
@@ -264,6 +268,8 @@ class Archive:
                 os.rmdir(path)
             else:
                 os.unlink(path)
+        except UnicodeEncodeError:
+            raise self.IncompatibleFilesystemEncodingError(path, sys.getfilesystemencoding())
         except OSError:
             pass
         mode = item[b'mode']

+ 2 - 0
attic/archiver.py

@@ -213,6 +213,8 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
     def do_extract(self, args):
         """Extract archive contents"""
         # be restrictive when restoring files, restore permissions later
+        if sys.getfilesystemencoding() == 'ascii':
+            print('Warning: File system encoding is "ascii", extracting non-ascii filenames will not be supported.')
         os.umask(0o077)
         repository = self.open_repository(args.archive)
         manifest, key = Manifest.load(repository)

+ 1 - 1
attic/cache.py

@@ -71,7 +71,7 @@ class Cache:
         if env_var_override and os.environ.get(env_var_override):
             print("Yes (From {})".format(env_var_override))
             return True
-        if sys.stdin.isatty():
+        if not sys.stdin.isatty():
             return False
         try:
             answer = input('Do you want to continue? [yN] ')

+ 4 - 3
attic/testsuite/archiver.py

@@ -106,18 +106,19 @@ class ArchiverTestCaseBase(AtticTestCase):
             self.assert_equal(exit_code, ret)
             return output
         args = list(args)
-        stdout, stderr = sys.stdout, sys.stderr
+        stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr
         try:
+            sys.stdin = StringIO()
             output = StringIO()
             sys.stdout = sys.stderr = output
             ret = self.archiver.run(args)
-            sys.stdout, sys.stderr = stdout, stderr
+            sys.stdin, sys.stdout, sys.stderr = stdin, stdout, stderr
             if ret != exit_code:
                 print(output.getvalue())
             self.assert_equal(exit_code, ret)
             return output.getvalue()
         finally:
-            sys.stdout, sys.stderr = stdout, stderr
+            sys.stdin, sys.stdout, sys.stderr = stdin, stdout, stderr
 
     def create_src_archive(self, name):
         self.attic('create', self.repository_location + '::' + name, src_dir)

+ 1 - 0
docs/global.rst.inc

@@ -27,4 +27,5 @@
 .. _Arch Linux: https://aur.archlinux.org/packages/attic/
 .. _Slackware: http://slackbuilds.org/result/?search=Attic
 .. _Cython: http://cython.org/
+.. _virtualenv: https://pypi.python.org/pypi/virtualenv/
 .. _mailing list discussion about internals: http://librelist.com/browser/attic/2014/5/6/questions-and-suggestions-about-inner-working-of-attic>

+ 1 - 1
docs/index.rst

@@ -32,7 +32,7 @@ Easy installation
 -----------------
 You can use pip to install |project_name| quickly and easily::
 
-    $ pip install attic
+    $ pip3 install attic
 
 |project_name| is also part of the Debian_, Ubuntu_, `Arch Linux`_ and Slackware_
 distributions of GNU/Linux.

+ 3 - 0
docs/installation.rst

@@ -20,6 +20,9 @@ Newer versions are available from homebrew_ on OS X and from FreeBSD ports.
 The llfuse_ python package is also required if you wish to mount an
 archive as a FUSE filesystem.
 
+Virtualenv_ can be used to build and install |project_name|
+without affecting the system Python or requiring root access.
+
 Common compilation pre-requisites
 ---------------------------------