All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
To: bitbake-devel@lists.openembedded.org
Subject: [PATCH 2/2] bitbake-dumpsig: Change to use argparse
Date: Wed, 14 Nov 2018 02:10:19 +0100	[thread overview]
Message-ID: <20181114011019.878-2-pkj@axis.com> (raw)
In-Reply-To: <20181114011019.878-1-pkj@axis.com>

This corresponds to commit 7f130e0b for bitbake-diffsigs.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 bitbake/bin/bitbake-dumpsig | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/bitbake/bin/bitbake-dumpsig b/bitbake/bin/bitbake-dumpsig
index 40e08e0439..50e5717ace 100755
--- a/bitbake/bin/bitbake-dumpsig
+++ b/bitbake/bin/bitbake-dumpsig
@@ -22,7 +22,7 @@
 import os
 import sys
 import warnings
-import optparse
+import argparse
 import logging
 import pickle
 
@@ -73,21 +73,22 @@ def find_siginfo_task(bbhandler, pn, taskname):
 
     return latestfiles[0]
 
-parser = optparse.OptionParser(
-    description = "Dumps siginfo/sigdata files written out by BitBake",
-    usage = """
-  %prog -t recipename taskname
-  %prog sigdatafile""")
+parser = argparse.ArgumentParser(
+    description="Dump siginfo/sigdata files written out by BitBake")
 
-parser.add_option("-D", "--debug",
-        help = "enable debug",
-        action = "store_true", dest="debug", default = False)
+parser.add_argument('-d', '--debug',
+                    help='Enable debug output',
+                    action='store_true')
 
-parser.add_option("-t", "--task",
-        help = "find the signature data file for the specified task",
-        action="store", dest="taskargs", nargs=2, metavar='recipename taskname')
+parser.add_argument("-t", "--task",
+        help="find the signature data file for the last run of the specified task",
+        action="store", dest="taskargs", nargs=2, metavar=('recipename', 'taskname'))
 
-options, args = parser.parse_args(sys.argv)
+parser.add_argument("sigdatafile",
+        help="Signature file to dump. Not used when using -t/--task.",
+        action="store", nargs='?')
+
+options = parser.parse_args()
 
 if options.debug:
     logger.setLevel(logging.DEBUG)
@@ -97,11 +98,11 @@ if options.taskargs:
     tinfoil.prepare(config_only = True)
     file = find_siginfo_task(tinfoil, options.taskargs[0], options.taskargs[1])
     logger.debug("Signature file: %s" % file)
-elif len(args) == 1:
-    parser.print_help()
-    sys.exit(0)
+elif options.sigdatafile:
+    file = options.sigdatafile
 else:
-    file = args[1]
+    parser.print_help()
+    sys.exit(1)
 
 try:
     output = bb.siggen.dump_sigfile(file)
-- 
2.12.0



  reply	other threads:[~2018-11-14  1:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14  1:10 [PATCH 1/2] bitbake-dumpsig: Make --task work again Peter Kjellerstedt
2018-11-14  1:10 ` Peter Kjellerstedt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-11-14  1:01 Peter Kjellerstedt
2018-11-14  1:01 ` [PATCH 2/2] bitbake-dumpsig: Change to use argparse Peter Kjellerstedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181114011019.878-2-pkj@axis.com \
    --to=peter.kjellerstedt@axis.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.