diff options
author | Mike Day <ncmike@ncultra.org> | 2018-08-15 13:18:27 -0400 |
---|---|---|
committer | yonghong-song <ys114321@gmail.com> | 2018-08-15 10:18:27 -0700 |
commit | 49d475f1e50ff6bd16ed89a20cbf86a57685fa0c (patch) | |
tree | 291db22e3e1697d9a734c4716ffc8ee5b81a0108 /src | |
parent | ecfbc7493ffb90e0b062b5361df6753b4e19137a (diff) | |
download | bcc-49d475f1e50ff6bd16ed89a20cbf86a57685fa0c.tar.gz |
provide a parameter to suppress printing a new line at the end of the bytes (#1930)
provide a parameter to suppress printing a new line at the end of the bytes.
existing behavior is not changed.
Diffstat (limited to 'src')
-rw-r--r-- | src/python/bcc/utils.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/python/bcc/utils.py b/src/python/bcc/utils.py index 692614ec..ef6f81d8 100644 --- a/src/python/bcc/utils.py +++ b/src/python/bcc/utils.py @@ -45,7 +45,7 @@ def detect_language(candidates, pid): FILESYSTEMENCODING = sys.getfilesystemencoding() -def printb(s, file=sys.stdout): +def printb(s, file=sys.stdout, nl=1): """ printb(s) @@ -54,7 +54,8 @@ def printb(s, file=sys.stdout): buf = file.buffer if hasattr(file, "buffer") else file buf.write(s) - buf.write(b"\n") + if nl: + buf.write(b"\n") file.flush() class ArgString(object): |