summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2017-12-31 17:46:40 +0100
committerAmar Tumballi <amarts@redhat.com>2018-03-24 05:09:37 +0000
commitaaa4e373f3c7093fa13d0882a034f35aba2761a1 (patch)
treeb24faca6bbcc03c8fff993b2bf49f96693a021be /tools
parenta69e8a664adb3a9255f44522facf04c041f6dec6 (diff)
glusterfind: Show C function when raising ChangelogException
Fixes: #432 Change-Id: I9ab031e098aff717e619d9deb6410281b96de14a Signed-off-by: Niklas Hambüchen <mail@nh2.me>
Diffstat (limited to 'tools')
-rw-r--r--tools/glusterfind/src/libgfchangelog.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/tools/glusterfind/src/libgfchangelog.py b/tools/glusterfind/src/libgfchangelog.py
index 0f6b40d6c9c..b7d8efcb4e4 100644
--- a/tools/glusterfind/src/libgfchangelog.py
+++ b/tools/glusterfind/src/libgfchangelog.py
@@ -21,28 +21,29 @@ class ChangelogException(OSError):
libgfc = CDLL(find_library("gfchangelog"), use_errno=True, mode=RTLD_GLOBAL)
-def raise_oserr():
+def raise_oserr(prefix=None):
errn = get_errno()
- raise ChangelogException(errn, os.strerror(errn))
+ prefix_or_empty = prefix + ": " if prefix else ""
+ raise ChangelogException(errn, prefix_or_empty + os.strerror(errn))
def cl_init():
ret = libgfc.gf_changelog_init(None)
if ret == -1:
- raise_oserr()
+ raise_oserr(prefix="gf_changelog_init")
def cl_register(brick, path, log_file, log_level, retries=0):
ret = libgfc.gf_changelog_register(brick, path, log_file,
log_level, retries)
if ret == -1:
- raise_oserr()
+ raise_oserr(prefix="gf_changelog_register")
def cl_history_scan():
ret = libgfc.gf_history_changelog_scan()
if ret == -1:
- raise_oserr()
+ raise_oserr(prefix="gf_history_changelog_scan")
return ret
@@ -53,7 +54,7 @@ def cl_history_changelog(changelog_path, start, end, num_parallel):
num_parallel,
byref(actual_end))
if ret == -1:
- raise_oserr()
+ raise_oserr(prefix="gf_history_changelog")
return actual_end.value
@@ -61,7 +62,7 @@ def cl_history_changelog(changelog_path, start, end, num_parallel):
def cl_history_startfresh():
ret = libgfc.gf_history_changelog_start_fresh()
if ret == -1:
- raise_oserr()
+ raise_oserr(prefix="gf_history_changelog_start_fresh")
def cl_history_getchanges():
@@ -78,7 +79,7 @@ def cl_history_getchanges():
break
changes.append(buf.raw[:ret - 1])
if ret == -1:
- raise_oserr()
+ raise_oserr(prefix="gf_history_changelog_next_change")
return sorted(changes, key=clsort)
@@ -86,4 +87,4 @@ def cl_history_getchanges():
def cl_history_done(clfile):
ret = libgfc.gf_history_changelog_done(clfile)
if ret == -1:
- raise_oserr()
+ raise_oserr(prefix="gf_history_changelog_done")