Skip to content

Commit

Permalink
Fix static check failure in travis CI due to pycodestyle change
Browse files Browse the repository at this point in the history
pycodestyle is default 2.9.0 by pip install, it will introduce some enchancement,
therefore it leads to static check failure in current code base

Signed-off-by: chunfuwen <[email protected]>
  • Loading branch information
chunfuwen committed Aug 2, 2022
1 parent 2de2d1e commit 10b597e
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion avocado_vt/plugins/vt_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _parameters_to_runnable(self, params):
# scalars, and will not be used in the context of nrunner
for key in ('_name_map_file', '_short_name_map_file', 'dep'):
if key in vt_params:
del(vt_params[key])
del (vt_params[key])

return Runnable('avocado-vt', uri, **vt_params)

Expand Down
8 changes: 4 additions & 4 deletions avocado_vt/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ def setUp(self):
finally:
# Clean libvirtd debug logs if the test is not fail or error
if self.params.get("libvirtd_log_cleanup", "no") == "yes":
if(self.params.get("vm_type") == 'libvirt' and
self.params.get("enable_libvirtd_debug_log", "yes") == "yes"):
if (self.params.get("vm_type") == 'libvirt' and
self.params.get("enable_libvirtd_debug_log", "yes") == "yes"):
libvirtd_log = self.params["libvirtd_debug_file"]
if("TestFail" not in str(self.__exc_info) and
"TestError" not in str(self.__exc_info)):
if ("TestFail" not in str(self.__exc_info) and
"TestError" not in str(self.__exc_info)):
if libvirtd_log and os.path.isfile(libvirtd_log):
self.log.info("cleaning libvirtd logs...")
os.remove(libvirtd_log)
Expand Down
4 changes: 2 additions & 2 deletions virttest/guest_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def __init__(self, cmd):
self.ecmd = cmd

def __str__(self):
return("The command %s is not supported by the current version qga"
% self.ecmd)
return ("The command %s is not supported by the current version qga"
% self.ecmd)


