[apparmor] [patch][utils] Refractor prompts to class
Kshitij Gupta
kgupta8592 at gmail.com
Wed Oct 8 19:50:42 UTC 2014
Hello,
Somehow aa-genprof sneaked through without being updated for the ui changes.
The following patch:
- ensures aa-genprof also uses class based prompt
Also, a grep for "UI_PromptUser" returns nothing for new tools.
=== modified file 'utils/aa-genprof'
--- utils/aa-genprof 2014-09-14 18:17:00 +0000
+++ utils/aa-genprof 2014-10-08 19:45:32 +0000
@@ -143,11 +143,11 @@
else:
logmark = last_audit_entry_time()
- q=apparmor.hasher()
- q['headers'] = [_('Profiling'), program]
- q['functions'] = ['CMD_SCAN', 'CMD_FINISHED']
- q['default'] = 'CMD_SCAN'
- ans, arg = aaui.UI_PromptUser(q, 'noexit')
+ q = aaui.PromptQuestion()
+ q.headers = [_('Profiling'), program]
+ q.functions = ['CMD_SCAN', 'CMD_FINISHED']
+ q.default = 'CMD_SCAN'
+ ans, arg = q.promptUser('noexit')
if ans == 'CMD_SCAN':
lp_ret = apparmor.do_logprof_pass(logmark, passno)
Regards,
Kshitij Gupta
On Tue, Oct 7, 2014 at 5:19 PM, Christian Boltz <apparmor at cboltz.de> wrote:
> Hello,
>
> Am Dienstag, 7. Oktober 2014 schrieb Kshitij Gupta:
>> Sorry for the delayed response, I was unable find time for the same
>> (owing to exams).
>
> Feel free to test me with some example questions on IRC (assuming your
> exams were about topics that are somehow related to programming ;-)
>
>> On Mon, Sep 22, 2014 at 2:26 AM, Christian Boltz wrote:
>> > Am Mittwoch, 10. September 2014 schrieb Kshitij Gupta:
>> >> In keeping with the idea to make the less Perl-ish and more OOP
>> >> style
>> >> (in hope to get more Pythonic). I thought it was a simple place to
>> >> start off with.
>> >>
>> >> Any suggestions and changes for the patch are welcome.
>> >>
>> >> The following patch:
>> >> - creates a class for prompt questions moving away from Perl hash
>> >> hack for the purpose.
>> >> - moves some functions to the methods for that class
>> >> - fix options being incorrectly passed to questionPrompt in
>> >> aa-mergeprof
>> >>
>> >> Due to the functions being moved around the patch is a bit long.
>> >
>> > That, and lots of q.['whatever'] -> q.whatever changes ;-)
>>
>> Well due to a patch to fix the messages so that they named parameters,
>> this patch got a bit broken.
>>
>> Attached below is the updated patch and a diff of the old and new
>> patch to make things easier (harder?).
>
> I compared the old and new patch with meld ;-)
>
> Using interdiff might also work, but funnily I got
>
> # interdiff ui_refractor.patch ui_refractor.patch3
> diff -u utils/aa-mergeprof utils/aa-mergeprof
> --- utils/aa-mergeprof 2014-09-10 09:46:48 +0000
> +++ utils/aa-mergeprof 2014-10-07 07:59:39 +0000
> @@ -26,7 +26,7 @@
> from apparmor.translations import init_translation
> _ = init_translation()
>
> -parser = argparse.ArgumentParser(description=_('Perform a 2-way or 3-way merge on the given profiles'),
> +parser = argparse.ArgumentParser(description=_('Perform a 2-way or 3-way merge on the given profiles'),
> epilog='WARNING: the arguments will change in a future version!')
> parser.add_argument('mine', type=str, help=_('your profile'))
> parser.add_argument('base', type=str, help=_('base profile'))
> 1 out of 1 hunk FAILED -- saving rejects to file /tmp/interdiff-1.p1QJzm.rej
> interdiff: Error applying patch1 to reconstructed file
>
> The last two lines are a bit ;-) unexpected and strange.
>
>> >> Basic testing done with logprof.
>>
>> Again basic ui tested with logprof.
>
> Acked-by: Christian Boltz <apparmor at cboltz.de>
>
> I'd recommend to commit it soon, before you get new merge conflicts ;-)
>
>
>> > The patch looks good, with one exception:
>> >
>> > === modified file 'utils/apparmor/ui.py'
>
>> > + def promptUser(self, params=''):
>
>> > + ypath, yarg = GetDataFromYast()
>> >
>> > That should probably be
>> >
>> > ypath, yarg = self.GetDataFromYast()
>> >
>> > (note the added "self.")
>>
>> No the self is not needed as the function is from a different module
>> and a method of the class.
>
> Indeed. I probably overlooked the "import" line, sorry.
>
>
> Regards,
>
> Christian Boltz
> --
> Ich hab dauernd das blöde Gefühl, dass ich dich fürchterlich nerve,
> weil ich sowas nicht alleine hinbekomme. Überall lese ich nur: "Ist
> ganz einfach - ging bei mir in 30 Minuten". Ich muss scheinbar doch
> bescheuert sein. [Andreas Schott]
>
>
> --
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
More information about the AppArmor
mailing list