rteval-cmd: If no kernel version is provided to -S/--source-download, download default kernel version
PATCH 1/1 rteval-cmd: If no kernel version is provided to -S/--source-download, download default kernel version
Previously, the usuage was "./rteval-cmd -S [KERNEL_VERSION]", and rteval-cmd would throw an error if no kernel version was provided. Now, rteval-cmd will download the default kernel version, as specified in rteval/modules/loads/kcompile.py.
--- rteval-cmd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
rteval-cmd +6 -4
@@ -168,11 +168,13 @@ def parse_options(cfg, parser, cmdargs): help='print rteval version and exit') # if the -S/--source-download option doesn't include the version, set version to default ind = None - if sys.argv.count("-S") > 0: ind = sys.argv.index("-S") - elif sys.argv.count("--source-download") > 0: ind = sys.argv.index("--source-download") + if sys.argv.count("-S") > 0: + ind = sys.argv.index("-S") + elif sys.argv.count("--source-download") > 0: + ind = sys.argv.index("--source-download") if ind != None: - if ind+1 == len(sys.argv): - sys.argv.insert(ind+1, ModuleParameters()["source"]["default"].strip(".tar.xz")) + if ind+1 == len(sys.argv): + sys.argv.insert(ind+1, ModuleParameters()["source"]["default"].replace(".tar.xz", "")) cmdargs.append(sys.argv[ind+1]) parser.add_option("-S", "--source-download", dest="rteval___srcdownload",
Signature · 1 line
2.31.1
PATCH 1/1 rteval: osinfo.py: Added code to use 'sos report' instead of sosreport.
sosreport is deprecated, so if available on the system osinfo will try to use the sos command instead.
--- rteval/sysinfo/osinfo.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
rteval/sysinfo/osinfo.py +6 -4
@@ -62,12 +62,14 @@ class OSInfo: def run_sysreport(self, repdir): - if os.path.exists('/usr/sbin/sosreport'): + if os.path.exists('/usr/sbin/sos'): + exe = '/usr/sbin/sos report' + elif os.path.exists('/usr/sbin/sosreport'): exe = '/usr/sbin/sosreport' elif os.path.exists('/usr/sbin/sysreport'): exe = '/usr/sbin/sysreport' else: - raise RuntimeError("Can't find sosreport/sysreport") + raise RuntimeError("Can't find sos/sosreport/sysreport") self.__logger.log(Log.DEBUG, f"report tool: {exe}") options = ['-k', 'rpm.rpmva=off',
@@ -75,8 +77,8 @@ class OSInfo: '--batch'] self.__logger.log(Log.INFO, "Generating SOS report") - self.__logger.log(Log.INFO, f"using command {' '.join([exe]+options)}") - subprocess.call([exe] + options) + self.__logger.log(Log.INFO, f"using command {' '.join(exe.split()+options)}") + subprocess.call(exe.split() + options) for s in glob('/tmp/s?sreport-rteval-*'): self.__logger.log(Log.DEBUG, f"moving {s} to {repdir}") shutil.move(s, repdir)
Signature · 1 line
2.31.1
Re: [PATCH] rteval: osinfo.py: Added code to use 'sos report' instead of sosreport.
Quoted 44 lines · Anubhav Shelat
sosreport is deprecated, so if available on the system osinfo will try to use the sos command instead.
Signed-off-by Anubhav Shelat <[email protected]>--- rteval/sysinfo/osinfo.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)rteval/sysinfo/osinfo.py +6
-4@@ -62,12 +62,14 @@ class OSInfo: def run_sysreport(self, repdir): - if os.path.exists('/usr/sbin/sosreport'): + if os.path.exists('/usr/sbin/sos'): + exe = '/usr/sbin/sos report' + elif os.path.exists('/usr/sbin/sosreport'): exe = '/usr/sbin/sosreport' elif os.path.exists('/usr/sbin/sysreport'): exe = '/usr/sbin/sysreport' else: - raise RuntimeError("Can't find sosreport/sysreport") + raise RuntimeError("Can't find sos/sosreport/sysreport") self.__logger.log(Log.DEBUG, f"report tool: {exe}") options = ['-k', 'rpm.rpmva=off',@@ -75,8 +77,8 @@ class OSInfo: '--batch'] self.__logger.log(Log.INFO, "Generating SOS report") - self.__logger.log(Log.INFO, f"using command {' '.join([exe]+options)}") - subprocess.call([exe] + options) + self.__logger.log(Log.INFO, f"using command {' '.join(exe.split()+options)}") + subprocess.call(exe.split() + options) for s in glob('/tmp/s?sreport-rteval-*'): self.__logger.log(Log.DEBUG, f"moving {s} to {repdir}") shutil.move(s, repdir)Signature · 1 line
2.31.1
Quoted 36 lines · Anubhav Shelat
Previously, the usuage was "./rteval-cmd -S [
KERNEL_VERSION]", and rteval-cmd would throw an error if no kernel version was provided. Now, rteval-cmd will download the default kernel version, as specified inrteval/modules/loads/kcompile.py.Signed-off-by Anubhav Shelat <[email protected]>--- rteval-cmd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)rteval-cmd +6
-4@@ -168,11 +168,13 @@ def parse_options(cfg, parser, cmdargs): help='print rteval version and exit') # if the -S/--source-download option doesn't include the version, set version to default ind = None - if sys.argv.count("-S") > 0: ind = sys.argv.index("-S") - elif sys.argv.count("--source-download") > 0: ind = sys.argv.index("--source-download") + if sys.argv.count("-S") > 0: + ind = sys.argv.index("-S") + elif sys.argv.count("--source-download") > 0: + ind = sys.argv.index("--source-download") if ind != None: - if ind+1 == len(sys.argv): - sys.argv.insert(ind+1, ModuleParameters()["source"]["default"].strip(".tar.xz")) + if ind+1 == len(sys.argv): + sys.argv.insert(ind+1, ModuleParameters()["source"]["default"].replace(".tar.xz", "")) cmdargs.append(sys.argv[ind+1]) parser.add_option("-S", "--source-download", dest="rteval___srcdownload",Signature · 1 line
2.31.1
This patch works and does something that I would like to have. However the point of parsers like optparse and argparse are to hide sys.argv kind of details. I am wondering if there is something you can do with nargs in order to make this work in a cleaner fashion.
I know you are working on converting deprecated optparse to argparse, so I would suggest that instead of fixing this here, finish your argparse work, and then try to reimplement this on top of that once it is accepted upstream.
Thanks
John