From 89cdf6ee1e796e5ba4c302a19da4862e18b99c4a Mon Sep 17 00:00:00 2001 From: Petr Spacek Date: May 12 2016 11:28:00 +0000 Subject: 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 --- diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py index 2da7b7c..42edba2 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: