|
|
562801 |
From 128490bb35079d77c0fa04f2e254bd6a0acc382a Mon Sep 17 00:00:00 2001
|
|
|
562801 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
562801 |
Date: Thu, 24 Nov 2016 07:54:21 +0100
|
|
|
562801 |
Subject: [PATCH] reportclient: honor ABRT_VERBOSE
|
|
|
562801 |
|
|
|
562801 |
libreport's verbosity can be configured via ABRT_VERBOSE environment
|
|
|
562801 |
variable and reportclient must be aware of that.
|
|
|
562801 |
|
|
|
562801 |
Related to #1257159
|
|
|
562801 |
|
|
|
562801 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
562801 |
---
|
|
|
562801 |
src/client-python/__init__.py | 9 ++++++++
|
|
|
562801 |
tests/Makefile.am | 1 +
|
|
|
562801 |
tests/client_python.at | 53 +++++++++++++++++++++++++++++++++++++++++++
|
|
|
562801 |
tests/testsuite.at | 1 +
|
|
|
562801 |
4 files changed, 64 insertions(+)
|
|
|
562801 |
create mode 100644 tests/client_python.at
|
|
|
562801 |
|
|
|
562801 |
diff --git a/src/client-python/__init__.py b/src/client-python/__init__.py
|
|
|
562801 |
index 8966f22..f10f710 100644
|
|
|
562801 |
--- a/src/client-python/__init__.py
|
|
|
562801 |
+++ b/src/client-python/__init__.py
|
|
|
562801 |
@@ -31,6 +31,7 @@ from report import EXIT_STOP_EVENT_RUN as RETURN_STOP_EVENT_RUN
|
|
|
562801 |
|
|
|
562801 |
|
|
|
562801 |
GETTEXT_PROGNAME = "libreport"
|
|
|
562801 |
+import os
|
|
|
562801 |
import locale
|
|
|
562801 |
import gettext
|
|
|
562801 |
|
|
|
562801 |
@@ -52,10 +53,18 @@ def init_gettext():
|
|
|
562801 |
init_gettext()
|
|
|
562801 |
|
|
|
562801 |
verbose = 0
|
|
|
562801 |
+ABRT_VERBOSE = os.getenv("ABRT_VERBOSE")
|
|
|
562801 |
+if ABRT_VERBOSE:
|
|
|
562801 |
+ try:
|
|
|
562801 |
+ verbose = int(ABRT_VERBOSE)
|
|
|
562801 |
+ except:
|
|
|
562801 |
+ pass
|
|
|
562801 |
+
|
|
|
562801 |
|
|
|
562801 |
def set_verbosity(verbosity):
|
|
|
562801 |
global verbose
|
|
|
562801 |
verbose = verbosity
|
|
|
562801 |
+ os.environ["ABRT_VERBOSE"] = str(verbose)
|
|
|
562801 |
|
|
|
562801 |
def log(fmt, *args):
|
|
|
562801 |
sys.stderr.write("%s\n" % (fmt % args))
|
|
|
562801 |
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
|
562801 |
index b45f2d9..52dfce4 100644
|
|
|
562801 |
--- a/tests/Makefile.am
|
|
|
562801 |
+++ b/tests/Makefile.am
|
|
|
562801 |
@@ -40,6 +40,7 @@ TESTSUITE_AT = \
|
|
|
562801 |
libreport_types.at \
|
|
|
562801 |
xml_definition.at \
|
|
|
562801 |
report_python.at \
|
|
|
562801 |
+ client_python.at \
|
|
|
562801 |
xfuncs.at \
|
|
|
562801 |
string_list.at \
|
|
|
562801 |
ureport.at \
|
|
|
562801 |
diff --git a/tests/client_python.at b/tests/client_python.at
|
|
|
562801 |
new file mode 100644
|
|
|
562801 |
index 0000000..656b1b2
|
|
|
562801 |
--- /dev/null
|
|
|
562801 |
+++ b/tests/client_python.at
|
|
|
562801 |
@@ -0,0 +1,53 @@
|
|
|
562801 |
+# -*- Autotest -*-
|
|
|
562801 |
+
|
|
|
562801 |
+AT_BANNER([client_python])
|
|
|
562801 |
+
|
|
|
562801 |
+## --------- ##
|
|
|
562801 |
+## verbosity ##
|
|
|
562801 |
+## --------- ##
|
|
|
562801 |
+
|
|
|
562801 |
+AT_PYTESTFUN([verbosity], [[
|
|
|
562801 |
+import sys
|
|
|
562801 |
+import os
|
|
|
562801 |
+import unittest
|
|
|
562801 |
+
|
|
|
562801 |
+sys.path.insert(0, "../../../src/client-python")
|
|
|
562801 |
+sys.path.insert(0, "../../../src/client-python/.libs")
|
|
|
562801 |
+
|
|
|
562801 |
+
|
|
|
562801 |
+class TestReportClientVerbose(unittest.TestCase):
|
|
|
562801 |
+ def setUp(self):
|
|
|
562801 |
+ try:
|
|
|
562801 |
+ del os.environ["ABRT_VERBOSE"]
|
|
|
562801 |
+ except:
|
|
|
562801 |
+ pass
|
|
|
562801 |
+ os.unsetenv("ABRT_VERBOSE")
|
|
|
562801 |
+ self.clientpython = __import__("client-python", globals(), locals(), [], -1)
|
|
|
562801 |
+ reload(self.clientpython)
|
|
|
562801 |
+ sys.modules["clientpython"] = self.clientpython
|
|
|
562801 |
+
|
|
|
562801 |
+ def tearDown(self):
|
|
|
562801 |
+ del sys.modules["clientpython"]
|
|
|
562801 |
+
|
|
|
562801 |
+ def test_default(self):
|
|
|
562801 |
+ self.assertEquals(self.clientpython.verbose, 0)
|
|
|
562801 |
+
|
|
|
562801 |
+ def test_assign(self):
|
|
|
562801 |
+ self.clientpython.set_verbosity(1)
|
|
|
562801 |
+ self.assertEquals(self.clientpython.verbose, 1)
|
|
|
562801 |
+ self.assertEquals(os.environ["ABRT_VERBOSE"], "1")
|
|
|
562801 |
+
|
|
|
562801 |
+ def test_load_from_environ(self):
|
|
|
562801 |
+ os.environ["ABRT_VERBOSE"] = "2"
|
|
|
562801 |
+ reload(self.clientpython)
|
|
|
562801 |
+ self.assertEquals(self.clientpython.verbose, 2)
|
|
|
562801 |
+
|
|
|
562801 |
+ def test_recover_from_invalid_environ(self):
|
|
|
562801 |
+ os.environ["ABRT_VERBOSE"] = "foo"
|
|
|
562801 |
+ reload(self.clientpython)
|
|
|
562801 |
+ self.assertEquals(self.clientpython.verbose, 0)
|
|
|
562801 |
+
|
|
|
562801 |
+
|
|
|
562801 |
+if __name__ == "__main__":
|
|
|
562801 |
+ unittest.main()
|
|
|
562801 |
+]])
|
|
|
562801 |
diff --git a/tests/testsuite.at b/tests/testsuite.at
|
|
|
562801 |
index ccb37d1..8ded735 100644
|
|
|
562801 |
--- a/tests/testsuite.at
|
|
|
562801 |
+++ b/tests/testsuite.at
|
|
|
562801 |
@@ -15,6 +15,7 @@ m4_include([make_description.at])
|
|
|
562801 |
m4_include([libreport_types.at])
|
|
|
562801 |
m4_include([xml_definition.at])
|
|
|
562801 |
m4_include([report_python.at])
|
|
|
562801 |
+m4_include([client_python.at])
|
|
|
562801 |
m4_include([string_list.at])
|
|
|
562801 |
m4_include([ureport.at])
|
|
|
562801 |
m4_include([problem_report.at])
|
|
|
562801 |
--
|
|
|
562801 |
1.8.3.1
|
|
|
562801 |
|