aboutsummaryrefslogtreecommitdiff
path: root/scripts/.scripts
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2017-11-05 01:45:14 +0100
committerneodarz <neodarz@neodarz.net>2017-11-05 01:45:14 +0100
commit9fa2106b3fc2a2dbe3eeadfb8e635af2dd821b82 (patch)
tree037ecbcfd44b95161beef7c173839b20e10a8cac /scripts/.scripts
parentb1203493d71b8350a2da184d70f3f682bc9b0ac5 (diff)
downloaddotfiles_ascii-9fa2106b3fc2a2dbe3eeadfb8e635af2dd821b82.tar.xz
dotfiles_ascii-9fa2106b3fc2a2dbe3eeadfb8e635af2dd821b82.zip
Simple python script for get linux error code
Diffstat (limited to 'scripts/.scripts')
-rwxr-xr-xscripts/.scripts/linux_system_error_list.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/.scripts/linux_system_error_list.py b/scripts/.scripts/linux_system_error_list.py
new file mode 100755
index 0000000..43f1cb5
--- /dev/null
+++ b/scripts/.scripts/linux_system_error_list.py
@@ -0,0 +1,30 @@
+#!/bin/python
+
+import re
+from terminaltables import DoubleTable
+
+data = []
+data.append(['Error', 'Code', 'Comment'])
+
+def get_content(file):
+
+ with open(file) as f:
+ content = f.readlines()
+
+ content = [x.strip() for x in content]
+
+ for line in content:
+ if re.search('define',line):
+ line = re.sub('#define\t', '', line)
+ line = re.sub('(?m)^#define .*\n?', '', line)
+ line = re.sub('\t\t', '\t', line)
+ line = re.sub('(/\*|\*/)', '', line)
+ if line != '':
+ data.append(re.split(r'\t',line))
+
+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)