python 2/3 compat: commands vs subprocess

Differential Revision: https://reviews.llvm.org/D59584

llvm-svn: 356995
This commit is contained in:
Serge Guelton 2019-03-26 14:46:15 +00:00
parent 25f9094d89
commit 1a12dd70c0
9 changed files with 28 additions and 17 deletions

View File

@ -16,7 +16,6 @@
# available.
#----------------------------------------------------------------------
import commands
from __future__ import print_function
import optparse

View File

@ -17,7 +17,7 @@
#----------------------------------------------------------------------
import binascii
import commands
import subprocess
import json
import math
import optparse

View File

@ -10,7 +10,6 @@
from __future__ import print_function
import lldb
import commands
import optparse
import os
import shlex

View File

@ -9,7 +9,6 @@
# (lldb) command script import /path/to/cmdtemplate.py
#----------------------------------------------------------------------
import commands
from __future__ import print_function
import platform
@ -17,6 +16,11 @@ import os
import re
import sys
if sys.version_info.major == 2:
import commands as subprocess
else:
import subprocess
try:
# Just try for LLDB in case PYTHONPATH is already correctly setup
import lldb
@ -26,7 +30,7 @@ except ImportError:
platform_system = platform.system()
if platform_system == 'Darwin':
# On Darwin, try the currently selected Xcode directory
xcode_dir = commands.getoutput("xcode-select --print-path")
xcode_dir = subprocess.getoutput("xcode-select --print-path")
if xcode_dir:
lldb_python_dirs.append(
os.path.realpath(
@ -53,7 +57,6 @@ except ImportError:
print("error: couldn't locate the 'lldb' module, please set PYTHONPATH correctly")
sys.exit(1)
import commands
import optparse
import shlex
import string

View File

@ -8,7 +8,6 @@
# export PYTHONPATH=/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python
#----------------------------------------------------------------------
import commands
from __future__ import print_function
import optparse
@ -20,6 +19,11 @@ import sys
import time
import types
if sys.version_info.major == 2:
import commands as subprocess
else:
import subprocess
#----------------------------------------------------------------------
# Code that auto imports LLDB
#----------------------------------------------------------------------
@ -32,7 +36,7 @@ except ImportError:
platform_system = platform.system()
if platform_system == 'Darwin':
# On Darwin, try the currently selected Xcode directory
xcode_dir = commands.getoutput("xcode-select --print-path")
xcode_dir = subprocess.getoutput("xcode-select --print-path")
if xcode_dir:
lldb_python_dirs.append(
os.path.realpath(
@ -303,7 +307,7 @@ class MemoryMeasurement(Measurement):
self.value = dict()
def Measure(self):
output = commands.getoutput(self.command).split("\n")[-1]
output = subprocess.getoutput(self.command).split("\n")[-1]
values = re.split('[-+\s]+', output)
for (idx, stat) in enumerate(values):
multiplier = 1

View File

@ -8,7 +8,6 @@
# export PYTHONPATH=/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python
#----------------------------------------------------------------------
import commands
from __future__ import print_function
import optparse
@ -16,6 +15,11 @@ import os
import platform
import sys
if sys.version_info.major == 2:
import commands as subprocess
else:
import subprocess
#----------------------------------------------------------------------
# Code that auto imports LLDB
#----------------------------------------------------------------------
@ -28,7 +32,7 @@ except ImportError:
platform_system = platform.system()
if platform_system == 'Darwin':
# On Darwin, try the currently selected Xcode directory
xcode_dir = commands.getoutput("xcode-select --print-path")
xcode_dir = subprocess.getoutput("xcode-select --print-path")
if xcode_dir:
lldb_python_dirs.append(
os.path.realpath(

View File

@ -1,7 +1,6 @@
#!/usr/bin/python
from __future__ import print_function
import lldb
import commands
import optparse
import shlex

View File

@ -9,7 +9,6 @@
# (lldb) command script import /path/to/cmdtemplate.py
#----------------------------------------------------------------------
import commands
from __future__ import print_function
import platform
@ -18,6 +17,11 @@ import re
import signal
import sys
if sys.version_info.major == 2:
import commands as subprocess
else:
import subprocess
try:
# Just try for LLDB in case PYTHONPATH is already correctly setup
import lldb
@ -27,7 +31,7 @@ except ImportError:
platform_system = platform.system()
if platform_system == 'Darwin':
# On Darwin, try the currently selected Xcode directory
xcode_dir = commands.getoutput("xcode-select --print-path")
xcode_dir = subprocess.getoutput("xcode-select --print-path")
if xcode_dir:
lldb_python_dirs.append(
os.path.realpath(
@ -54,7 +58,6 @@ except ImportError:
print("error: couldn't locate the 'lldb' module, please set PYTHONPATH correctly")
sys.exit(1)
import commands
import optparse
import shlex
import time

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
import commands
import subprocess
import optparse
import os
import os.path
@ -11,7 +11,7 @@ import sys
def extract_exe_symbol_names(arch, exe_path, match_str):
command = 'dsymutil --arch %s -s "%s" | grep "%s" | colrm 1 69' % (
arch, exe_path, match_str)
(command_exit_status, command_output) = commands.getstatusoutput(command)
(command_exit_status, command_output) = subprocess.getstatusoutput(command)
if command_exit_status == 0:
if command_output:
return command_output[0:-1].split("'\n")