zturner created this revision.
zturner added a reviewer: tfiala.
zturner added a subscriber: lldb-commits.

The purpose of this file is to fill in the gaps where `six` is lacking support 
for some operation that we need.

Initially this just provides a replacement for the `commands` module which is 
no longer present in Python 3.


http://reviews.llvm.org/D14162

Files:
  packages/Python/lldbsuite/support/__init__.py
  packages/Python/lldbsuite/support/seven.py

Index: packages/Python/lldbsuite/support/seven.py
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/support/seven.py
@@ -0,0 +1,17 @@
+import six
+
+if six.PY2:
+    import commands
+    get_command_output = commands.getoutput
+    get_command_status_output = commands.getstatusoutput
+
+else:
+    def get_command_status_output(command):
+        try:
+            import subprocess
+            return (0, subprocess.check_output(command, shell=True))
+        except subprocess.CalledProcessError as e:
+            return (e.returncode, e.output)
+
+    def get_command_output(command):
+        return get_command_status_output(command)[1]


Index: packages/Python/lldbsuite/support/seven.py
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/support/seven.py
@@ -0,0 +1,17 @@
+import six
+
+if six.PY2:
+    import commands
+    get_command_output = commands.getoutput
+    get_command_status_output = commands.getstatusoutput
+
+else:
+    def get_command_status_output(command):
+        try:
+            import subprocess
+            return (0, subprocess.check_output(command, shell=True))
+        except subprocess.CalledProcessError as e:
+            return (e.returncode, e.output)
+
+    def get_command_output(command):
+        return get_command_status_output(command)[1]
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to