瀏覽代碼

Removed redundant is_a_terminal function and minor check fixes.

Jonas Borgström 11 年之前
父節點
當前提交
66fe7e5377
共有 3 個文件被更改,包括 4 次插入12 次删除
  1. 2 2
      attic/archiver.py
  2. 0 9
      attic/helpers.py
  3. 2 1
      attic/repository.py

+ 2 - 2
attic/archiver.py

@@ -14,7 +14,7 @@ from attic.key import key_creator
 from attic.helpers import Error, location_validator, format_time, \
 from attic.helpers import Error, location_validator, format_time, \
     format_file_mode, ExcludePattern, exclude_path, adjust_patterns, to_localtime, \
     format_file_mode, ExcludePattern, exclude_path, adjust_patterns, to_localtime, \
     get_cache_dir, get_keys_dir, format_timedelta, prune_within, prune_split, \
     get_cache_dir, get_keys_dir, format_timedelta, prune_within, prune_split, \
-    Manifest, remove_surrogates, is_a_terminal, update_excludes
+    Manifest, remove_surrogates, update_excludes
 from attic.remote import RepositoryServer, RemoteRepository
 from attic.remote import RepositoryServer, RemoteRepository
 
 
 
 
@@ -74,7 +74,7 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
                 if input('Do you want to continue? ') == 'Yes I am sure':
                 if input('Do you want to continue? ') == 'Yes I am sure':
                     break
                     break
         if args.progress is None:
         if args.progress is None:
-            args.progress = is_a_terminal(sys.stdout) or args.verbose
+            args.progress = sys.stdout.isatty() or args.verbose
         if not repository.check(progress=args.progress, repair=args.repair):
         if not repository.check(progress=args.progress, repair=args.repair):
             self.exit_code = 1
             self.exit_code = 1
         return self.exit_code
         return self.exit_code

+ 0 - 9
attic/helpers.py

@@ -468,15 +468,6 @@ def daemonize():
     os.dup2(fd, 2)
     os.dup2(fd, 2)
 
 
 
 
-def is_a_terminal(fd):
-    """Determine if `fd` is associated with a terminal or not
-    """
-    try:
-        os.ttyname(fd.fileno())
-        return True
-    except:
-        return False
-
 if sys.version < '3.3':
 if sys.version < '3.3':
     # st_mtime_ns attribute only available in 3.3+
     # st_mtime_ns attribute only available in 3.3+
     def st_mtime_ns(st):
     def st_mtime_ns(st):

+ 2 - 1
attic/repository.py

@@ -43,7 +43,7 @@ class Repository(object):
         """{} is not a valid repository"""
         """{} is not a valid repository"""
 
 
     class CheckNeeded(Error):
     class CheckNeeded(Error):
-        '''Inconsistency detected. Please "run attic check {}"'''
+        '''Inconsistency detected. Please run "attic check {}"'''
 
 
 
 
     def __init__(self, path, create=False):
     def __init__(self, path, create=False):
@@ -199,6 +199,7 @@ class Repository(object):
                 error_found = True
                 error_found = True
             if error or progress:
             if error or progress:
                 print(msg, file=sys.stderr)
                 print(msg, file=sys.stderr)
+                sys.stderr.flush()
 
 
         assert not self._active_txn
         assert not self._active_txn
         index_transaction_id = self.get_index_transaction_id()
         index_transaction_id = self.get_index_transaction_id()