[Bf-blender-cvs] [9b96dd0f615] master: icon update: replace os.system w/ subprocess.check_call

Campbell Barton noreply at git.blender.org
Fri Jan 26 02:48:24 CET 2018


Commit: 9b96dd0f6157fabf0f267ece54fa604094ba303c
Author: Campbell Barton
Date:   Fri Jan 26 12:46:10 2018 +1100
Branches: master
https://developer.blender.org/rB9b96dd0f6157fabf0f267ece54fa604094ba303c

icon update: replace os.system w/ subprocess.check_call

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

M	release/datafiles/blender_icons_update.py
M	release/datafiles/prvicons_update.py

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

diff --git a/release/datafiles/blender_icons_update.py b/release/datafiles/blender_icons_update.py
index d342df0a6f9..664915cc10b 100755
--- a/release/datafiles/blender_icons_update.py
+++ b/release/datafiles/blender_icons_update.py
@@ -2,13 +2,14 @@
 
 # This script updates icons from the SVG file
 import os
+import subprocess
 import sys
 
 def run(cmd):
-    print("   ", cmd)
-    os.system(cmd)
+    print("   ", " ".join(cmd))
+    subprocess.check_call(cmd)
 
-BASEDIR = os.path.abspath(os.path.dirname(__file__)) + os.sep
+BASEDIR = os.path.abspath(os.path.dirname(__file__))
 
 inkscape_bin = "inkscape"
 blender_bin = "blender"
@@ -18,9 +19,24 @@ if sys.platform == 'darwin':
     if os.path.exists(inkscape_app_path):
         inkscape_bin = inkscape_app_path
 
-cmd = inkscape_bin + ' "%sblender_icons.svg" --export-width=602 --export-height=640 --without-gui --export-png="%sblender_icons16.png"' % (BASEDIR, BASEDIR)
+cmd = (
+    inkscape_bin,
+    os.path.join(BASEDIR, "blender_icons.svg"),
+    "--export-width=602",
+    "--export-height=640",
+    "--without-gui",
+    "--export-png=" + os.path.join(BASEDIR, "blender_icons16.png"),
+)
 run(cmd)
-cmd = inkscape_bin + ' "%sblender_icons.svg" --export-width=1204 --export-height=1280 --without-gui --export-png="%sblender_icons32.png"' % (BASEDIR, BASEDIR)
+
+cmd = (
+    inkscape_bin,
+    os.path.join(BASEDIR, "blender_icons.svg"),
+    "--export-width=1204",
+    "--export-height=1280",
+    "--without-gui",
+    "--export-png=" + os.path.join(BASEDIR, "blender_icons32.png"),
+)
 run(cmd)
 
 
@@ -32,40 +48,36 @@ datatoc_icon_split_py = os.path.join(BASEDIR, "..", "..", "source", "blender", "
 
 # create .dat pixmaps (which are stored in git)
 cmd = (
-    blender_bin + " "
-    "--background -noaudio "
-    "--python " + datatoc_icon_split_py + " -- "
-    "--image=" + BASEDIR + "blender_icons16.png "
-    "--output=" + BASEDIR + "blender_icons16 "
-    "--output_prefix=icon16_ "
-    "--name_style=UI_ICONS "
-    "--parts_x 26 --parts_y 30 "
-    "--minx 3 --maxx 53 --miny 3 --maxy 8 "
-    "--minx_icon 2 --maxx_icon 2 --miny_icon 2 --maxy_icon 2 "
-    "--spacex_icon 1 --spacey_icon 1"
-    )
+    blender_bin, "--background", "-noaudio",
+    "--python", datatoc_icon_split_py, "--",
+    "--image=" + os.path.join(BASEDIR, "blender_icons16.png"),
+    "--output=" + os.path.join(BASEDIR, "blender_icons16"),
+    "--output_prefix=icon16_",
+    "--name_style=UI_ICONS",
+    "--parts_x", "26", "--parts_y", "30",
+    "--minx", "3", "--maxx", "53", "--miny", "3", "--maxy", "8",
+    "--minx_icon", "2", "--maxx_icon", "2", "--miny_icon", "2", "--maxy_icon", "2",
+    "--spacex_icon", "1", "--spacey_icon", "1",
+)
 run(cmd)
 
 cmd = (
-    blender_bin + " "
-    "--background -noaudio "
-    "--python " + datatoc_icon_split_py + " -- "
-    "--image=" + BASEDIR + "blender_icons32.png "
-    "--output=" + BASEDIR + "blender_icons32 "
-    "--output_prefix=icon32_ "
-    "--name_style=UI_ICONS "
-    "--parts_x 26 --parts_y 30 "
-    "--minx 6 --maxx 106 --miny 6 --maxy 16 "
-    "--minx_icon 4 --maxx_icon 4 --miny_icon 4 --maxy_icon 4 "
-    "--spacex_icon 2 --spacey_icon 2"
-
-    )
+    blender_bin, "--background", "-noaudio",
+    "--python", datatoc_icon_split_py, "--",
+    "--image=" + os.path.join(BASEDIR, "blender_icons32.png"),
+    "--output=" + os.path.join(BASEDIR, "blender_icons32"),
+    "--output_prefix=icon32_",
+    "--name_style=UI_ICONS",
+    "--parts_x", "26", "--parts_y", "30",
+    "--minx", "6", "--maxx", "106", "--miny", "6", "--maxy", "16",
+    "--minx_icon", "4", "--maxx_icon", "4", "--miny_icon", "4", "--maxy_icon", "4",
+    "--spacex_icon", "2", "--spacey_icon", "2",
+)
 run(cmd)
 
-os.remove(BASEDIR + "blender_icons16.png")
-os.remove(BASEDIR + "blender_icons32.png")
+os.remove(os.path.join(BASEDIR, "blender_icons16.png"))
+os.remove(os.path.join(BASEDIR, "blender_icons32.png"))
 
 # For testing, if we want the PNG of each image
 # ./datatoc_icon_split_to_png.py ./blender_icons16/*.dat
 # ./datatoc_icon_split_to_png.py ./blender_icons32/*.dat
-
diff --git a/release/datafiles/prvicons_update.py b/release/datafiles/prvicons_update.py
index 448a43df9ce..bc170b98545 100755
--- a/release/datafiles/prvicons_update.py
+++ b/release/datafiles/prvicons_update.py
@@ -2,9 +2,10 @@
 
 # This script updates icons from the SVG file
 import os
+import subprocess
 import sys
 
-BASEDIR = os.path.abspath(os.path.dirname(__file__)) + os.sep
+BASEDIR = os.path.abspath(os.path.dirname(__file__))
 
 inkscape_path = 'inkscape'
 
@@ -13,5 +14,10 @@ if sys.platform == 'darwin':
     if os.path.exists(inkscape_app_path):
         inkscape_path = inkscape_app_path
 
-cmd = inkscape_path + ' "%sprvicons.svg" --without-gui --export-png="%sprvicons.png"' % (BASEDIR, BASEDIR)
-os.system(cmd)
+cmd = (
+    inkscape_path,
+    os.path.join(BASEDIR, "prvicons.svg"),
+    "--without-gui",
+    "--export-png=" + os.path.join(BASEDIR, "prvicons.png"),
+)
+subprocess.check_call(cmd)



More information about the Bf-blender-cvs mailing list