[Bf-blender-cvs] [803d156] master: Minor edits to sys-info

Campbell Barton noreply at git.blender.org
Fri Sep 18 12:03:44 CEST 2015


Commit: 803d1563ec0ad72b06449cb091121ba35436c758
Author: Campbell Barton
Date:   Tue Sep 15 02:39:40 2015 +1000
Branches: master
https://developer.blender.org/rB803d1563ec0ad72b06449cb091121ba35436c758

Minor edits to sys-info

- remove byte b''
- remove always false check for missing buildinfo.
- use textwrap module

===================================================================

M	release/scripts/modules/sys_info.py

===================================================================

diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py
index f402d3f..8ca3014 100644
--- a/release/scripts/modules/sys_info.py
+++ b/release/scripts/modules/sys_info.py
@@ -26,29 +26,9 @@ import bgl
 import sys
 
 
-def cutPoint(text, length):
-    """Returns position of the last space found before 'length' chars"""
-    l = length
-    c = text[l]
-    while c != ' ':
-        l -= 1
-        if l == 0:
-            return length  # no space found
-        c = text[l]
-    return l
-
-
-def textWrap(text, length=70):
-    lines = []
-    while len(text) > 70:
-        cpt = cutPoint(text, length)
-        line, text = text[:cpt], text[cpt + 1:]
-        lines.append(line)
-    lines.append(text)
-    return lines
-
-
 def write_sysinfo(op):
+    import textwrap
+
     output_filename = "system-info.txt"
 
     output = bpy.data.texts.get(output_filename)
@@ -57,6 +37,17 @@ def write_sysinfo(op):
     else:
         output = bpy.data.texts.new(name=output_filename)
 
+    # pretty repr
+    def prepr(v):
+        r = repr(v)
+        vt = type(v)
+        if vt is bytes:
+            r = r[2:-1]
+        elif vt is list or vt is tuple:
+            r = r[1:-1]
+        return r
+
+
     header = "= Blender %s System Information =\n" % bpy.app.version_string
     lilies = "%s\n\n" % (len(header) * "=")
     firstlilies = "%s\n" % (len(header) * "=")
@@ -67,27 +58,22 @@ def write_sysinfo(op):
     # build info
     output.write("\nBlender:\n")
     output.write(lilies)
-    if bpy.app.build_branch and bpy.app.build_branch != "Unknown":
-        output.write("version %s, branch %r, commit date %r %r, hash %r, %r\n" %
-            (bpy.app.version_string,
-             bpy.app.build_branch,
-             bpy.app.build_commit_date,
-             bpy.app.build_commit_time,
-             bpy.app.build_hash,
-             bpy.app.build_type))
-    else:
-        output.write("version %s, revision %r. %r\n" %
-            (bpy.app.version_string,
-             bpy.app.build_change,
-             bpy.app.build_type))
-
-    output.write("build date: %r, %r\n" % (bpy.app.build_date, bpy.app.build_time))
-    output.write("platform: %r\n" % (bpy.app.build_platform))
-    output.write("binary path: %r\n" % (bpy.app.binary_path))
-    output.write("build cflags: %r\n" % (bpy.app.build_cflags))
-    output.write("build cxxflags: %r\n" % (bpy.app.build_cxxflags))
-    output.write("build linkflags: %r\n" % (bpy.app.build_linkflags))
-    output.write("build system: %r\n" % (bpy.app.build_system))
+    output.write("version: %s, branch: %s, commit date: %s %s, hash: %s, type: %s\n" %
+        (bpy.app.version_string,
+         prepr(bpy.app.build_branch),
+         prepr(bpy.app.build_commit_date),
+         prepr(bpy.app.build_commit_time),
+         prepr(bpy.app.build_hash),
+         prepr(bpy.app.build_type),
+         ))
+
+    output.write("build date: %s, %s\n" % (prepr(bpy.app.build_date), prepr(bpy.app.build_time)))
+    output.write("platform: %s\n" % prepr(bpy.app.build_platform))
+    output.write("binary path: %s\n" % prepr(bpy.app.binary_path))
+    output.write("build cflags: %s\n" % prepr(bpy.app.build_cflags))
+    output.write("build cxxflags: %s\n" % prepr(bpy.app.build_cxxflags))
+    output.write("build linkflags: %s\n" % prepr(bpy.app.build_linkflags))
+    output.write("build system: %s\n" % prepr(bpy.app.build_system))
 
     # python info
     output.write("\nPython:\n")
@@ -175,9 +161,9 @@ def write_sysinfo(op):
         output.write("extensions:\n")
 
         glext = bgl.glGetString(bgl.GL_EXTENSIONS)
-        glext = textWrap(glext, 70)
+        glext = textwrap.wrap(glext, 70)
         for l in glext:
-            output.write("\t\t%r\n" % (l))
+            output.write("\t%s\n" % l)
 
         output.write("\nImplementation Dependent OpenGL Limits:\n")
         output.write(lilies)




More information about the Bf-blender-cvs mailing list