From 64e8ea72ac26f1c0fdbae8cf652b78e23564fbbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Tue, 21 Apr 2015 22:29:10 +0200 Subject: [PATCH 1/3] Improve handling of systems with improperly configured file system encoding Closes #289 --- CHANGES | 1 + attic/archive.py | 6 ++++++ attic/archiver.py | 2 ++ 3 files changed, 9 insertions(+) diff --git a/CHANGES b/CHANGES index f703b9b12..5828de634 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,7 @@ Version 0.16 ------------ (bugfix release, released on X) +- 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) diff --git a/attic/archive.py b/attic/archive.py index 1b3818bc8..6778bed13 100644 --- a/attic/archive.py +++ b/attic/archive.py @@ -119,6 +119,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): self.cwd = os.getcwd() @@ -247,6 +251,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'] diff --git a/attic/archiver.py b/attic/archiver.py index 7295ac06e..5731ffb4c 100644 --- a/attic/archiver.py +++ b/attic/archiver.py @@ -188,6 +188,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) From c79b5357f896c175ca84e9275407ba46c3864515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Mon, 27 Apr 2015 22:35:06 +0200 Subject: [PATCH 2/3] Improve installatoin instructions. Specifically refer to pip3 instead of pip to avoid potential confusion. Also mention virtualenv --- docs/global.rst.inc | 1 + docs/index.rst | 2 +- docs/installation.rst | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/global.rst.inc b/docs/global.rst.inc index 694f4d967..e4c57e473 100644 --- a/docs/global.rst.inc +++ b/docs/global.rst.inc @@ -23,3 +23,4 @@ .. _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/ diff --git a/docs/index.rst b/docs/index.rst index 3d9f11986..0ba967866 100644 --- a/docs/index.rst +++ b/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. diff --git a/docs/installation.rst b/docs/installation.rst index 44e31e4ec..4f1d7a384 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -19,11 +19,14 @@ 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. + Installing from PyPI using pip ------------------------------ :: - $ pip install Attic + $ pip3 install Attic Installing from source tarballs ------------------------------- From a24d0f4cba4f9d0e5a9bc9f87b490f73502e48d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Fri, 8 May 2015 17:41:50 +0200 Subject: [PATCH 3/3] Fix typo preventing the security confirmation prompt from working Closes #303 --- CHANGES | 1 + attic/cache.py | 2 +- attic/testsuite/archiver.py | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 5828de634..7b312a69a 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,7 @@ 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) diff --git a/attic/cache.py b/attic/cache.py index 95017b61b..8a38d0f9a 100644 --- a/attic/cache.py +++ b/attic/cache.py @@ -68,7 +68,7 @@ class Cache(object): 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] ') diff --git a/attic/testsuite/archiver.py b/attic/testsuite/archiver.py index c115b460f..372a1e052 100644 --- a/attic/testsuite/archiver.py +++ b/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)