Skip to content

Commit

Permalink
Fixup pylint failures when running on Github
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Syms <mark.syms@citrix.com>
  • Loading branch information
MarkSymsCtx committed Mar 15, 2023
1 parent 865514a commit 877403d
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 35 deletions.
4 changes: 2 additions & 2 deletions drivers/FileSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from uuid import uuid4
from lock import Lock
import xmlrpc.client
import XenAPI
import XenAPI # pylint: disable=import-error
from constants import CBTLOG_TAG

geneology = {}
Expand Down Expand Up @@ -215,7 +215,7 @@ def scan(self, sr_uuid):
self._kickGC()

# default behaviour from here on
return super(FileSR, self).scan(sr_uuid)
super(FileSR, self).scan(sr_uuid)

def update(self, sr_uuid):
if not self._checkmount():
Expand Down
4 changes: 2 additions & 2 deletions drivers/ISOSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def vdi(self, uuid):
smconfig = self.srcmd.params.get('vdi_sm_config')
if smconfig is None:
# uh, oh, a VDI.from_uuid()
import XenAPI
import XenAPI # pylint: disable=import-error
_VDI = self.session.xenapi.VDI
try:
vdi_ref = _VDI.get_by_uuid(uuid)
Expand Down Expand Up @@ -320,6 +320,7 @@ def attach(self, sr_uuid):
raise xs_errors.XenError('ISOInvalidSMBversion')

# Attempt mounting
smb3_fail_reason = None
try:
if protocol == 'nfs_iso':
# For NFS, do a soft mount with tcp as protocol. Since ISO SR is
Expand All @@ -334,7 +335,6 @@ def attach(self, sr_uuid):
'tcp', useroptions=options, nfsversion=self.nfsversion,
timeout=io_timeout, retrans=io_retrans)
else:
smb3_fail_reason = None
if self.smbversion in SMB_VERSION_3:
util.SMlog('ISOSR mount over smb 3.0')
try:
Expand Down
7 changes: 4 additions & 3 deletions drivers/LVHDSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from refcounter import RefCounter
from ipc import IPCFlag
from lvmanager import LVActivator
import XenAPI
import XenAPI # pylint: disable=import-error
import re
from srmetadata import ALLOCATION_TAG, NAME_LABEL_TAG, NAME_DESCRIPTION_TAG, \
UUID_TAG, IS_A_SNAPSHOT_TAG, SNAPSHOT_OF_TAG, TYPE_TAG, VDI_TYPE_TAG, \
Expand Down Expand Up @@ -792,9 +792,8 @@ def scan(self, uuid):
new_vdi.cbt_enabled = True
self.vdis[cbt_uuid] = new_vdi

ret = super(LVHDSR, self).scan(uuid)
super(LVHDSR, self).scan(uuid)
self._kickGC()
return ret

finally:
if lvname != '' and activated:
Expand Down Expand Up @@ -2232,6 +2231,7 @@ def _activate_cbt_log(self, lv_name):
except Exception as e:
util.SMlog("Exception in _activate_cbt_log, "
"Error: %s." % str(e))
raise
else:
return False

Expand All @@ -2240,6 +2240,7 @@ def _deactivate_cbt_log(self, lv_name):
self.sr.lvmCache.deactivateNoRefcount(lv_name)
except Exception as e:
util.SMlog("Exception in _deactivate_cbt_log, Error: %s." % str(e))
raise

def _cbt_log_exists(self, logpath):
return lvutil.exists(logpath)
Expand Down
2 changes: 1 addition & 1 deletion drivers/SR.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import xml.dom.minidom
import errno
import xs_errors
import XenAPI
import XenAPI # pylint: disable=import-error
import xmlrpc.client
import util
import copy
Expand Down
2 changes: 1 addition & 1 deletion drivers/SRCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# SRCommand: parse SR command-line objects
#

import XenAPI
import XenAPI # pylint: disable=import-error
import sys
import xs_errors
import xmlrpc.client
Expand Down
2 changes: 1 addition & 1 deletion drivers/VDI.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ def _activate_cbt_log(self, logname):
SR specific Implementation required for VDIs on block-based SRs.
No-op otherwise
"""
pass
return False

def _deactivate_cbt_log(self, logname):
"""Deactivate CBT log file
Expand Down
13 changes: 7 additions & 6 deletions drivers/blktap2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import glob
import json
import xs_errors
import XenAPI
import XenAPI # pylint: disable=import-error
import scsiutil
from syslog import openlog, syslog
from stat import * # S_ISBLK(), ...
Expand Down Expand Up @@ -1042,7 +1042,6 @@ def get_o_direct_capability(self, options):
@classmethod
def from_cli(cls, uuid):
import VDI as sm
import XenAPI

