Переглянути джерело

remove platform.uname() call, fixes #3732

also: add exception handler around deprecated platform.linux_distribution() call.

(cherry picked from commit 1e94211bf5166cc68a8073aff62e61fb31117f10)
(cherry picked from commit 4f45eb660a469d7ab6d92a35ac83f41b34a5f8af)
Thomas Waldmann 7 роки тому
батько
коміт
30bd78f266
1 змінених файлів з 21 додано та 4 видалено
  1. 21 4
      src/borg/helpers/misc.py

+ 21 - 4
src/borg/helpers/misc.py

@@ -61,11 +61,28 @@ def prune_split(archives, rule, n, kept_because=None):
 
 
 def sysinfo():
-    info = []
-    info.append('Platform: %s' % (' '.join(platform.uname()), ))
+    python_implementation = platform.python_implementation()
+    python_version = platform.python_version()
+    # platform.uname() does a shell call internally to get processor info,
+    # creating #3732 issue, so rather use os.uname().
+    try:
+        uname = os.uname()
+    except AttributeError:
+        uname = None
     if sys.platform.startswith('linux'):
-        info.append('Linux: %s %s %s' % platform.linux_distribution())
-    info.append('Borg: %s  Python: %s %s' % (borg_version, platform.python_implementation(), platform.python_version()))
+        try:
+            linux_distribution = platform.linux_distribution()
+        except:
+            # platform.linux_distribution() is deprecated since py 3.5 and removed in 3.7.
+            linux_distribution = ('Unknown Linux', '', '')
+    else:
+        linux_distribution = None
+    info = []
+    if uname is not None:
+        info.append('Platform: %s' % (' '.join(uname), ))
+    if linux_distribution is not None:
+        info.append('Linux: %s %s %s' % linux_distribution)
+    info.append('Borg: %s  Python: %s %s' % (borg_version, python_implementation, python_version))
     info.append('PID: %d  CWD: %s' % (os.getpid(), os.getcwd()))
     info.append('sys.argv: %r' % sys.argv)
     info.append('SSH_ORIGINAL_COMMAND: %r' % os.environ.get('SSH_ORIGINAL_COMMAND'))