Python: Remove deprecated uses of os.popen
T40415 by Lawrence D'Oliveiro
This commit is contained in:
@@ -285,8 +285,7 @@ if env['OURPLATFORM']=='darwin':
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
command = ["%s"%env['CC'], "--version"]
|
command = ["%s"%env['CC'], "--version"]
|
||||||
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=None, shell=False)
|
line = subprocess.check_output(command)
|
||||||
line = process.communicate()[0]
|
|
||||||
ver = re.search(r'[0-9]+(\.[0-9]+[svn]+)+', line) or re.search(r'[0-9]+(\.[0-9]+)+', line) # read the "based on LLVM x.xsvn" version here, not the Apple version
|
ver = re.search(r'[0-9]+(\.[0-9]+[svn]+)+', line) or re.search(r'[0-9]+(\.[0-9]+)+', line) # read the "based on LLVM x.xsvn" version here, not the Apple version
|
||||||
if ver:
|
if ver:
|
||||||
env['CCVERSION'] = ver.group(0).strip('svn')
|
env['CCVERSION'] = ver.group(0).strip('svn')
|
||||||
|
@@ -406,55 +406,58 @@ def buildinfo(lenv, build_type):
|
|||||||
"""
|
"""
|
||||||
Generate a buildinfo object
|
Generate a buildinfo object
|
||||||
"""
|
"""
|
||||||
|
import subprocess
|
||||||
|
|
||||||
build_date = time.strftime ("%Y-%m-%d")
|
build_date = time.strftime ("%Y-%m-%d")
|
||||||
build_time = time.strftime ("%H:%M:%S")
|
build_time = time.strftime ("%H:%M:%S")
|
||||||
|
|
||||||
if os.path.isdir(os.path.abspath('.git')):
|
if os.path.isdir(os.path.abspath('.git')):
|
||||||
build_commit_timestamp = os.popen('git log -1 --format=%ct').read().strip()
|
build_commit_timestamp = subprocess.check_output(args=['git', 'log', '-1', '--format=%ct']).strip()
|
||||||
if not build_commit_timestamp:
|
if not build_commit_timestamp:
|
||||||
# Git command not found
|
# Git command not found
|
||||||
build_hash = 'unknown'
|
build_hash = 'unknown'
|
||||||
build_commit_timestamp = '0'
|
build_commit_timestamp = '0'
|
||||||
build_branch = 'unknown'
|
build_branch = 'unknown'
|
||||||
else:
|
else:
|
||||||
import subprocess
|
|
||||||
no_upstream = False
|
no_upstream = False
|
||||||
|
|
||||||
process = subprocess.Popen(['git', 'rev-parse', '--short', '@{u}'],
|
try :
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
build_hash = subprocess.check_output(['git', 'rev-parse', '--short', '@{u}']).strip()
|
||||||
build_hash, stderr = process.communicate()
|
except subprocess.CalledProcessError:
|
||||||
build_hash = build_hash.strip()
|
# assume branch has no upstream configured
|
||||||
build_branch = os.popen('git rev-parse --abbrev-ref HEAD').read().strip()
|
build_hash = ''
|
||||||
|
|
||||||
|
build_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
|
||||||
|
|
||||||
if build_branch == 'HEAD':
|
if build_branch == 'HEAD':
|
||||||
master_check = os.popen('git branch --list master --contains ' + build_hash).read().strip()
|
master_check = subprocess.check_output(['git', 'branch', '--list', 'master', '--contains', build_hash]).strip()
|
||||||
if master_check == 'master':
|
if master_check == 'master':
|
||||||
build_branch = 'master'
|
build_branch = 'master'
|
||||||
else:
|
else:
|
||||||
head_hash = os.popen('git rev-parse HEAD').read().strip()
|
head_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip()
|
||||||
tag_hashes = os.popen('git show-ref --tags -d').read()
|
tag_hashes = subprocess.check_output(['git', 'show-ref', '--tags', '-d'])
|
||||||
if tag_hashes.find(head_hash) != -1:
|
if tag_hashes.find(head_hash) != -1:
|
||||||
build_branch = 'master'
|
build_branch = 'master'
|
||||||
|
|
||||||
if build_hash == '':
|
if build_hash == '':
|
||||||
build_hash = os.popen('git rev-parse --short HEAD').read().strip()
|
build_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip()
|
||||||
no_upstream = True
|
no_upstream = True
|
||||||
else:
|
else:
|
||||||
older_commits = os.popen('git log --oneline HEAD..@{u}').read().strip()
|
older_commits = subprocess.check_output(['git', 'log', '--oneline', 'HEAD..@{u}']).strip()
|
||||||
if older_commits:
|
if older_commits:
|
||||||
build_hash = os.popen('git rev-parse --short HEAD').read().strip()
|
build_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip()
|
||||||
|
|
||||||
# ## Check for local modifications
|
# ## Check for local modifications
|
||||||
has_local_changes = False
|
has_local_changes = False
|
||||||
|
|
||||||
# Update GIT index before getting dirty files
|
# Update GIT index before getting dirty files
|
||||||
os.system('git update-index -q --refresh')
|
os.system('git update-index -q --refresh')
|
||||||
changed_files = os.popen('git diff-index --name-only HEAD --').read().strip()
|
changed_files = subprocess.check_output(['git', 'diff-index', '--name-only', 'HEAD', '--']).strip()
|
||||||
|
|
||||||
if changed_files:
|
if changed_files:
|
||||||
has_local_changes = True
|
has_local_changes = True
|
||||||
elif no_upstream == False:
|
elif no_upstream == False:
|
||||||
unpushed_log = os.popen('git log --oneline @{u}..').read().strip()
|
unpushed_log = subprocess.check_output(['git', 'log', '--oneline', '@{u}..']).strip()
|
||||||
has_local_changes = unpushed_log != ''
|
has_local_changes = unpushed_log != ''
|
||||||
|
|
||||||
if build_branch.startswith('blender-v'):
|
if build_branch.startswith('blender-v'):
|
||||||
|
@@ -56,7 +56,7 @@ def get_version():
|
|||||||
raise Exception("%s: missing version string" % fname)
|
raise Exception("%s: missing version string" % fname)
|
||||||
|
|
||||||
def get_hash():
|
def get_hash():
|
||||||
build_hash = os.popen('git rev-parse --short HEAD').read().strip()
|
build_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip()
|
||||||
if build_hash == '' or build_hash == None:
|
if build_hash == '' or build_hash == None:
|
||||||
build_hash = 'UNKNOWN'
|
build_hash = 'UNKNOWN'
|
||||||
|
|
||||||
|
@@ -64,8 +64,7 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']:
|
|||||||
closure_dir = os.path.join(source_dir, "../closure")
|
closure_dir = os.path.join(source_dir, "../closure")
|
||||||
|
|
||||||
# get CUDA version
|
# get CUDA version
|
||||||
nvcc_pipe = subprocess.Popen([nvcc, "--version"],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
output = subprocess.check_output([nvcc, "--version"])
|
||||||
output, erroroutput = nvcc_pipe.communicate()
|
|
||||||
cuda_major_minor = re.findall(r'release (\d+).(\d+)', output)[0]
|
cuda_major_minor = re.findall(r'release (\d+).(\d+)', output)[0]
|
||||||
cuda_version = int(cuda_major_minor[0])*10 + int(cuda_major_minor[1])
|
cuda_version = int(cuda_major_minor[0])*10 + int(cuda_major_minor[1])
|
||||||
|
|
||||||
|
@@ -802,13 +802,14 @@ class WM_OT_path_open(Operator):
|
|||||||
if sys.platform[:3] == "win":
|
if sys.platform[:3] == "win":
|
||||||
os.startfile(filepath)
|
os.startfile(filepath)
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
subprocess.Popen(["open", filepath])
|
subprocess.check_call(["open", filepath])
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
subprocess.Popen(["xdg-open", filepath])
|
subprocess.check_call(["xdg-open", filepath])
|
||||||
except OSError:
|
except:
|
||||||
# xdg-open *should* be supported by recent Gnome, KDE, Xfce
|
# xdg-open *should* be supported by recent Gnome, KDE, Xfce
|
||||||
pass
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user