[virt-manager] [PATCH 5/5] pycodestyle: Use module instead of executable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The `pycodestyle-3` executable is provided by the
`python3-pycodestyle` rpm package.
On Debian the corresponding executable is called `pycodestyle3`.
Arch Linux uses Python 3 by default and `python2-pycodestyle`
package is used for the py2 version.

To get around this inconsistency, import the `pycodestyle` module and
call the corresponding methods. The implementation has similar
behaviour to what happens when `pycodestyle` [1] is executed from the
command-line.

[1] https://github.com/PyCQA/pycodestyle/blob/master/pycodestyle.py

Signed-off-by: Radostin Stoyanov <rstoyanov1@xxxxxxxxx>
---
 setup.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/setup.py b/setup.py
index 33a1b478..b545dd85 100755
--- a/setup.py
+++ b/setup.py
@@ -582,6 +582,7 @@ class CheckPylint(distutils.core.Command):
 
     def run(self):
         import pylint.lint
+        import pycodestyle
 
         files = ["setup.py", "virt-install", "virt-clone",
                  "virt-convert", "virt-xml", "virt-manager",
@@ -592,11 +593,16 @@ class CheckPylint(distutils.core.Command):
         exclude = ["virtinst/progress.py"]
 
         print("running pycodestyle")
-        cmd = "pycodestyle-3 "
-        cmd += "--config tests/pycodestyle.cfg "
-        cmd += "--exclude %s " % ",".join(exclude)
-        cmd += " ".join(files)
-        os.system(cmd)
+        style_guide = pycodestyle.StyleGuide(
+            config_file='tests/pycodestyle.cfg',
+            paths=files
+        )
+        style_guide.options.exclude = pycodestyle.normalize_paths(
+            ','.join(exclude)
+        )
+        report = style_guide.check_files()
+        if style_guide.options.count:
+            sys.stderr.write(str(report.total_errors) + '\n')
 
         print("running pylint")
         pylint_opts = [
-- 
2.14.3

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux