mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 06:16:03 +00:00
[2/2] Add JSON interface to UI_Changes
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@suse.com> [cboltz] fix "unused variable" warning and add a comment about ignoring the JSON response Acked-by: Christian Boltz <apparmor@cboltz.de>
This commit is contained in:
committed by
Christian Boltz
parent
6ce2768115
commit
9a69ec2c48
@@ -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)
|
||||
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'),
|
||||
|
Reference in New Issue
Block a user