session = XenAPI.xapi_local()
session.xenapi.login_with_password('root', '', '', 'SM')
Expand Down Expand Up @@ -1887,7 +1886,6 @@ def _setup_cache(self, session, sr_uuid, vdi_uuid, local_sr_uuid,
import SR
import EXTSR
import NFSSR
import XenAPI
from lock import Lock
from FileSR import FileVDI

Expand Down Expand Up @@ -2035,7 +2033,6 @@ def _remove_cache(self, session, local_sr_uuid):
import SR
import EXTSR
import NFSSR
import XenAPI
from lock import Lock
from FileSR import FileVDI

Expand Down Expand Up @@ -2091,9 +2088,13 @@ def __init__(self):
self._action = None

class KeyError(PythonKeyError):
def __init__(self, args):
super().__init__(args)
self.key = args[0]

def __str__(self):
return \
"Key '%s' missing in environment. " % self.args[0] + \
"Key '%s' missing in environment. " % self.key + \
"Not called in udev context?"

@classmethod
Expand Down Expand Up @@ -2239,7 +2240,7 @@ def __init__(self, domid, devid):
self.devid = int(devid)
self._xbt = XenbusDevice.XBT_NIL

import xen.lowlevel.xs
import xen.lowlevel.xs # pylint: disable=import-error
self.xs = xen.lowlevel.xs.xs()

def xs_path(self, key=None):
Expand Down
2 changes: 1 addition & 1 deletion drivers/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import errno
import stat

import XenAPI
import XenAPI # pylint: disable=import-error
import util
import lvutil
import vhdutil
Expand Down
2 changes: 1 addition & 1 deletion drivers/devscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def adapters(filterstr="any"):
port_name_path = os.path.join(SYSFS_PATH1, a, 'device', \
'fc_host', a, 'port_name')
port_name_path_exists = os.path.exists(port_name_path)
util.SMlog("Port name path exists %d" % port_name_path_exists)
util.SMlog("Port name path exists %s" % port_name_path_exists)
if filterstr == "fcoe" and not port_name_path_exists:
continue
if port_name_path_exists:
Expand Down
2 changes: 1 addition & 1 deletion drivers/lcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def from_session(cls, session):

@classmethod
def from_cli(cls):
import XenAPI
import XenAPI # pylint: disable=import-error

session = XenAPI.xapi_local()
session.xenapi.login_with_password('root', '', '', 'SM')
Expand Down
3 changes: 1 addition & 2 deletions drivers/mpathcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
SCSIid = 'NOTSUPPLIED'
mpp_entry = 'NOTSUPPLIED'

cached_DM_maj = None

def get_dm_major():
global cached_DM_maj
Expand Down Expand Up @@ -218,8 +219,6 @@ def check_devconfig(devconfig, sm_config, config, remove, add):
mpp_path_update = True
mpp_entry = sys.argv[2]

cached_DM_maj = None

try:
session = util.get_localAPI_session()
except:
Expand Down
2 changes: 1 addition & 1 deletion drivers/resetvdis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import cleanup
import util
import lock
import XenAPI
import XenAPI # pylint: disable=import-error


def reset_sr(session, host_uuid, sr_uuid, is_sr_master):
Expand Down
6 changes: 3 additions & 3 deletions drivers/srmetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def findMetadataVDI(self):
# is_a_snapshot
# snapshot_of, if snapshot status is true
# snapshot time
# type: system, user or metadata etc
# type (system, user or metadata etc)
# vdi_type: raw or vhd
# read_only
# location
Expand Down Expand Up @@ -634,10 +634,10 @@ def getMetadataToWrite(self, sr_info, vdi_info, lower, upper, update_map, \

# specific functions, to be implement by the child classes
def getVdiInfo(self, Dict, generateSector=0):
return
return ''

def getSRInfoForSectors(self, sr_info, range):
return
return ''


class LVMMetadataHandler(MetadataHandler):
Expand Down
2 changes: 1 addition & 1 deletion drivers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import scsiutil
import stat
import xs_errors
import XenAPI
import XenAPI # pylint: disable=import-error
import xmlrpc.client
import base64
import syslog
Expand Down
10 changes: 1 addition & 9 deletions tests/pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ output-format=text
# Include message's id in output
#include-ids=yes

# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]".
files-output=no

# Tells whether to display a full report or only the messages
reports=no

Expand Down Expand Up @@ -147,9 +142,6 @@ indent-string=' '
# Required attributes for module, separated by a comma
#required-attributes=

# List of builtins function names that should not be used, separated by a comma
bad-functions=map,filter,apply,input

# Regular expression which should only match correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

Expand Down Expand Up @@ -205,7 +197,7 @@ max-locals=15
max-returns=6

# Maximum number of branch for function / method body
max-branchs=12
max-branches = 12

# Maximum number of statements in function / method body
max-statements=50
Expand Down

0 comments on commit 877403d

Please sign in to comment.