[apparmor] [PATCH 2/2] Add JSON interface to UI_Changes
Christian Boltz
apparmor at cboltz.de
Wed Oct 25 22:20:16 UTC 2017
Hello,
Am Montag, 23. Oktober 2017, 12:38:34 CEST schrieb Goldwyn Rodrigues:
> From: Goldwyn Rodrigues <rgoldwyn at suse.com>
>
> Provides the filename in the json format, which can be
> directly read by Yast. Increased the protocol version; perhaps
> it should go in the next release.
>
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.com>
> ---
> utils/apparmor/ui.py | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/utils/apparmor/ui.py b/utils/apparmor/ui.py
> index be07b28a..2afbd5b1 100644
> --- a/utils/apparmor/ui.py
> +++ b/utils/apparmor/ui.py
> @@ -45,7 +45,7 @@ def write_json(jsonout):
> def set_json_mode():
> global UI_mode
> UI_mode = 'json'
> - jsonout = {'dialog': 'apparmor-json-version', 'data': '2.12'}
> + jsonout = {'dialog': 'apparmor-json-version', 'data': '2.13'}
> write_json(jsonout)
>
> # reads the response on command line for json and verifies the
> response @@ -250,9 +250,16 @@ def
> generate_diff_with_comments(oldprofile, newprofile): def
> UI_Changes(oldprofile, newprofile, comments=False):
> if comments == False:
> difftemp = generate_diff(oldprofile, newprofile)
> + header = 'View Changes'
> else:
> difftemp = generate_diff_with_comments(oldprofile, newprofile)
> - subprocess.call('less %s' % difftemp.name, shell=True)
> + header = 'View Changes with comments'
> + if UI_mode == 'json':
> + jsonout = {'dialog': 'changes', 'header':header, 'filename':
> difftemp.name} + write_json(jsonout)
> + response = json_response('changes')["response"]
make check complains:
apparmor/ui.py:260: local variable 'response' is assigned to but never used
Obviously nobody cares about the response of displaying the diff (but
expecting a response is still a good idea to keep the interface
consistent). Therefore I'll change this line to
+ json_response('changes')["response"] # response gets ignored, therefore not assigning to a variable
> + else:
> + subprocess.call('less %s' % difftemp.name, shell=True)
> difftemp.close()
>
> CMDS = {'CMD_ALLOW': _('(A)llow'),
With the above change:
Acked-by: Christian Boltz <apparmor at cboltz.de>
Regards,
Christian Boltz
--
Ja, aber damit wirst Du Glenn nicht zufriedenstellen können. Unser
Baby will ein Edelfläschchen mit frischer, vorgereinigter Milch,
mit feinster Bourbonvanille versetzt und einem Schuss edelstem
Madagaskar-Rum. Garniert in einem Früchtetraum aus Mango, Aprikose
und Maracuja. [Philipp Zacharias in suse-linux]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20171026/c7080d23/attachment.sig>
More information about the AppArmor
mailing list