Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add pylint job #2

Merged
merged 7 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Pylint

on: [push, pull_request]

jobs:
pylint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt install libcurl4-gnutls-dev librtmp-dev
python -m pip install --upgrade pip
pip install pylint
pip install ovirt-imageio
pip install ovirt-engine-sdk-python
pip install pyyaml
- name: Analysing the code with pylint
run: pylint $(git ls-files '*.py')
8 changes: 4 additions & 4 deletions backup/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
import ovirtsdk4 as sdk
import ovirtsdk4.types as types

import imagetransfer
from . import imagetransfer

log = logging.getLogger("backup")


class Timeout:
class Timeout(Exception):
"""
Raised when starting or stopping a backup times out.
"""
Expand Down Expand Up @@ -238,8 +238,8 @@ def _get_backup(backup_service, backup_id):
"""
try:
backup = backup_service.get()
except sdk.NotFoundError:
raise RuntimeError(f"Backup {backup_id} does not exist")
except sdk.NotFoundError as e:
raise RuntimeError(f"Backup {backup_id} does not exist") from e

if backup.phase == types.BackupPhase.FAILED:
raise RuntimeError(f"Backup {backup_id} has failed")
Expand Down
12 changes: 6 additions & 6 deletions backup/imagetransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ def create_transfer(
while True:
try:
transfer = transfer_service.get()
except sdk.NotFoundError:
except sdk.NotFoundError as e:
# The system has removed the disk and the transfer.
raise RuntimeError(f"Transfer {transfer.id} was removed")
raise RuntimeError(f"Transfer {transfer.id} was removed") from e

if transfer.phase == types.ImageTransferPhase.FINISHED_FAILURE:
# The system will remove the disk and the transfer soon.
Expand Down Expand Up @@ -281,7 +281,7 @@ def finalize_transfer(connection, transfer, disk, timeout=300):
time.sleep(1)
try:
transfer = transfer_service.get()
except sdk.NotFoundError:
except sdk.NotFoundError as e:
# Old engine (< 4.4.7): since the transfer was already deleted from
# the database, we can assume that the disk status is already
# updated, so we can check it only once.
Expand All @@ -290,16 +290,16 @@ def finalize_transfer(connection, transfer, disk, timeout=300):
.disk_service(disk.id))
try:
disk = disk_service.get()
except sdk.NotFoundError:
except sdk.NotFoundError as e:
# Disk verification failed and the system removed the disk.
raise RuntimeError(
f"Transfer {transfer.id} failed: disk {disk.id} was removed")
f"Transfer {transfer.id} failed: disk {disk.id} was removed") from e

if disk.status == types.DiskStatus.OK:
break

raise RuntimeError(
f"Transfer {transfer.id} failed: disk {disk.id} status {disk.status}")
f"Transfer {transfer.id} failed: disk {disk.id} status {disk.status}") from e

log.debug("Transfer %r in phase %r", transfer.id, transfer.phase)

Expand Down
7 changes: 2 additions & 5 deletions backup/test.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import argparse
import logging
import os
import shutil
import subprocess
import threading
import time
import uuid
import yaml

from collections import Counter

import yaml
import ovirtsdk4 as sdk
import ovirtsdk4.types as types

import backup
import imagetransfer
from . import backup

log = logging.getLogger("test")

Expand Down
5 changes: 2 additions & 3 deletions delete-snapshot-chain/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import threading
import time
import uuid
import yaml

from collections import Counter

import yaml
import ovirtsdk4 as sdk
import ovirtsdk4.types as types

Expand Down Expand Up @@ -68,7 +67,7 @@ def run(self):

def setup(self):
self.vm = None
self.snapshot = None
self.snapshots = []
self.check_data_center()
self.create_vm()
self.start_vm()
Expand Down
4 changes: 1 addition & 3 deletions delete-snapshot/test.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import argparse
import logging
import subprocess
import threading
import time
import uuid
import yaml

from collections import Counter

import yaml
import ovirtsdk4 as sdk
import ovirtsdk4.types as types

Expand Down
Loading