class VAgentSyncError(VAgentError):
Expand Down
2 changes: 1 addition & 1 deletion virttest/libvirt_xml/vm_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def set_vm_vcpus(vm_name, vcpus, current=None, sockets=None, cores=None,
if vcpus is not None:
if current is not None:
try:
if(int(current) > vcpus):
if (int(current) > vcpus):
raise xcepts.LibvirtXMLError("The cpu current value %s "
"is larger than max "
"number %s" % (current,
Expand Down
8 changes: 4 additions & 4 deletions virttest/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def __init__(self, params):
path.find_command("service")
path.find_command("exportfs")

if(params.get("setup_remote_nfs") == "yes" or
params.get("setup_local_nfs") == "yes"):
if (params.get("setup_remote_nfs") == "yes" or
params.get("setup_local_nfs") == "yes"):
if 'Ubuntu' in distro_details or 'rhel' in distro_details:
self.nfs_service = service.Service("nfs-server",
session=self.session)
Expand Down Expand Up @@ -247,8 +247,8 @@ def setup(self):
self.unexportfs_in_clean = not self.exportfs.already_exported

LOG.debug("Mount %s to %s" % (self.mount_src, self.mount_dir))
if(utils_misc.check_exists(self.mount_dir, session=self.session)
and not utils_misc.check_isdir(self.mount_dir, session=self.session)):
if (utils_misc.check_exists(self.mount_dir, session=self.session)
and not utils_misc.check_isdir(self.mount_dir, session=self.session)):
raise OSError(
"Mount point %s is not a directory, check your setup." %
self.mount_dir)
Expand Down
8 changes: 4 additions & 4 deletions virttest/ppm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ def image_verify_ppm_file(filename):
try:
size = os.path.getsize(filename)
with open(filename, "rb") as fin:
assert(fin.readline().strip() == b"P6")
assert (fin.readline().strip() == b"P6")
(width, height) = map(int, fin.readline().split())
assert(width > 0 and height > 0)
assert(fin.readline().strip() == b"255")
assert (width > 0 and height > 0)
assert (fin.readline().strip() == b"255")
size_read = fin.tell()
assert(size - size_read == width * height * 3)
assert (size - size_read == width * height * 3)
return True
except Exception:
return False
Expand Down
6 changes: 3 additions & 3 deletions virttest/qemu_devices/qdevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def set_param(self, option, value, option_type=None, dynamic=False):
else:
self.params[option] = value
elif value is None and option in self.params:
del(self.params[option])
del (self.params[option])
if option in self.dynamic_params:
self.dynamic_params.remove(option)

Expand All @@ -152,7 +152,7 @@ def __getitem__(self, option):

def __delitem__(self, option):
""" deletes self.params[option] """
del(self.params[option])
del (self.params[option])

def __len__(self):
""" length of self.params """
Expand Down Expand Up @@ -2371,7 +2371,7 @@ def remove(self, device):
remove = key
break
if remove is not None:
del(self.bus[remove])
del (self.bus[remove])
return True
return False

Expand Down
4 changes: 2 additions & 2 deletions virttest/qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3785,9 +3785,9 @@ def hotplug_vcpu(self, cpu_id=None, plug_command="", unplug=""):
else:
modified_vcpu_threads = vcpu_threads_count + add_remove_count
if len(self.vcpu_threads) == modified_vcpu_threads:
return(True, plug_cpu_id)
return (True, plug_cpu_id)
else:
return(False, cmd_output)
return (False, cmd_output)

@error_context.context_aware
def hotplug_vcpu_device(self, vcpu_id):
Expand Down
2 changes: 1 addition & 1 deletion virttest/shared/scripts/virtio_console_guest.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def init(self, in_files):
remove.append(port['name'])
print("Fail to open port %s" % port['name'])
for name in remove:
del(self.ports[name])
del (self.ports[name])

# Check if in_files count and system port count matches
# TODO: Not all devices are listed
Expand Down
8 changes: 4 additions & 4 deletions virttest/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,14 +721,14 @@ def copy_nfs_image(params, root_dir, basename=False):
# check for image availability in NFS shared path
base_dir = params["nfs_mount_dir"]
dst = get_image_filename(params, base_dir, basename=basename)
if(not os.path.isfile(dst) or
utils_misc.get_image_info(dst)['lcounts'].lower() == "true"):
if (not os.path.isfile(dst) or
utils_misc.get_image_info(dst)['lcounts'].lower() == "true"):
source = get_image_filename(params, root_dir)
LOG.debug("Checking for image available in image data "
"path - %s", source)
# check for image availability in images data directory
if(os.path.isfile(source) and not
utils_misc.get_image_info(source)['lcounts'].lower() == "true"):
if (os.path.isfile(source) and not
utils_misc.get_image_info(source)['lcounts'].lower() == "true"):
LOG.debug("Copying guest image from %s to %s", source, dst)
shutil.copy(source, dst)
else:
Expand Down
4 changes: 2 additions & 2 deletions virttest/tests/unattended_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,10 +896,10 @@ def setup_cdrom(self):

i.copy(os.path.join(self.boot_path, os.path.basename(self.kernel)),
self.kernel)
assert(os.path.getsize(self.kernel) > 0)
assert (os.path.getsize(self.kernel) > 0)
i.copy(os.path.join(self.boot_path, os.path.basename(self.initrd)),
self.initrd)
assert(os.path.getsize(self.initrd) > 0)
assert (os.path.getsize(self.initrd) > 0)

if self.unattended_file.endswith('.preseed'):
self.preseed_initrd()
Expand Down
4 changes: 2 additions & 2 deletions virttest/utils_spice.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ def get_vdagent_status(vm_session, test_timeout):
except ShellCmdError:
# getting the status of vdagent stopped returns 3, which results in a
# ShellCmdError
return("stopped")
return ("stopped")
except Exception:
print("Unexpected error:", sys.exc_info()[0])
raise exceptions.TestFail(
"Failed attempting to get status of spice-vdagentd")
wait_timeout(3)
return(output)
return (output)


def verify_virtio(guest_session, test_timeout):
Expand Down
2 changes: 1 addition & 1 deletion virttest/utils_test/libvirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3864,7 +3864,7 @@ def check_qemu_cmd_line(content, err_ignore=False,
:return: True if exist, False otherwise
"""
cmd = 'pgrep -a qemu'
if not(remote_params or runner_on_target):
if not (remote_params or runner_on_target):
qemu_line = process.run(cmd, shell=True).stdout_text
else:
cmd_result = remote_old.run_remote_cmd(cmd, remote_params, runner_on_target)
Expand Down
4 changes: 2 additions & 2 deletions virttest/virt_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,8 +1013,8 @@ def verify_dmesg(self, dmesg_log_file=None, connect_uri=None):
serial_login = self.params.get("serial_login", "no") == "yes"
if serial_login:
self.session = self.wait_for_serial_login()
elif(len(self.virtnet) > 0 and self.virtnet[0].nettype != "macvtap" and
not connect_uri):
elif (len(self.virtnet) > 0 and self.virtnet[0].nettype != "macvtap" and
not connect_uri):
self.session = self.wait_for_login()
expected_guest_dmesg = self.params.get("expected_guest_dmesg", "")
return utils_misc.verify_dmesg(dmesg_log_file=dmesg_log_file,
Expand Down

0 comments on commit 10b597e

Please sign in to comment.