On 4.5.2016 15:04, Jan Cholasta wrote:
> Hi,
> 
> On 22.4.2016 13:28, Petr Spacek wrote:
>> Hello,
>>
>> 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
> 
> LGTM, but please use 'UNKNOWN' as the default value, for consistency with
> ipalib.rpcserver code.

Here you are.

-- 
Petr^2 Spacek
From 309776755e1e8ba46830227264bc44f22298fae0 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
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
---
 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 2da7b7ca811fc67b22c43655352ace539488ce0d..42edba2ad85c2e11b3167dba2b5f82fcc87dd86b 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:
-- 
2.5.5

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to