Skip to contentSkip to conversation

runqemu: formatting cleanups suggested by PyLint

PATCH In review Ross Burton 3 participants 3 messages Dec 14, 2018 – Dec 15, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 runqemu: formatting cleanups suggested by PyLint

Mostly whitespace fixes but also some r"" strings to clarify regular expressions.

---
 meta/lib/oe/package_manager.py | 97 +++++++++++++++++-------------------------
 scripts/runqemu                | 46 ++++++++++----------
 2 files changed, 61 insertions(+), 82 deletions(-)
meta/lib/oe/package_manager.py +38 -59
index 92a98e2a8df..f08190efc0d 100644
@@ -185,7 +185,6 @@ class OpkgIndexer(Indexer):
                      "SDK_PACKAGE_ARCHS",
                     ]
 
-        opkg_index_cmd = bb.utils.which(os.getenv('PATH'), "opkg-make-index")
         if self.d.getVar('PACKAGE_FEED_SIGN') == '1':
             signer = get_signer(self.d, self.d.getVar('PACKAGE_FEED_GPG_BACKEND'))
         else:
@@ -211,8 +210,8 @@ class OpkgIndexer(Indexer):
                 if not os.path.exists(pkgs_file):
                     open(pkgs_file, "w").close()
 
-                index_cmds.add('%s -r %s -p %s -m %s' %
-                               (opkg_index_cmd, pkgs_file, pkgs_file, pkgs_dir))
+                index_cmds.add('opkg-make-index -r %s -p %s -m %s' %
+                               (pkgs_file, pkgs_file, pkgs_dir))
 
                 index_sign_files.add(pkgs_file)
 
@@ -271,9 +270,6 @@ class DpkgIndexer(Indexer):
         all_mlb_pkg_arch_list = (self.d.getVar('ALL_MULTILIB_PACKAGE_ARCHS') or "").split()
         arch_list.extend(arch for arch in all_mlb_pkg_arch_list if arch not in arch_list)
 
-        apt_ftparchive = bb.utils.which(os.getenv('PATH'), "apt-ftparchive")
-        gzip = bb.utils.which(os.getenv('PATH'), "gzip")
-
         index_cmds = []
         deb_dirs_found = False
         for arch in arch_list:
@@ -281,14 +277,13 @@ class DpkgIndexer(Indexer):
             if not os.path.isdir(arch_dir):
                 continue
 
-            cmd = "cd %s; PSEUDO_UNLOAD=1 %s packages . > Packages;" % (arch_dir, apt_ftparchive)
-
-            cmd += "%s -fcn Packages > Packages.gz;" % gzip
+            cmd = "cd %s; PSEUDO_UNLOAD=1 apt-ftparchive packages . > Packages;" % (arch_dir)
+            cmd += "gzip -fcn Packages > Packages.gz;"
 
             with open(os.path.join(arch_dir, "Release"), "w+") as release:
                 release.write("Label: %s\n" % arch)
 
-            cmd += "PSEUDO_UNLOAD=1 %s release . >> Release" % apt_ftparchive
+            cmd += "PSEUDO_UNLOAD=1 apt-ftparchive release . >> Release"
 
             index_cmds.append(cmd)
 
@@ -321,12 +316,11 @@ class OpkgPkgsList(PkgsList):
     def __init__(self, d, rootfs_dir, config_file):
         super(OpkgPkgsList, self).__init__(d, rootfs_dir)
 
-        self.opkg_cmd = bb.utils.which(os.getenv('PATH'), "opkg")
         self.opkg_args = "-f %s -o %s " % (config_file, rootfs_dir)
         self.opkg_args += self.d.getVar("OPKG_ARGS")
 
     def list_pkgs(self, format=None):
-        cmd = "%s %s status" % (self.opkg_cmd, self.opkg_args)
+        cmd = "opkg %s status" % (self.opkg_args)
 
         # opkg returns success even when it printed some
         # "Collected errors:" report to stderr. Mixing stderr into
@@ -347,7 +341,7 @@ class OpkgPkgsList(PkgsList):
 class DpkgPkgsList(PkgsList):
 
     def list_pkgs(self):
