* [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module
@ 2018-04-01 19:14 Peter Korsgaard
2018-04-01 19:14 ` [Buildroot] [PATCH 2/2] support/scripts/graph-depends: add --quiet option Peter Korsgaard
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Peter Korsgaard @ 2018-04-01 19:14 UTC (permalink / raw)
To: buildroot
Instead of hardcoded sys.stderr.write() calls. No functional change, but
allows us to easily implement a quiet option.
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
support/scripts/brpkgutil.py | 13 +++++++------
support/scripts/graph-depends | 16 ++++++++++------
2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/support/scripts/brpkgutil.py b/support/scripts/brpkgutil.py
index 4c99ae9110..e70d525353 100644
--- a/support/scripts/brpkgutil.py
+++ b/support/scripts/brpkgutil.py
@@ -1,5 +1,6 @@
# Copyright (C) 2010-2013 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+import logging
import sys
import subprocess
@@ -7,18 +8,18 @@ import subprocess
# Execute the "make <pkg>-show-version" command to get the version of a given
# list of packages, and return the version formatted as a Python dictionary.
def get_version(pkgs):
- sys.stderr.write("Getting version for %s\n" % pkgs)
+ logging.info("Getting version for %s" % pkgs)
cmd = ["make", "-s", "--no-print-directory"]
for pkg in pkgs:
cmd.append("%s-show-version" % pkg)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
output = p.communicate()[0]
if p.returncode != 0:
- sys.stderr.write("Error getting version %s\n" % pkgs)
+ logging.error("Error getting version %s" % pkgs)
sys.exit(1)
output = output.split("\n")
if len(output) != len(pkgs) + 1:
- sys.stderr.write("Error getting version\n")
+ logging.error("Error getting version")
sys.exit(1)
version = {}
for i in range(0, len(pkgs)):
@@ -28,18 +29,18 @@ def get_version(pkgs):
def _get_depends(pkgs, rule):
- sys.stderr.write("Getting dependencies for %s\n" % pkgs)
+ logging.info("Getting dependencies for %s" % pkgs)
cmd = ["make", "-s", "--no-print-directory"]
for pkg in pkgs:
cmd.append("%s-%s" % (pkg, rule))
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
output = p.communicate()[0]
if p.returncode != 0:
- sys.stderr.write("Error getting dependencies %s\n" % pkgs)
+ logging.error("Error getting dependencies %s\n" % pkgs)
sys.exit(1)
output = output.split("\n")
if len(output) != len(pkgs) + 1:
- sys.stderr.write("Error getting dependencies\n")
+ logging.error("Error getting dependencies")
sys.exit(1)
deps = {}
for i in range(0, len(pkgs)):
diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends
index dc265ae28c..17bfaa0cf5 100755
--- a/support/scripts/graph-depends
+++ b/support/scripts/graph-depends
@@ -21,6 +21,7 @@
#
# Copyright (C) 2010-2013 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+import logging
import sys
import subprocess
import argparse
@@ -39,7 +40,7 @@ allpkgs = []
# Buildroot PACKAGES and return it formatted as a Python list. This
# list is used as the starting point for full dependency graphs
def get_targets():
- sys.stderr.write("Getting targets\n")
+ logging.info("Getting targets")
cmd = ["make", "-s", "--no-print-directory", "show-targets"]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
output = p.communicate()[0].strip()
@@ -192,10 +193,10 @@ def check_circular_deps(deps):
chain.append(pkg)
for p in deps[pkg]:
if p in chain:
- sys.stderr.write("\nRecursion detected for : %s\n" % (p))
+ logging.warning("\nRecursion detected for : %s" % (p))
while True:
_p = chain.pop()
- sys.stderr.write("which is a dependency of: %s\n" % (_p))
+ logging.warning("which is a dependency of: %s" % (_p))
if p == _p:
sys.exit(1)
recurse(p)
@@ -319,11 +320,14 @@ def main():
check_only = args.check_only
+ logging.basicConfig(stream=sys.stderr, format='%(message)s',
+ level=logging.INFO)
+
if args.outfile is None:
outfile = sys.stdout
else:
if check_only:
- sys.stderr.write("don't specify outfile and check-only at the same time\n")
+ logging.error("don't specify outfile and check-only at the same time")
sys.exit(1)
outfile = open(args.outfile, "w")
@@ -348,7 +352,7 @@ def main():
arrow_dir = "forward"
else:
if mode == MODE_FULL:
- sys.stderr.write("--reverse needs a package\n")
+ logging.error("--reverse needs a package")
sys.exit(1)
get_depends_func = brpkgutil.get_rdepends
arrow_dir = "back"
@@ -358,7 +362,7 @@ def main():
# We'll let 'dot' validate the colors...
colors = args.colors.split(',', 4)
if len(colors) != 3:
- sys.stderr.write("Error: incorrect color list '%s'\n" % args.colors)
+ logging.error("Error: incorrect color list '%s'" % args.colors)
sys.exit(1)
# In full mode, start with the result of get_targets() to get the main
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 2/2] support/scripts/graph-depends: add --quiet option
2018-04-01 19:14 [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module Peter Korsgaard
@ 2018-04-01 19:14 ` Peter Korsgaard
2018-04-01 20:07 ` Thomas Petazzoni
` (2 more replies)
2018-04-01 20:07 ` [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module Thomas Petazzoni
` (2 subsequent siblings)
3 siblings, 3 replies; 8+ messages in thread
From: Peter Korsgaard @ 2018-04-01 19:14 UTC (permalink / raw)
To: buildroot
This will be useful for the upcoming recursive show-depends and
show-rdepends features.
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
support/scripts/graph-depends | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends
index 17bfaa0cf5..4ec0e46f7b 100755
--- a/support/scripts/graph-depends
+++ b/support/scripts/graph-depends
@@ -312,6 +312,8 @@ def parse_args():
help="Draw direct dependencies (the default)")
parser.add_argument("--reverse", dest="direct", action='store_false',
help="Draw reverse dependencies")
+ parser.add_argument("--quiet", '-q', dest="quiet", action='store_true',
+ help="Quiet")
return parser.parse_args()
@@ -321,7 +323,7 @@ def main():
check_only = args.check_only
logging.basicConfig(stream=sys.stderr, format='%(message)s',
- level=logging.INFO)
+ level=logging.WARNING if args.quiet else logging.INFO)
if args.outfile is None:
outfile = sys.stdout
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module
2018-04-01 19:14 [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module Peter Korsgaard
2018-04-01 19:14 ` [Buildroot] [PATCH 2/2] support/scripts/graph-depends: add --quiet option Peter Korsgaard
@ 2018-04-01 20:07 ` Thomas Petazzoni
2018-04-01 20:21 ` Peter Korsgaard
2018-04-01 20:24 ` Yann E. MORIN
3 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2018-04-01 20:07 UTC (permalink / raw)
To: buildroot
Hello,
On Sun, 1 Apr 2018 21:14:48 +0200, Peter Korsgaard wrote:
> Instead of hardcoded sys.stderr.write() calls. No functional change, but
> allows us to easily implement a quiet option.
>
> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Thomas
--
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 2/2] support/scripts/graph-depends: add --quiet option
2018-04-01 19:14 ` [Buildroot] [PATCH 2/2] support/scripts/graph-depends: add --quiet option Peter Korsgaard
@ 2018-04-01 20:07 ` Thomas Petazzoni
2018-04-01 20:21 ` Peter Korsgaard
2018-04-01 20:24 ` Yann E. MORIN
2 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2018-04-01 20:07 UTC (permalink / raw)
To: buildroot
Hello,
On Sun, 1 Apr 2018 21:14:49 +0200, Peter Korsgaard wrote:
> This will be useful for the upcoming recursive show-depends and
> show-rdepends features.
>
> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Thomas
--
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module
2018-04-01 19:14 [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module Peter Korsgaard
2018-04-01 19:14 ` [Buildroot] [PATCH 2/2] support/scripts/graph-depends: add --quiet option Peter Korsgaard
2018-04-01 20:07 ` [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module Thomas Petazzoni
@ 2018-04-01 20:21 ` Peter Korsgaard
2018-04-01 20:24 ` Yann E. MORIN
3 siblings, 0 replies; 8+ messages in thread
From: Peter Korsgaard @ 2018-04-01 20:21 UTC (permalink / raw)
To: buildroot
>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:
> Instead of hardcoded sys.stderr.write() calls. No functional change, but
> allows us to easily implement a quiet option.
> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Committed, thanks.
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 2/2] support/scripts/graph-depends: add --quiet option
2018-04-01 19:14 ` [Buildroot] [PATCH 2/2] support/scripts/graph-depends: add --quiet option Peter Korsgaard
2018-04-01 20:07 ` Thomas Petazzoni
@ 2018-04-01 20:21 ` Peter Korsgaard
2018-04-01 20:24 ` Yann E. MORIN
2 siblings, 0 replies; 8+ messages in thread
From: Peter Korsgaard @ 2018-04-01 20:21 UTC (permalink / raw)
To: buildroot
>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:
> This will be useful for the upcoming recursive show-depends and
> show-rdepends features.
> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Committed, thanks.
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module
2018-04-01 19:14 [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module Peter Korsgaard
` (2 preceding siblings ...)
2018-04-01 20:21 ` Peter Korsgaard
@ 2018-04-01 20:24 ` Yann E. MORIN
3 siblings, 0 replies; 8+ messages in thread
From: Yann E. MORIN @ 2018-04-01 20:24 UTC (permalink / raw)
To: buildroot
Peter, All,
On 2018-04-01 21:14 +0200, Peter Korsgaard spake thusly:
> Instead of hardcoded sys.stderr.write() calls. No functional change, but
> allows us to easily implement a quiet option.
>
> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Thank you! :-)
Regards,
Yann E. MORIN.
> ---
> support/scripts/brpkgutil.py | 13 +++++++------
> support/scripts/graph-depends | 16 ++++++++++------
> 2 files changed, 17 insertions(+), 12 deletions(-)
>
> diff --git a/support/scripts/brpkgutil.py b/support/scripts/brpkgutil.py
> index 4c99ae9110..e70d525353 100644
> --- a/support/scripts/brpkgutil.py
> +++ b/support/scripts/brpkgutil.py
> @@ -1,5 +1,6 @@
> # Copyright (C) 2010-2013 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>
> +import logging
> import sys
> import subprocess
>
> @@ -7,18 +8,18 @@ import subprocess
> # Execute the "make <pkg>-show-version" command to get the version of a given
> # list of packages, and return the version formatted as a Python dictionary.
> def get_version(pkgs):
> - sys.stderr.write("Getting version for %s\n" % pkgs)
> + logging.info("Getting version for %s" % pkgs)
> cmd = ["make", "-s", "--no-print-directory"]
> for pkg in pkgs:
> cmd.append("%s-show-version" % pkg)
> p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
> output = p.communicate()[0]
> if p.returncode != 0:
> - sys.stderr.write("Error getting version %s\n" % pkgs)
> + logging.error("Error getting version %s" % pkgs)
> sys.exit(1)
> output = output.split("\n")
> if len(output) != len(pkgs) + 1:
> - sys.stderr.write("Error getting version\n")
> + logging.error("Error getting version")
> sys.exit(1)
> version = {}
> for i in range(0, len(pkgs)):
> @@ -28,18 +29,18 @@ def get_version(pkgs):
>
>
> def _get_depends(pkgs, rule):
> - sys.stderr.write("Getting dependencies for %s\n" % pkgs)
> + logging.info("Getting dependencies for %s" % pkgs)
> cmd = ["make", "-s", "--no-print-directory"]
> for pkg in pkgs:
> cmd.append("%s-%s" % (pkg, rule))
> p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
> output = p.communicate()[0]
> if p.returncode != 0:
> - sys.stderr.write("Error getting dependencies %s\n" % pkgs)
> + logging.error("Error getting dependencies %s\n" % pkgs)
> sys.exit(1)
> output = output.split("\n")
> if len(output) != len(pkgs) + 1:
> - sys.stderr.write("Error getting dependencies\n")
> + logging.error("Error getting dependencies")
> sys.exit(1)
> deps = {}
> for i in range(0, len(pkgs)):
> diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends
> index dc265ae28c..17bfaa0cf5 100755
> --- a/support/scripts/graph-depends
> +++ b/support/scripts/graph-depends
> @@ -21,6 +21,7 @@
> #
> # Copyright (C) 2010-2013 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>
> +import logging
> import sys
> import subprocess
> import argparse
> @@ -39,7 +40,7 @@ allpkgs = []
> # Buildroot PACKAGES and return it formatted as a Python list. This
> # list is used as the starting point for full dependency graphs
> def get_targets():
> - sys.stderr.write("Getting targets\n")
> + logging.info("Getting targets")
> cmd = ["make", "-s", "--no-print-directory", "show-targets"]
> p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
> output = p.communicate()[0].strip()
> @@ -192,10 +193,10 @@ def check_circular_deps(deps):
> chain.append(pkg)
> for p in deps[pkg]:
> if p in chain:
> - sys.stderr.write("\nRecursion detected for : %s\n" % (p))
> + logging.warning("\nRecursion detected for : %s" % (p))
> while True:
> _p = chain.pop()
> - sys.stderr.write("which is a dependency of: %s\n" % (_p))
> + logging.warning("which is a dependency of: %s" % (_p))
> if p == _p:
> sys.exit(1)
> recurse(p)
> @@ -319,11 +320,14 @@ def main():
>
> check_only = args.check_only
>
> + logging.basicConfig(stream=sys.stderr, format='%(message)s',
> + level=logging.INFO)
> +
> if args.outfile is None:
> outfile = sys.stdout
> else:
> if check_only:
> - sys.stderr.write("don't specify outfile and check-only at the same time\n")
> + logging.error("don't specify outfile and check-only at the same time")
> sys.exit(1)
> outfile = open(args.outfile, "w")
>
> @@ -348,7 +352,7 @@ def main():
> arrow_dir = "forward"
> else:
> if mode == MODE_FULL:
> - sys.stderr.write("--reverse needs a package\n")
> + logging.error("--reverse needs a package")
> sys.exit(1)
> get_depends_func = brpkgutil.get_rdepends
> arrow_dir = "back"
> @@ -358,7 +362,7 @@ def main():
> # We'll let 'dot' validate the colors...
> colors = args.colors.split(',', 4)
> if len(colors) != 3:
> - sys.stderr.write("Error: incorrect color list '%s'\n" % args.colors)
> + logging.error("Error: incorrect color list '%s'" % args.colors)
> sys.exit(1)
>
> # In full mode, start with the result of get_targets() to get the main
> --
> 2.11.0
>
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 2/2] support/scripts/graph-depends: add --quiet option
2018-04-01 19:14 ` [Buildroot] [PATCH 2/2] support/scripts/graph-depends: add --quiet option Peter Korsgaard
2018-04-01 20:07 ` Thomas Petazzoni
2018-04-01 20:21 ` Peter Korsgaard
@ 2018-04-01 20:24 ` Yann E. MORIN
2 siblings, 0 replies; 8+ messages in thread
From: Yann E. MORIN @ 2018-04-01 20:24 UTC (permalink / raw)
To: buildroot
Peter, All,
On 2018-04-01 21:14 +0200, Peter Korsgaard spake thusly:
> This will be useful for the upcoming recursive show-depends and
> show-rdepends features.
>
> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Regards,
Yann E. MORIN.
> ---
> support/scripts/graph-depends | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends
> index 17bfaa0cf5..4ec0e46f7b 100755
> --- a/support/scripts/graph-depends
> +++ b/support/scripts/graph-depends
> @@ -312,6 +312,8 @@ def parse_args():
> help="Draw direct dependencies (the default)")
> parser.add_argument("--reverse", dest="direct", action='store_false',
> help="Draw reverse dependencies")
> + parser.add_argument("--quiet", '-q', dest="quiet", action='store_true',
> + help="Quiet")
> return parser.parse_args()
>
>
> @@ -321,7 +323,7 @@ def main():
> check_only = args.check_only
>
> logging.basicConfig(stream=sys.stderr, format='%(message)s',
> - level=logging.INFO)
> + level=logging.WARNING if args.quiet else logging.INFO)
>
> if args.outfile is None:
> outfile = sys.stdout
> --
> 2.11.0
>
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-04-01 20:24 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-01 19:14 [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module Peter Korsgaard
2018-04-01 19:14 ` [Buildroot] [PATCH 2/2] support/scripts/graph-depends: add --quiet option Peter Korsgaard
2018-04-01 20:07 ` Thomas Petazzoni
2018-04-01 20:21 ` Peter Korsgaard
2018-04-01 20:24 ` Yann E. MORIN
2018-04-01 20:07 ` [Buildroot] [PATCH 1/2] support/scripts/graph-depends: use the standard python logging module Thomas Petazzoni
2018-04-01 20:21 ` Peter Korsgaard
2018-04-01 20:24 ` Yann E. MORIN
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.