[Lldb-commits] [PATCH] D14162: Create Python library `seven` in lldbsuite.support

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 28 15:23:25 PDT 2015


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]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14162.38692.patch
Type: text/x-patch
Size: 724 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151028/da1ebd90/attachment.bin>


More information about the lldb-commits mailing list