diff options
Diffstat (limited to '')
-rwxr-xr-x | scripts/.scripts/linux_system_error_list.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/scripts/.scripts/linux_system_error_list.py b/scripts/.scripts/linux_system_error_list.py index 43f1cb5..ee1a7a6 100755 --- a/scripts/.scripts/linux_system_error_list.py +++ b/scripts/.scripts/linux_system_error_list.py @@ -1,6 +1,6 @@ #!/bin/python -import re +import re, sys from terminaltables import DoubleTable data = [] @@ -25,6 +25,22 @@ def get_content(file): get_content("/usr/include/asm-generic/errno-base.h") get_content("/usr/include/asm-generic/errno.h") -table = DoubleTable(data, "Error code") -table.justify_columns = {0: 'right', 1: 'center', 2: 'left'} -print(table.table) +if len(sys.argv) == 2 and sys.argv[1] == "list": + table = DoubleTable(data, "Error code") + table.justify_columns = {0: 'right', 1: 'center', 2: 'left'} + print(table.table) +elif (len(sys.argv) == 2 or len(sys.argv) == 3) and sys.argv[1] == "search": + if len(sys.argv) == 3: + data_searched = [] + data_searched.append(['Error', 'Code', 'Comment']) + for line in data: + if re.search(sys.argv[2],str(line)): + data_searched.append(line) + table = DoubleTable(data_searched, "Error code") + table.justify_columns = {0: 'right', 1: 'center', 2: 'left'} + print(table.table) + else: + print("search <search_string> # You can send regex following re.search python function") +else: + print("search <search_string> # You can send regex following re.search python function") + print("list # Return list of all error from errno.h and errno-base.h") |