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

-- 
Petr^2 Spacek
From f85a79c15752e0328c9b4c7d6c28fcdb7dbc0282 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..51899f61a33cf77f90055a4908c3bc0168e988da 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 principal>'),
+                    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