pep8 job enable and fix pep8 reported issue

use flake8 as pep8 tools
enable check and gate for pep8(voting)
Fix below flake8 issues:
    E127 continuation line over-indented for visual indent
    E211 whitespace before '('
    E222 multiple spaces after operator
    E302 expected 2 blank lines, found 1
    E501 line too long (101 > 79 characters)
    E502 the backslash is redundant between brackets
    F401 'platform' imported but unused
    W391 blank line at end of file

Change-Id: Idfb953e52c8ee35c2adefdf0e4143a381c7f49e2
Story: 2003426
Task:  24596
Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
Sun Austin 2018-09-04 09:57:48 +08:00
parent fedb95ba79
commit 90ce692186
5 changed files with 29 additions and 19 deletions

View File

@ -2,9 +2,9 @@
- project:
check:
jobs:
- openstack-tox-pep8:
voting: false
- openstack-tox-linters
- openstack-tox-pep8
gate:
jobs:
- openstack-tox-linters
- openstack-tox-pep8

View File

@ -9,16 +9,17 @@ SPDX-License-Identifier: Apache-2.0
from __future__ import print_function
import getopt
import os
import platform
import subprocess
import sys
import xml.etree.ElementTree as ElementTree
def usage():
print("Usage: %s --groups <groups.xml> --pkgdir <pkgdir>" \
print("Usage: %s --groups <groups.xml> --pkgdir <pkgdir>"
% os.path.basename(sys.argv[0]))
exit(1)
def add_text_tag_to_xml(parent,
name,
text):
@ -108,18 +109,23 @@ def main():
usage()
# Get the pkglist
cmd = "find %s -name '*.rpm' | xargs rpm -qp --queryformat '%%{NAME}\n'" % pkgdir
cmd = "find %s -name '*.rpm' \
| xargs rpm -qp --queryformat '%%{NAME}\n'" % pkgdir
rpmlist = subprocess.check_output(cmd, shell=True).split()
tree = ElementTree.parse(groups_file)
comps = tree.getroot()
comps.tail = '\n'
add_group(comps, 'controller', rpmlist, filter_dir, 'filter_out_from_controller')
add_group(comps, 'controller-compute', rpmlist, filter_dir, 'filter_out_from_smallsystem')
add_group(comps, 'controller-compute-lowlatency', rpmlist, filter_dir, 'filter_out_from_smallsystem_lowlatency')
add_group(comps, 'controller', rpmlist,
filter_dir, 'filter_out_from_controller')
add_group(comps, 'controller-compute', rpmlist,
filter_dir, 'filter_out_from_smallsystem')
add_group(comps, 'controller-compute-lowlatency', rpmlist,
filter_dir, 'filter_out_from_smallsystem_lowlatency')
add_group(comps, 'compute', rpmlist, filter_dir, 'filter_out_from_compute')
add_group(comps, 'compute-lowlatency', rpmlist, filter_dir, 'filter_out_from_compute_lowlatency')
add_group(comps, 'compute-lowlatency', rpmlist,
filter_dir, 'filter_out_from_compute_lowlatency')
add_group(comps, 'storage', rpmlist, filter_dir, 'filter_out_from_storage')
add_group(comps, 'controller')
@ -134,4 +140,3 @@ def main():
if __name__ == "__main__":
main()

View File

@ -11,9 +11,9 @@ UDP_IP = socket.gethostbyname('controller')
UDP_PORT = 2188
ENV_MESSAGE = os.environ["MESSAGE"]
print ("UDP target IP:", UDP_IP)
print ("UDP target port:", UDP_PORT)
print ("message:", ENV_MESSAGE)
print("UDP target IP:", UDP_IP)
print("UDP target port:", UDP_PORT)
print("message:", ENV_MESSAGE)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(ENV_MESSAGE, (UDP_IP, UDP_PORT))

View File

@ -1,3 +1,4 @@
bashate >= 0.2
PyYAML >= 3.1.0
yamllint >= 0.5.2
flake8

12
tox.ini
View File

@ -1,5 +1,5 @@
[tox]
envlist = linters
envlist = linters,pep8
minversion = 2.3
skipsdist = True
@ -33,11 +33,15 @@ commands =
[testenv:pep8]
usedevelop = False
skip_install = True
deps =
pep8
flake8
description =
Run style checks
commands =
pep8
flake8
[flake8]
show-source = True
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-*
[testenv:venv]
commands = {posargs}