Author: serge_sans_paille Date: Tue Mar 26 07:46:15 2019 New Revision: 356995
URL: http://llvm.org/viewvc/llvm-project?rev=356995&view=rev Log: python 2/3 compat: commands vs subprocess Differential Revision: https://reviews.llvm.org/D59584 Modified: lldb/trunk/examples/python/delta.py lldb/trunk/examples/python/gdbremote.py lldb/trunk/examples/python/globals.py lldb/trunk/examples/python/memory.py lldb/trunk/examples/python/performance.py lldb/trunk/examples/python/process_events.py lldb/trunk/examples/python/stacks.py lldb/trunk/examples/python/types.py lldb/trunk/scripts/verify_api.py Modified: lldb/trunk/examples/python/delta.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/delta.py?rev=356995&r1=356994&r2=356995&view=diff ============================================================================== --- lldb/trunk/examples/python/delta.py (original) +++ lldb/trunk/examples/python/delta.py Tue Mar 26 07:46:15 2019 @@ -16,7 +16,6 @@ # available. #---------------------------------------------------------------------- -import commands from __future__ import print_function import optparse Modified: lldb/trunk/examples/python/gdbremote.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/gdbremote.py?rev=356995&r1=356994&r2=356995&view=diff ============================================================================== --- lldb/trunk/examples/python/gdbremote.py (original) +++ lldb/trunk/examples/python/gdbremote.py Tue Mar 26 07:46:15 2019 @@ -17,7 +17,7 @@ #---------------------------------------------------------------------- import binascii -import commands +import subprocess import json import math import optparse Modified: lldb/trunk/examples/python/globals.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/globals.py?rev=356995&r1=356994&r2=356995&view=diff ============================================================================== --- lldb/trunk/examples/python/globals.py (original) +++ lldb/trunk/examples/python/globals.py Tue Mar 26 07:46:15 2019 @@ -10,7 +10,6 @@ from __future__ import print_function import lldb -import commands import optparse import os import shlex Modified: lldb/trunk/examples/python/memory.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/memory.py?rev=356995&r1=356994&r2=356995&view=diff ============================================================================== --- lldb/trunk/examples/python/memory.py (original) +++ lldb/trunk/examples/python/memory.py Tue Mar 26 07:46:15 2019 @@ -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 Modified: lldb/trunk/examples/python/performance.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/performance.py?rev=356995&r1=356994&r2=356995&view=diff ============================================================================== --- lldb/trunk/examples/python/performance.py (original) +++ lldb/trunk/examples/python/performance.py Tue Mar 26 07:46:15 2019 @@ -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 Modified: lldb/trunk/examples/python/process_events.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/process_events.py?rev=356995&r1=356994&r2=356995&view=diff ============================================================================== --- lldb/trunk/examples/python/process_events.py (original) +++ lldb/trunk/examples/python/process_events.py Tue Mar 26 07:46:15 2019 @@ -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( Modified: lldb/trunk/examples/python/stacks.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/stacks.py?rev=356995&r1=356994&r2=356995&view=diff ============================================================================== --- lldb/trunk/examples/python/stacks.py (original) +++ lldb/trunk/examples/python/stacks.py Tue Mar 26 07:46:15 2019 @@ -1,7 +1,6 @@ #!/usr/bin/python from __future__ import print_function import lldb -import commands import optparse import shlex Modified: lldb/trunk/examples/python/types.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/types.py?rev=356995&r1=356994&r2=356995&view=diff ============================================================================== --- lldb/trunk/examples/python/types.py (original) +++ lldb/trunk/examples/python/types.py Tue Mar 26 07:46:15 2019 @@ -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 Modified: lldb/trunk/scripts/verify_api.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/verify_api.py?rev=356995&r1=356994&r2=356995&view=diff ============================================================================== --- lldb/trunk/scripts/verify_api.py (original) +++ lldb/trunk/scripts/verify_api.py Tue Mar 26 07:46:15 2019 @@ -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") _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits