From 841a58bb59f1ffdcccd63d1cce592c81569a8116 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 08 2015 09:43:57 +0000 Subject: Adjust pagure to work on recent version of psutils as well as the old one Fixes https://pagure.io/pagure/issue/524 --- diff --git a/pagure/mail_logging.py b/pagure/mail_logging.py index 405872e..5f74125 100644 --- a/pagure/mail_logging.py +++ b/pagure/mail_logging.py @@ -76,8 +76,17 @@ class ContextInjector(logging.Filter): # pragma: no cover record.pid = '-' if not isinstance(current_process, str): record.pid = current_process.pid - record.proc_name = current_process.name - record.command_line = " ".join(current_process.cmdline) + # Be compatible with python-psutil 1.0 and 2.0, 3.0 + proc_name = current_process.name + if callable(proc_name): + proc_name = proc_name() + record.proc_name = proc_name + # Be compatible with python-psutil 1.0 and 2.0, 3.0 + cmd_line = current_process.cmdline + if callable(cmd_line): + cmd_line = cmd_line() + record.command_line = " ".join(cmd_line) + record.callstack = self.format_callstack() record.url = '-'