Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Unified Diff: third_party/pexpect/tools/display-fpathconf.py

Issue 1398903002: Add third_party/pexpect (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@end-to-end-test
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pexpect/tests/utils.py ('k') | third_party/pexpect/tools/display-maxcanon.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pexpect/tools/display-fpathconf.py
diff --git a/third_party/pexpect/tools/display-fpathconf.py b/third_party/pexpect/tools/display-fpathconf.py
new file mode 100644
index 0000000000000000000000000000000000000000..d40cbae206fa1d67ac410f7dc712a0f6b40a5e53
--- /dev/null
+++ b/third_party/pexpect/tools/display-fpathconf.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+"""Displays os.fpathconf values related to terminals. """
+from __future__ import print_function
+import sys
+import os
+
+
+def display_fpathconf():
+ DISP_VALUES = (
+ ('PC_MAX_CANON', ('Max no. of bytes in a '
+ 'terminal canonical input line.')),
+ ('PC_MAX_INPUT', ('Max no. of bytes for which '
+ 'space is available in a terminal input queue.')),
+ ('PC_PIPE_BUF', ('Max no. of bytes which will '
+ 'be written atomically to a pipe.')),
+ ('PC_VDISABLE', 'Terminal character disabling value.')
+ )
+ FMT = '{name:<13} {value:<5} {description}'
+
+ # column header
+ print(FMT.format(name='name', value='value', description='description'))
+ print(FMT.format(name=('-' * 13), value=('-' * 5), description=('-' * 11)))
+
+ fd = sys.stdin.fileno()
+ for name, description in DISP_VALUES:
+ key = os.pathconf_names.get(name, None)
+ if key is None:
+ value = 'UNDEF'
+ else:
+ try:
+ value = os.fpathconf(fd, name)
+ except OSError as err:
+ value = 'OSErrno {0.errno}'.format(err)
+ if name == 'PC_VDISABLE':
+ value = hex(value)
+ print(FMT.format(name=name, value=value, description=description))
+ print()
+
+
+if __name__ == '__main__':
+ display_fpathconf()
« no previous file with comments | « third_party/pexpect/tests/utils.py ('k') | third_party/pexpect/tools/display-maxcanon.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698