flake8 regex fixes
Prefix strings with regex escapes with "r" Change-Id: I1dcbaa9947a693992e560ca258469b8cbcfcfec3
This commit is contained in:
parent
618e1833e1
commit
dcc872442f
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user