Make abrt-python compatibile with RHEL6 and Python 2.6.6.
Richard Marko (5): abrt-python: fix deprecation warnings abrt-python: pass DD_OPEN_READONLY only if available abrt-python: fix tests compatibility with python 2.6 abrt-python: check if gid equals current users gid abrt-python: fix dbus compatibility on RHEL6
src/python-problem/problem/__init__.py | 4 ++-- src/python-problem/problem/proxies.py | 25 +++++++++++-------- src/python-problem/problem/watch.py | 8 ++++++- src/python-problem/test | 2 +- src/python-problem/tests/test_api.py | 44 +++++++++++++--------------------- 5 files changed, 41 insertions(+), 42 deletions(-)
Signed-off-by: Richard Marko rmarko@redhat.com --- src/python-problem/problem/__init__.py | 4 ++-- src/python-problem/problem/proxies.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/python-problem/problem/__init__.py b/src/python-problem/problem/__init__.py index a211c0b..65804a1 100644 --- a/src/python-problem/problem/__init__.py +++ b/src/python-problem/problem/__init__.py @@ -113,7 +113,7 @@ class Problem(object): try: return self.__getattr__(attr) except AttributeError as e: - raise KeyError(e.message) + raise KeyError(e)
def __setitem__(self, attr, value): self.__setattr__(attr, value) @@ -122,7 +122,7 @@ class Problem(object): try: self.__delattr__(attr) except AttributeError as e: - raise KeyError(e.message) + raise KeyError(e)
def __repr__(self): return '<problem.{0} ({1})>'.format(self.__class__.__name__, self.reason) diff --git a/src/python-problem/problem/proxies.py b/src/python-problem/problem/proxies.py index 0b1c7df..d4b3cfa 100644 --- a/src/python-problem/problem/proxies.py +++ b/src/python-problem/problem/proxies.py @@ -17,7 +17,7 @@ class DBusProxy(object):
def __new__(cls, *args, **kwargs): if not cls.__instance: - cls.__instance = super(DBusProxy, cls).__new__(cls, *args, **kwargs) + cls.__instance = super(DBusProxy, cls).__new__(cls)
return cls.__instance
@@ -29,14 +29,14 @@ class DBusProxy(object): self._proxy = self.dbus.SystemBus().get_object( 'org.freedesktop.problems', '/org/freedesktop/problems') except self.dbus.exceptions.DBusException as e: - logging.debug('Unable to get dbus proxy: {0}'.format(e.message)) + logging.debug('Unable to get dbus proxy: {0}'.format(e)) return
try: self._iface = self.dbus.Interface(self._proxy, 'org.freedesktop.problems') except self.dbus.exceptions.DBusException as e: - logging.debug('Unable to get dbus interface: {0}'.format(e.message)) + logging.debug('Unable to get dbus interface: {0}'.format(e)) return
self.connected = True @@ -52,10 +52,10 @@ class DBusProxy(object): return getattr(self._iface, fun_name)(*args)
if dbname == 'org.freedesktop.problems.AuthFailure': - raise problem.exception.AuthFailure(e.message) + raise problem.exception.AuthFailure(e)
if dbname == 'org.freedesktop.problems.InvalidProblemDir': - raise problem.exception.InvalidProblem(e.message) + raise problem.exception.InvalidProblem(e)
raise
Signed-off-by: Richard Marko rmarko@redhat.com --- src/python-problem/problem/proxies.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/python-problem/problem/proxies.py b/src/python-problem/problem/proxies.py index d4b3cfa..c547161 100644 --- a/src/python-problem/problem/proxies.py +++ b/src/python-problem/problem/proxies.py @@ -155,13 +155,15 @@ class FsProxy(object): def get_item(self, dump_dir, name): ddir = self._open_ddir(dump_dir)
- val = ddir.load_text( - name, - report.DD_OPEN_READONLY | - report.DD_FAIL_QUIETLY_EACCES | + flags = (report.DD_FAIL_QUIETLY_EACCES | report.DD_FAIL_QUIETLY_ENOENT | report.DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE)
+ if hasattr(report, 'DD_OPEN_READONLY'): + flags |= report.DD_OPEN_READONLY + + val = ddir.load_text(name, flags) + ddir.close() return val
Signed-off-by: Richard Marko rmarko@redhat.com --- src/python-problem/test | 2 +- src/python-problem/tests/test_api.py | 44 +++++++++++++----------------------- 2 files changed, 17 insertions(+), 29 deletions(-)
diff --git a/src/python-problem/test b/src/python-problem/test index 9e9a7f4..8f993e0 100755 --- a/src/python-problem/test +++ b/src/python-problem/test @@ -6,4 +6,4 @@ if [ $? -ne 0 ]; then exit 1 fi
-nosetests --with-coverage --cover-package=problem --nocapture --nologcapture --no-skip --verbose tests/*.py +nosetests --with-coverage --cover-package=problem --nocapture --no-skip --verbose tests/*.py diff --git a/src/python-problem/tests/test_api.py b/src/python-problem/tests/test_api.py index 0cdd81f..1d6c6e5 100755 --- a/src/python-problem/tests/test_api.py +++ b/src/python-problem/tests/test_api.py @@ -40,11 +40,7 @@ class ProblemAPITestCase(ProblematicTestCase):
tools.eq_(prob.reason, 'Front fell off')
- with self.assertRaises(AttributeError): - prob.non_existent - - with self.assertRaises(AttributeError): - prob.non_existent_method() + self.assertRaises(AttributeError, lambda: prob.non_existent)
prob.add_current_process_data() ident = prob.save() @@ -52,11 +48,7 @@ class ProblemAPITestCase(ProblematicTestCase): self.proxy.set_item(ident, 'test', 'wat') tools.eq_(prob.test, 'wat')
- with self.assertRaises(AttributeError): - prob.persisted_non_existent - - with self.assertRaises(AttributeError): - prob.persisted_non_existent_method() + self.assertRaises(AttributeError, lambda: prob.persisted_non_existent)
prob.delete()
@@ -67,8 +59,7 @@ class ProblemAPITestCase(ProblematicTestCase): prob.save() del prob.executable
- with self.assertRaises(AttributeError): - prob.executable + self.assertRaises(AttributeError, getattr, prob, 'executable')
prob.delete()
@@ -89,8 +80,7 @@ class ProblemAPITestCase(ProblematicTestCase):
tools.eq_(prob['reason'], 'Front fell off')
- with self.assertRaises(KeyError): - prob['non_existent'] + self.assertRaises(KeyError, lambda: prob['non_existent'])
prob.add_current_process_data() ident = prob.save() @@ -98,8 +88,7 @@ class ProblemAPITestCase(ProblematicTestCase): self.proxy.set_item(ident, 'test', 'wat') tools.eq_(prob['test'], 'wat')
- with self.assertRaises(KeyError): - prob['persisted_non_existent'] + self.assertRaises(KeyError, lambda: prob['persisted_non_existent'])
prob.delete()
@@ -156,11 +145,9 @@ class ProblemAPITestCase(ProblematicTestCase): def test_delattr(self): prob = self.create_problem() del prob.reason - with self.assertRaises(AttributeError): - prob.reason + self.assertRaises(AttributeError, lambda: prob.reason)
- with self.assertRaises(AttributeError): - del prob.non_existent + self.assertRaises(AttributeError, lambda: prob.non_existant)
prob.add_current_process_data() ident = prob.save() @@ -184,9 +171,11 @@ class ProblemAPITestCase(ProblematicTestCase):
del prob.test
- with self.assertRaises(AttributeError): + def raising_delete(): del prob.test
+ self.assertRaises(AttributeError, raising_delete) + prob.save()
tools.eq_(self.proxy.get_item(ident, 'test'), None) @@ -197,12 +186,13 @@ class ProblemAPITestCase(ProblematicTestCase): prob = self.create_problem()
del prob['reason'] - with self.assertRaises(KeyError): - prob['reason'] + self.assertRaises(KeyError, lambda: prob['reason'])
- with self.assertRaises(KeyError): + def raising_delete(): del prob['non_existent']
+ self.assertRaises(KeyError, raising_delete) + prob.add_current_process_data() ident = prob.save()
@@ -291,8 +281,7 @@ class ProblemAPITestCase(ProblematicTestCase): prob.validate()
del prob.executable - with self.assertRaises(problem.exception.ValidationError): - prob.validate() + self.assertRaises(problem.exception.ValidationError, prob.validate)
def test_invalidproblem(self): prob = self.create_problem() @@ -302,8 +291,7 @@ class ProblemAPITestCase(ProblematicTestCase):
time.sleep(2)
- with self.assertRaises(problem.exception.InvalidProblem): - self.proxy.get_item(ident, 'reason') + self.assertRaises(problem.exception.InvalidProblem, self.proxy.get_item,ident, 'reason')
def test_save(self): prob = self.create_problem()
Required for old dump directory style where ownership is stored in gid instead of uid.
Signed-off-by: Richard Marko rmarko@redhat.com --- src/python-problem/problem/proxies.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/python-problem/problem/proxies.py b/src/python-problem/problem/proxies.py index c547161..1bd89a4 100644 --- a/src/python-problem/problem/proxies.py +++ b/src/python-problem/problem/proxies.py @@ -193,7 +193,10 @@ class FsProxy(object): continue
uid = os.getuid() - if not _all and os.stat(dump_dir).st_uid != uid: + gid = os.getuid() + dir_stat = os.stat(dump_dir) + if not _all and (dir_stat.st_uid != uid and + dir_stat.st_gid != gid): continue
ddir = report.dd_opendir(dump_dir)
Related to #651.
Signed-off-by: Richard Marko rmarko@redhat.com --- src/python-problem/problem/watch.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/python-problem/problem/watch.py b/src/python-problem/problem/watch.py index 2f83fde..49ec395 100644 --- a/src/python-problem/problem/watch.py +++ b/src/python-problem/problem/watch.py @@ -16,11 +16,12 @@ class ProblemWatcher(object): def __init__(self, auth): import dbus import gobject + from dbus.mainloop.glib import DBusGMainLoop
gobject.threads_init()
bus = dbus.SystemBus( - mainloop=dbus.mainloop.glib.DBusGMainLoop(), + mainloop=DBusGMainLoop(), private=True)
self.bus = bus @@ -33,6 +34,11 @@ class ProblemWatcher(object): self._new_problem_handler, signal_name='Crash', path='/org/freedesktop/problems')
+ # add second listener for the old path + evt_match_old_path = self.bus.add_signal_receiver( + self._new_problem_handler, + signal_name='Crash', path='/com/redhat/abrt') + self.loop = gobject.MainLoop()
def _new_problem_handler(self, comp, ddir, uid):
Pushed. Thanks!
On Thursday 09 of May 2013 15:44:04 Richard Marko wrote:
Make abrt-python compatibile with RHEL6 and Python 2.6.6.
Richard Marko (5): abrt-python: fix deprecation warnings abrt-python: pass DD_OPEN_READONLY only if available abrt-python: fix tests compatibility with python 2.6 abrt-python: check if gid equals current users gid abrt-python: fix dbus compatibility on RHEL6
src/python-problem/problem/__init__.py | 4 ++-- src/python-problem/problem/proxies.py | 25 +++++++++++-------- src/python-problem/problem/watch.py | 8 ++++++- src/python-problem/test | 2 +- src/python-problem/tests/test_api.py | 44 +++++++++++++--------------------- 5 files changed, 41 insertions(+), 42 deletions(-)
crash-catcher@lists.fedorahosted.org