Merge "flake8 regex fixes"

This commit is contained in:
Zuul 2020-02-12 01:05:43 +00:00 committed by Gerrit Code Review
commit 2fb60c3721
1 changed files with 8 additions and 7 deletions

View File

@ -33,6 +33,7 @@ class FileServerStatus(Enum):
UNKNOWN = 3
NO_CONNECTION = 4
Partition = collections.namedtuple(
'Partition', 'partition, used, free, total, percent_used')
@ -68,7 +69,7 @@ class FileServerStats(object):
# Sample AFS timestamps:
# Tue Nov 2 03:35:15 2016
# Tue Nov 22 03:35:15 2016
AFS_DATE_REGEX = '(?P<date>\w+ \w+\s+(\d{1,2}) \d+:\d+:\d+ \d+)'
AFS_DATE_REGEX = r'(?P<date>\w+ \w+\s+(\d{1,2}) \d+:\d+:\d+ \d+)'
AFS_DATE_STRPTIME = '%a %b %d %H:%M:%S %Y'
def _get_volumes(self):
@ -99,7 +100,7 @@ class FileServerStats(object):
# convert it to a Volume()
# todo: there's a bunch more we could extract...
m = vol_regex.search(chunk)
q = re.search('MaxQuota\s+(?P<quota>\d+) K', chunk)
q = re.search(r'MaxQuota\s+(?P<quota>\d+) K', chunk)
used = int(m.group('used'))
quota = int(q.group('quota'))
percent_used = round(float(used) / float(quota) * 100, 2)
@ -118,10 +119,10 @@ class FileServerStats(object):
cmd, stderr=subprocess.STDOUT).decode('ascii')
for line in output.split('\n'):
m = re.search('(?P<waiting>\d+) calls waiting for a thread', line)
m = re.search(r'(?P<waiting>\d+) calls waiting for a thread', line)
if m:
self.calls_waiting = int(m.group('waiting'))
m = re.search('(?P<idle>\d+) threads are idle', line)
m = re.search(r'(?P<idle>\d+) threads are idle', line)
if m:
self.idle_threads = int(m.group('idle'))
@ -133,9 +134,9 @@ class FileServerStats(object):
for line in output.split('\n'):
m = re.search(
'Free space on partition '
'/vicep(?P<partition>[a-z][a-z]?): '
'(?P<free>\d+) K blocks out of total (?P<total>\d+)', line)
r'Free space on partition '
r'/vicep(?P<partition>[a-z][a-z]?): '
r'(?P<free>\d+) K blocks out of total (?P<total>\d+)', line)
if m:
part = 'vicep%s' % m.group('partition')
# (used, free, total, %age)