diff mbox series

[2/2] python/semanage: Use standard argparse.error() method in handlePermissive

Message ID 20190206194325.24875-2-plautrba@redhat.com (mailing list archive)
State Accepted
Headers show
Series [1/2] python/semanage module: Fix handling of -a/-e/-d/-r options | expand

Commit Message

Petr Lautrbach Feb. 6, 2019, 7:43 p.m. UTC
This method prints a usage message including the message to the standard error
and terminates the program with a status code of 2.

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
---
 python/semanage/semanage | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Nicolas Iooss Feb. 7, 2019, 9:47 p.m. UTC | #1
On Wed, Feb 6, 2019 at 8:43 PM Petr Lautrbach <plautrba@redhat.com> wrote:
>
> This method prints a usage message including the message to the standard error
> and terminates the program with a status code of 2.
>
> Signed-off-by: Petr Lautrbach <plautrba@redhat.com>

For this patch:
Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org>

> ---
>  python/semanage/semanage | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/python/semanage/semanage b/python/semanage/semanage
> index 9b737fa8..a9fcb319 100644
> --- a/python/semanage/semanage
> +++ b/python/semanage/semanage
> @@ -743,9 +743,7 @@ def handlePermissive(args):
>          if args.action == "delete":
>              OBJECT.delete(args.type)
>      else:
> -        args.parser.print_usage(sys.stderr)
> -        sys.stderr.write(_('semanage permissive: error: the following argument is required: type\n'))
> -        sys.exit(1)
> +        args.parser.error(message=_('semanage permissive: error: the following argument is required: type\n'))
>
>
>  def setupPermissiveParser(subparsers):
> --
> 2.20.1
>
Nicolas Iooss Feb. 10, 2019, 4:51 p.m. UTC | #2
On Thu, Feb 7, 2019 at 10:47 PM Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
>
> On Wed, Feb 6, 2019 at 8:43 PM Petr Lautrbach <plautrba@redhat.com> wrote:
> >
> > This method prints a usage message including the message to the standard error
> > and terminates the program with a status code of 2.
> >
> > Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
>
> For this patch:
> Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org>

Merged.

Nicolas

> > ---
> >  python/semanage/semanage | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/python/semanage/semanage b/python/semanage/semanage
> > index 9b737fa8..a9fcb319 100644
> > --- a/python/semanage/semanage
> > +++ b/python/semanage/semanage
> > @@ -743,9 +743,7 @@ def handlePermissive(args):
> >          if args.action == "delete":
> >              OBJECT.delete(args.type)
> >      else:
> > -        args.parser.print_usage(sys.stderr)
> > -        sys.stderr.write(_('semanage permissive: error: the following argument is required: type\n'))
> > -        sys.exit(1)
> > +        args.parser.error(message=_('semanage permissive: error: the following argument is required: type\n'))
> >
> >
> >  def setupPermissiveParser(subparsers):
> > --
> > 2.20.1
> >
diff mbox series

Patch

diff --git a/python/semanage/semanage b/python/semanage/semanage
index 9b737fa8..a9fcb319 100644
--- a/python/semanage/semanage
+++ b/python/semanage/semanage
@@ -743,9 +743,7 @@  def handlePermissive(args):
         if args.action == "delete":
             OBJECT.delete(args.type)
     else:
-        args.parser.print_usage(sys.stderr)
-        sys.stderr.write(_('semanage permissive: error: the following argument is required: type\n'))
-        sys.exit(1)
+        args.parser.error(message=_('semanage permissive: error: the following argument is required: type\n'))
 
 
 def setupPermissiveParser(subparsers):