* [Buildroot] [PATCH] support/scripts/pkg-stats: add tilde '~' expansion for pathes
@ 2020-03-07 10:37 Heiko Thiery
2020-03-07 14:56 ` Thomas Petazzoni
2020-04-12 12:56 ` Thomas Petazzoni
0 siblings, 2 replies; 4+ messages in thread
From: Heiko Thiery @ 2020-03-07 10:37 UTC (permalink / raw)
To: buildroot
The script arguments 'nvd-path', 'json' and 'html' currently does not
allow to have '~' in path for user home directory. With this patch
this '~' is expanded to the real user home directory.
Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
---
support/scripts/pkg-stats | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 8a67e509e1..bfe3a3f8d4 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -861,12 +861,16 @@ def dump_json(packages, stats, date, commit, output):
f.write('\n')
+def resolvepath(path):
+ return os.path.abspath(os.path.expanduser(path))
+
+
def parse_args():
parser = argparse.ArgumentParser()
output = parser.add_argument_group('output', 'Output file(s)')
- output.add_argument('--html', dest='html', action='store',
+ output.add_argument('--html', dest='html', type=resolvepath,
help='HTML output file')
- output.add_argument('--json', dest='json', action='store',
+ output.add_argument('--json', dest='json', type=resolvepath,
help='JSON output file')
packages = parser.add_mutually_exclusive_group()
packages.add_argument('-n', dest='npackages', type=int, action='store',
@@ -874,7 +878,7 @@ def parse_args():
packages.add_argument('-p', dest='packages', action='store',
help='List of packages (comma separated)')
parser.add_argument('--nvd-path', dest='nvd_path',
- help='Path to the local NVD database')
+ help='Path to the local NVD database', type=resolvepath)
args = parser.parse_args()
if not args.html and not args.json:
parser.error('at least one of --html or --json (or both) is required')
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH] support/scripts/pkg-stats: add tilde '~' expansion for pathes
2020-03-07 10:37 [Buildroot] [PATCH] support/scripts/pkg-stats: add tilde '~' expansion for pathes Heiko Thiery
@ 2020-03-07 14:56 ` Thomas Petazzoni
2020-03-07 21:00 ` Heiko Thiery
2020-04-12 12:56 ` Thomas Petazzoni
1 sibling, 1 reply; 4+ messages in thread
From: Thomas Petazzoni @ 2020-03-07 14:56 UTC (permalink / raw)
To: buildroot
On Sat, 7 Mar 2020 11:37:05 +0100
Heiko Thiery <heiko.thiery@gmail.com> wrote:
> The script arguments 'nvd-path', 'json' and 'html' currently does not
> allow to have '~' in path for user home directory. With this patch
> this '~' is expanded to the real user home directory.
>
> Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
Isn't ~ supposed to be expanded by your shell before calling pkg-stats
? Here, pkg-stats --html ~/toto.html works perfectly fine without your
patch.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH] support/scripts/pkg-stats: add tilde '~' expansion for pathes
2020-03-07 14:56 ` Thomas Petazzoni
@ 2020-03-07 21:00 ` Heiko Thiery
0 siblings, 0 replies; 4+ messages in thread
From: Heiko Thiery @ 2020-03-07 21:00 UTC (permalink / raw)
To: buildroot
Hi Thomas,
Am Sa., 7. M?rz 2020 um 15:56 Uhr schrieb Thomas Petazzoni
<thomas.petazzoni@bootlin.com>:
>
> On Sat, 7 Mar 2020 11:37:05 +0100
> Heiko Thiery <heiko.thiery@gmail.com> wrote:
>
> > The script arguments 'nvd-path', 'json' and 'html' currently does not
> > allow to have '~' in path for user home directory. With this patch
> > this '~' is expanded to the real user home directory.
> >
> > Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
>
> Isn't ~ supposed to be expanded by your shell before calling pkg-stats
> ? Here, pkg-stats --html ~/toto.html works perfectly fine without your
> patch.
>
Indeed I didn't thought about that and you're right the shell should
expand that. But I saw that it was not.
I rechecked that and found out that there is a difference between
setting the argument of the option with or without a '='.
Without '=' the '~' is expanded by the shell (pkg-stats --html ~/out.html).
Wit '=' the '~' is not expanded by the shell (pkg-stats --html=~/out.html).
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
Heiko
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH] support/scripts/pkg-stats: add tilde '~' expansion for pathes
2020-03-07 10:37 [Buildroot] [PATCH] support/scripts/pkg-stats: add tilde '~' expansion for pathes Heiko Thiery
2020-03-07 14:56 ` Thomas Petazzoni
@ 2020-04-12 12:56 ` Thomas Petazzoni
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Petazzoni @ 2020-04-12 12:56 UTC (permalink / raw)
To: buildroot
On Sat, 7 Mar 2020 11:37:05 +0100
Heiko Thiery <heiko.thiery@gmail.com> wrote:
> The script arguments 'nvd-path', 'json' and 'html' currently does not
> allow to have '~' in path for user home directory. With this patch
> this '~' is expanded to the real user home directory.
>
> Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
> ---
> support/scripts/pkg-stats | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
Applied to master with an improved commit log to explain the difference
between --html=~/foo and --html ~/foo.
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-12 12:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-07 10:37 [Buildroot] [PATCH] support/scripts/pkg-stats: add tilde '~' expansion for pathes Heiko Thiery
2020-03-07 14:56 ` Thomas Petazzoni
2020-03-07 21:00 ` Heiko Thiery
2020-04-12 12:56 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox