[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 02/16] python: fix broad-exception-raised pylint error
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v5 02/16] python: fix broad-exception-raised pylint error |
Date: |
Wed, 15 Feb 2023 16:25:33 +0300 |
Now 'make check-dev' called in python/ directory raises several
W0719: Raising too general exception: Exception (broad-exception-raised)
Let's fix.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
python/qemu/utils/qemu_ga_client.py | 6 +++---
tests/qemu-iotests/iotests.py | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/python/qemu/utils/qemu_ga_client.py
b/python/qemu/utils/qemu_ga_client.py
index 8c38a7ac9c..d8411bb2d0 100644
--- a/python/qemu/utils/qemu_ga_client.py
+++ b/python/qemu/utils/qemu_ga_client.py
@@ -155,7 +155,7 @@ def ping(self, timeout: Optional[float]) -> bool:
def fsfreeze(self, cmd: str) -> object:
if cmd not in ['status', 'freeze', 'thaw']:
- raise Exception('Invalid command: ' + cmd)
+ raise ValueError('Invalid command: ' + cmd)
# Can be int (freeze, thaw) or GuestFsfreezeStatus (status)
return getattr(self.qga, 'fsfreeze' + '_' + cmd)()
@@ -167,7 +167,7 @@ def fstrim(self, minimum: int) -> Dict[str, object]:
def suspend(self, mode: str) -> None:
if mode not in ['disk', 'ram', 'hybrid']:
- raise Exception('Invalid mode: ' + mode)
+ raise ValueError('Invalid mode: ' + mode)
try:
getattr(self.qga, 'suspend' + '_' + mode)()
@@ -178,7 +178,7 @@ def suspend(self, mode: str) -> None:
def shutdown(self, mode: str = 'powerdown') -> None:
if mode not in ['powerdown', 'halt', 'reboot']:
- raise Exception('Invalid mode: ' + mode)
+ raise ValueError('Invalid mode: ' + mode)
try:
self.qga.shutdown(mode=mode)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 94aeb3f3b2..3e82c634cf 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -720,7 +720,7 @@ def __exit__(self, exc_type, value, traceback):
signal.setitimer(signal.ITIMER_REAL, 0)
return False
def timeout(self, signum, frame):
- raise Exception(self.errmsg)
+ raise TimeoutError(self.errmsg)
def file_pattern(name):
return "{0}-{1}".format(os.getpid(), name)
@@ -804,7 +804,7 @@ def remote_filename(path):
elif imgproto == 'ssh':
return "ssh://%s@127.0.0.1:22%s" % (os.environ.get('USER'), path)
else:
- raise Exception("Protocol %s not supported" % (imgproto))
+ raise ValueError("Protocol %s not supported" % (imgproto))
class VM(qtest.QEMUQtestMachine):
'''A QEMU VM'''
--
2.34.1
- [PATCH v5 00/16] iotests: use vm.cmd(), Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 01/16] python: fix superfluous-parens pylint error, Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 03/16] python/qemu/qmp/legacy: cmd(): drop cmd_id unused argument, Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 04/16] qmp_shell.py: _fill_completion() use .command() instead of .cmd(), Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 02/16] python: fix broad-exception-raised pylint error,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v5 06/16] python: rename QEMUMonitorProtocol.cmd() to cmd_raw(), Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 08/16] python/machine.py: upgrade vm.cmd() method, Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 05/16] scripts/cpu-x86-uarch-abi.py: use .command() instead of .cmd(), Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 07/16] python/qemu: rename command() to cmd(), Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 09/16] iotests: QemuStorageDaemon: add cmd() method like in QEMUMachine., Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 10/16] iotests: add some missed checks of qmp result, Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 12/16] iotests: drop some occasional semicolons, Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 14/16] iotests.py: pause_job(): drop return value, Vladimir Sementsov-Ogievskiy, 2023/02/15
- [PATCH v5 11/16] iotests: refactor some common qmp result checks into generic pattern, Vladimir Sementsov-Ogievskiy, 2023/02/15