-        cmd = [bb.utils.which(os.getenv('PATH'), "dpkg-query"),
+        cmd = ["dpkg-query",
                "--admindir=%s/var/lib/dpkg" % self.rootfs_dir,
                "-W"]
 
@@ -783,8 +777,7 @@ class RpmPM(PackageManager):
             signer = get_signer(self.d, self.d.getVar('RPM_GPG_BACKEND'))
             pubkey_path = oe.path.join(self.d.getVar('B'), 'rpm-key')
             signer.export_pubkey(pubkey_path, self.d.getVar('RPM_GPG_NAME'))
-            rpm_bin = bb.utils.which(os.getenv('PATH'), "rpmkeys")
-            cmd = [rpm_bin, '--root=%s' % self.target_rootfs, '--import', pubkey_path]
+            cmd = ['rpmkeys', '--root=%s' % self.target_rootfs, '--import', pubkey_path]
             try:
                 subprocess.check_output(cmd, stderr=subprocess.STDOUT)
             except subprocess.CalledProcessError as e:
@@ -874,8 +867,7 @@ class RpmPM(PackageManager):
         if with_dependencies:
             self._invoke_dnf(["remove"] + pkgs)
         else:
-            cmd = bb.utils.which(os.getenv('PATH'), "rpm")
-            args = ["-e", "-v", "--nodeps", "--root=%s" %self.target_rootfs]
+            args = ["rpm", "-e", "-v", "--nodeps", "--root=%s" %self.target_rootfs]
 
             try:
                 bb.note("Running %s" % ' '.join([cmd] + args + pkgs))
@@ -960,8 +952,8 @@ class RpmPM(PackageManager):
     def _invoke_dnf(self, dnf_args, fatal=True, print_output=True):
         os.environ['RPM_ETCCONFIGDIR'] = self.target_rootfs
 
-        dnf_cmd = bb.utils.which(os.getenv('PATH'), "dnf")
-        standard_dnf_args = ["-v", "--rpmverbosity=debug", "-y",
+        standard_dnf_args = ["dnf",
+                             "-v", "--rpmverbosity=debug", "-y",
                              "-c", oe.path.join(self.target_rootfs, "etc/dnf/dnf.conf"),
                              "--setopt=reposdir=%s" % (oe.path.join(self.target_rootfs, "etc/yum.repos.d")),
                              "--installroot=%s" % (self.target_rootfs),
@@ -969,7 +961,7 @@ class RpmPM(PackageManager):
                             ]
         if hasattr(self, "rpm_repo_dir"):
             standard_dnf_args.append("--repofrompath=oe-repo,%s" % (self.rpm_repo_dir))
-        cmd = [dnf_cmd] + standard_dnf_args + dnf_args
+        cmd = standard_dnf_args + dnf_args
         bb.note('Running %s' % ' '.join(cmd))
         try:
             output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode("utf-8")
@@ -1005,14 +997,13 @@ class RpmPM(PackageManager):
 
     def save_rpmpostinst(self, pkg):
         bb.note("Saving postinstall script of %s" % (pkg))
-        cmd = bb.utils.which(os.getenv('PATH'), "rpm")
-        args = ["-q", "--root=%s" % self.target_rootfs, "--queryformat", "%{postin}", pkg]
+        args = ["rpm", "-q", "--root=%s" % self.target_rootfs, "--queryformat", "%{postin}", pkg]
 
         try:
-            output = subprocess.check_output([cmd] + args, stderr=subprocess.STDOUT).decode("utf-8")
+            output = subprocess.check_output(args, stderr=subprocess.STDOUT).decode("utf-8")
         except subprocess.CalledProcessError as e:
             bb.fatal("Could not invoke rpm. Command "
-                     "'%s' returned %d:\n%s" % (' '.join([cmd] + args), e.returncode, e.output.decode("utf-8")))
+                     "'%s' returned %d:\n%s" % (' '.join(args), e.returncode, e.output.decode("utf-8")))
 
         # may need to prepend #!/bin/sh to output
 
@@ -1038,9 +1029,6 @@ class RpmPM(PackageManager):
             bb.fatal("dnf could not find package %s in repository: %s" %(pkg, output))
         pkg_path = oe.path.join(self.rpm_repo_dir, pkg_name)
 
-        cpio_cmd = bb.utils.which(os.getenv("PATH"), "cpio")
-        rpm2cpio_cmd = bb.utils.which(os.getenv("PATH"), "rpm2cpio")
-
         if not os.path.isfile(pkg_path):
             bb.fatal("Unable to extract package for '%s'."
                      "File %s doesn't exists" % (pkg, pkg_path))
@@ -1050,7 +1038,7 @@ class RpmPM(PackageManager):
         os.chdir(tmp_dir)
 
         try:
-            cmd = "%s %s | %s -idmv" % (rpm2cpio_cmd, pkg_path, cpio_cmd)
+            cmd = "rpm2cpio %s | cpio -idmv" % (pkg_path)
             output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
         except subprocess.CalledProcessError as e:
             bb.utils.remove(tmp_dir, recurse=True)
@@ -1097,10 +1085,7 @@ class OpkgDpkgPM(PackageManager):
         This method extracts the common parts for Opkg and Dpkg
         """
 
-        ar_cmd = bb.utils.which(os.getenv("PATH"), "ar")
-        tar_cmd = bb.utils.which(os.getenv("PATH"), "tar")
         pkg_path = pkg_info[pkg]["filepath"]
-
         if not os.path.isfile(pkg_path):
             bb.fatal("Unable to extract package for '%s'."
                      "File %s doesn't exists" % (pkg, pkg_path))
@@ -1114,10 +1099,10 @@ class OpkgDpkgPM(PackageManager):
             data_tar = 'data.tar.gz'
 
         try:
-            cmd = [ar_cmd, 'x', pkg_path]
-            output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
-            cmd = [tar_cmd, 'xf', data_tar]
-            output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+            cmd = ['ar', 'x', pkg_path]
+            subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+            cmd = ['tar', 'xf', data_tar]
+            subprocess.check_output(cmd, stderr=subprocess.STDOUT)
         except subprocess.CalledProcessError as e:
             bb.utils.remove(tmp_dir, recurse=True)
             bb.fatal("Unable to extract %s package. Command '%s' "
@@ -1147,7 +1132,6 @@ class OpkgPM(OpkgDpkgPM):
 
         self.deploy_dir = oe.path.join(self.d.getVar('WORKDIR'), ipk_repo_workdir)
         self.deploy_lock_file = os.path.join(self.deploy_dir, "deploy.lock")
-        self.opkg_cmd = bb.utils.which(os.getenv('PATH'), "opkg")
         self.opkg_args = "--volatile-cache -f %s -t %s -o %s " % (self.config_file, self.d.expand('${T}/ipktemp/'), target_rootfs)
         self.opkg_args += self.d.getVar("OPKG_ARGS")
 
@@ -1308,7 +1292,7 @@ class OpkgPM(OpkgDpkgPM):
     def update(self):
         self.deploy_dir_lock()
 
-        cmd = "%s %s update" % (self.opkg_cmd, self.opkg_args)
+        cmd = "opkg %s update" % (self.opkg_args)
 
         try:
             subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
@@ -1323,7 +1307,7 @@ class OpkgPM(OpkgDpkgPM):
         if not pkgs:
             return
 
-        cmd = "%s %s" % (self.opkg_cmd, self.opkg_args)
+        cmd = "opkg %s" % (self.opkg_args)
         for exclude in (self.d.getVar("PACKAGE_EXCLUDE") or "").split():
             cmd += " --add-exclude %s" % exclude
         cmd += " install "
@@ -1358,11 +1342,11 @@ class OpkgPM(OpkgDpkgPM):
             return
 
         if with_dependencies:
-            cmd = "%s %s --force-remove --force-removal-of-dependent-packages remove %s" % \
-                (self.opkg_cmd, self.opkg_args, ' '.join(pkgs))
+            cmd = "opkg %s --force-remove --force-removal-of-dependent-packages remove %s" % \
+                (self.opkg_args, ' '.join(pkgs))
         else:
-            cmd = "%s %s --force-depends remove %s" % \
-                (self.opkg_cmd, self.opkg_args, ' '.join(pkgs))
+            cmd = "opkg %s --force-depends remove %s" % \
+                (self.opkg_args, ' '.join(pkgs))
 
         try:
             bb.note(cmd)
@@ -1406,7 +1390,7 @@ class OpkgPM(OpkgDpkgPM):
         if os.path.exists(status_file):
             return
 
-        cmd = "%s %s info " % (self.opkg_cmd, self.opkg_args)
+        cmd = "opkg %s info " % (self.opkg_args)
 
         with open(status_file, "w+") as status:
             for pkg in bad_recommendations.split():
@@ -1451,7 +1435,7 @@ class OpkgPM(OpkgDpkgPM):
         opkg_args = "-f %s -o %s " % (self.config_file, temp_rootfs)
         opkg_args += self.d.getVar("OPKG_ARGS")
 
-        cmd = "%s %s update" % (self.opkg_cmd, opkg_args)
+        cmd = "opkg %s update" % (opkg_args)
         try:
             subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
         except subprocess.CalledProcessError as e:
@@ -1459,9 +1443,7 @@ class OpkgPM(OpkgDpkgPM):
                      "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
 
         # Dummy installation
-        cmd = "%s %s --noaction install %s " % (self.opkg_cmd,
-                                                opkg_args,
-                                                ' '.join(pkgs))
+        cmd = "opkg %s --noaction install %s " % (opkg_args, ' '.join(pkgs))
         try:
             output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
         except subprocess.CalledProcessError as e:
@@ -1495,7 +1477,7 @@ class OpkgPM(OpkgDpkgPM):
         """
         Returns a dictionary with the package info.
         """
-        cmd = "%s %s info %s" % (self.opkg_cmd, self.opkg_args, pkg)
+        cmd = "opkg %s info %s" % (self.opkg_args, pkg)
         pkg_info = super(OpkgPM, self).package_info(pkg, cmd)
 
         pkg_arch = pkg_info[pkg]["arch"]
@@ -1533,8 +1515,6 @@ class DpkgPM(OpkgDpkgPM):
         else:
             self.apt_conf_dir = apt_conf_dir
         self.apt_conf_file = os.path.join(self.apt_conf_dir, "apt.conf")
-        self.apt_get_cmd = bb.utils.which(os.getenv('PATH'), "apt-get")
-        self.apt_cache_cmd = bb.utils.which(os.getenv('PATH'), "apt-cache")
 
         self.apt_args = d.getVar("APT_ARGS")
 
@@ -1624,7 +1604,7 @@ class DpkgPM(OpkgDpkgPM):
 
         self.deploy_dir_lock()
 
-        cmd = "%s update" % self.apt_get_cmd
+        cmd = "apt-get update"
 
         try:
             subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
@@ -1640,8 +1620,8 @@ class DpkgPM(OpkgDpkgPM):
 
         os.environ['APT_CONFIG'] = self.apt_conf_file
 
-        cmd = "%s %s install --force-yes --allow-unauthenticated %s" % \
-              (self.apt_get_cmd, self.apt_args, ' '.join(pkgs))
+        cmd = "apt-get %s install --force-yes --allow-unauthenticated %s" % \
+              (self.apt_args, ' '.join(pkgs))
 
         try:
             bb.note("Installing the following packages: %s" % ' '.join(pkgs))
@@ -1672,12 +1652,11 @@ class DpkgPM(OpkgDpkgPM):
 
         if with_dependencies:
             os.environ['APT_CONFIG'] = self.apt_conf_file
-            cmd = "%s purge %s" % (self.apt_get_cmd, ' '.join(pkgs))
+            cmd = "apt-get purge %s" % (' '.join(pkgs))
         else:
-            cmd = "%s --admindir=%s/var/lib/dpkg --instdir=%s" \
+            cmd = "dpkg --admindir=%s/var/lib/dpkg --instdir=%s" \
                   " -P --force-depends %s" % \
-                  (bb.utils.which(os.getenv('PATH'), "dpkg"),
-                   self.target_rootfs, self.target_rootfs, ' '.join(pkgs))
+                  (self.target_rootfs, self.target_rootfs, ' '.join(pkgs))
 
         try:
             subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
@@ -1809,7 +1788,7 @@ class DpkgPM(OpkgDpkgPM):
     def fix_broken_dependencies(self):
         os.environ['APT_CONFIG'] = self.apt_conf_file
 
-        cmd = "%s %s -f install" % (self.apt_get_cmd, self.apt_args)
+        cmd = "apt-get %s -f install" % (self.apt_args)
 
         try:
             subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
@@ -1824,7 +1803,7 @@ class DpkgPM(OpkgDpkgPM):
         """
         Returns a dictionary with the package info.
         """
-        cmd = "%s show %s" % (self.apt_cache_cmd, pkg)
+        cmd = "apt-cache show %s" % (pkg)
         pkg_info = super(DpkgPM, self).package_info(pkg, cmd)
 
         pkg_arch = pkg_info[pkg]["pkgarch"]
scripts/runqemu +23 -23

111 lines not on this page · raw message

Signature · 1 line
2.11.0
#1 lore raw

✗ patchtest: failure for runqemu: formatting cleanups suggested by PyLint

== Series Details ==

Series: runqemu: formatting cleanups suggested by PyLint
Revision: 1
URL : https://patchwork.openembedded.org/series/15350/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at 6408b4b908)

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe
#2 lore raw
In reply to Ross Burton
Quoted 9 lines · Ross Burton

Mostly whitespace fixes but also some r"" strings to clarify regular expressions.

---
 meta/lib/oe/package_manager.py | 97 +++++++++++++++++---------------
----------
 scripts/runqemu                | 46 ++++++++++----------
 2 files changed, 61 insertions(+), 82 deletions(-)

I think your patches got a little confused!

(2 files, not 1)

Cheers,

Richard