From 89cdf6ee1e796e5ba4c302a19da4862e18b99c4a Mon Sep 17 00:00:00 2001 From: Petr Spacek Date: Fri, 22 Apr 2016 10:54:44 +0200 Subject: [PATCH] Batch command: avoid accessing potentially undefined context.principal This might happen when the command is called directly in Python, e.g. in installers and so on. Pylint pylint-1.5.5-1.fc24.noarch caught this. https://fedorahosted.org/freeipa/ticket/5838 Reviewed-By: Jan Cholasta --- ipalib/plugins/batch.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py index 2da7b7ca8..42edba2ad 100644 --- a/ipalib/plugins/batch.py +++ b/ipalib/plugins/batch.py @@ -107,7 +107,10 @@ class batch(Command): result = api.Command[name](*a, **newkw) self.info( - '%s: batch: %s(%s): SUCCESS', context.principal, name, ', '.join(api.Command[name]._repr_iter(**params)) + '%s: batch: %s(%s): SUCCESS', + getattr(context, 'principal', 'UNKNOWN'), + name, + ', '.join(api.Command[name]._repr_iter(**params)) ) result['error']=None except Exception as e: