Fix python 3.6 escape char warnings in strings
In python 3.6, escape sequences that are not recognized in string literals issue DeprecationWarnings. Convert these to raw strings. Change-Id: I0d20a0dd27415eab0abf08ceb5be415ae1cf0ad0
This commit is contained in:
parent
544d13ef0a
commit
76a63308f4
@ -248,7 +248,7 @@ def get_request_url(request):
|
||||
forwarded = headers.get('X-Forwarded-Host')
|
||||
if forwarded:
|
||||
url_parts = list(urllib.parse.urlsplit(url))
|
||||
url_parts[1] = re.split(',\s?', forwarded)[-1]
|
||||
url_parts[1] = re.split(r',\s?', forwarded)[-1]
|
||||
url = urllib.parse.urlunsplit(url_parts).rstrip('/')
|
||||
return url
|
||||
|
||||
|
@ -120,7 +120,7 @@ class QuotaSetsControllerTestBase(test.TestCase):
|
||||
self.fixture.config(auth_uri=self.auth_url, group='keystone_authtoken')
|
||||
|
||||
def _create_project_hierarchy(self):
|
||||
"""Sets an environment used for nested quotas tests.
|
||||
r"""Sets an environment used for nested quotas tests.
|
||||
|
||||
Create a project hierarchy such as follows:
|
||||
+-----------+
|
||||
@ -393,7 +393,7 @@ class QuotaSetControllerValidateNestedQuotaSetup(QuotaSetsControllerTestBase):
|
||||
"""
|
||||
|
||||
def _create_project_hierarchy(self):
|
||||
"""Sets an environment used for nested quotas tests.
|
||||
r"""Sets an environment used for nested quotas tests.
|
||||
|
||||
Create a project hierarchy such as follows:
|
||||
+-----------------+
|
||||
|
@ -1519,7 +1519,7 @@ class NestedDbQuotaDriverTestCase(NestedDbQuotaDriverBaseTestCase):
|
||||
class NestedQuotaValidation(NestedDbQuotaDriverBaseTestCase):
|
||||
def setUp(self):
|
||||
super(NestedQuotaValidation, self).setUp()
|
||||
"""
|
||||
r"""
|
||||
Quota hierarchy setup like so
|
||||
+-----------+
|
||||
| |
|
||||
|
@ -439,7 +439,7 @@ Return: 0x0000
|
||||
}])
|
||||
|
||||
def get_fake_show_snapshot(self):
|
||||
msg = """
|
||||
msg = r"""
|
||||
CLI: Successful: Device(UID:77124, Name:, Model:DS S12F-G2852-6) selected.
|
||||
Return: 0x0000
|
||||
\/\/\/-
|
||||
|
@ -923,8 +923,8 @@ class ExportTest(volume_helper.MStorageDSVDriver, unittest.TestCase):
|
||||
|
||||
self.vol.status = 'downloading'
|
||||
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
|
||||
'Failed to unregister Logical Disk from'
|
||||
' Logical Disk Set \(iSM31064\)'):
|
||||
r'Failed to unregister Logical Disk from'
|
||||
r' Logical Disk Set \(iSM31064\)'):
|
||||
mock_del = mock.Mock()
|
||||
self._cli.delldsetld = mock_del
|
||||
self._cli.delldsetld.return_value = False, 'iSM31064'
|
||||
|
@ -451,7 +451,7 @@ class NetAppBlockStorageCmodeLibraryTestCase(test.TestCase):
|
||||
self.assertListEqual([], pools)
|
||||
mock_get_ssc.assert_called_once_with()
|
||||
|
||||
@ddt.data('open+|demix+', 'open.+', '.+\d', '^((?!mix+).)*$',
|
||||
@ddt.data(r'open+|demix+', 'open.+', r'.+\d', '^((?!mix+).)*$',
|
||||
'open123, open321')
|
||||
def test_get_pool_map_match_selected_pools(self, patterns):
|
||||
|
||||
|
@ -260,7 +260,7 @@ class NetAppEseriesLibraryTestCase(test.TestCase):
|
||||
|
||||
self.assertEqual(eseries_fake.STORAGE_POOLS, filtered_pools)
|
||||
|
||||
@ddt.data(('[\d]+,a', ['1', '2', 'a', 'b'], ['1', '2', 'a']),
|
||||
@ddt.data((r'[\d]+,a', ['1', '2', 'a', 'b'], ['1', '2', 'a']),
|
||||
('1 , 3', ['1', '2', '3'], ['1', '3']),
|
||||
('$,3', ['1', '2', '3'], ['3']),
|
||||
('[a-zA-Z]+', ['1', 'a', 'B'], ['a', 'B']),
|
||||
|
@ -106,7 +106,7 @@ def common_mocks(f):
|
||||
return _common_inner_inner1
|
||||
|
||||
|
||||
CEPH_MON_DUMP = """dumped monmap epoch 1
|
||||
CEPH_MON_DUMP = r"""dumped monmap epoch 1
|
||||
{ "epoch": 1,
|
||||
"fsid": "33630410-6d93-4d66-8e42-3b953cf194aa",
|
||||
"modified": "2013-05-22 17:44:56.343618",
|
||||
|
@ -35,7 +35,7 @@ class WindowsSmbFsTestCase(test.TestCase):
|
||||
|
||||
_FAKE_SHARE = '//1.2.3.4/share1'
|
||||
_FAKE_SHARE_HASH = 'db0bf952c1734092b83e8990bd321131'
|
||||
_FAKE_MNT_BASE = 'c:\openstack\mnt'
|
||||
_FAKE_MNT_BASE = r'c:\openstack\mnt'
|
||||
_FAKE_MNT_POINT = os.path.join(_FAKE_MNT_BASE, _FAKE_SHARE_HASH)
|
||||
_FAKE_VOLUME_ID = '4f711859-4928-4cb7-801a-a50c37ceaccc'
|
||||
_FAKE_VOLUME_NAME = 'volume-%s.vhdx' % _FAKE_VOLUME_ID
|
||||
|
@ -350,8 +350,8 @@ def sanitize_hostname(hostname):
|
||||
if isinstance(hostname, six.text_type):
|
||||
hostname = hostname.encode('latin-1', 'ignore')
|
||||
|
||||
hostname = re.sub('[ _]', '-', hostname)
|
||||
hostname = re.sub('[^\w.-]+', '', hostname)
|
||||
hostname = re.sub(r'[ _]', '-', hostname)
|
||||
hostname = re.sub(r'[^\w.-]+', '', hostname)
|
||||
hostname = hostname.lower()
|
||||
hostname = hostname.strip('.-')
|
||||
|
||||
@ -581,7 +581,7 @@ def _get_disk_of_partition(devpath, st=None):
|
||||
for '/dev/disk1p1' ('p' is prepended to the partition number if the disk
|
||||
name ends with numbers).
|
||||
"""
|
||||
diskpath = re.sub('(?:(?<=\d)p)?\d+$', '', devpath)
|
||||
diskpath = re.sub(r'(?:(?<=\d)p)?\d+$', '', devpath)
|
||||
if diskpath != devpath:
|
||||
try:
|
||||
st_disk = os.stat(diskpath)
|
||||
|
@ -694,7 +694,7 @@ class ScaleIODriver(driver.VolumeDriver):
|
||||
raise exception.VolumeBackendAPIException(data=msg)
|
||||
|
||||
# make sure the response was valid
|
||||
pattern = re.compile("^\d+(\.\d+)*$")
|
||||
pattern = re.compile(r"^\d+(\.\d+)*$")
|
||||
if not pattern.match(self.server_api_version):
|
||||
msg = (_("Error calling version api "
|
||||
"response: %s") % r.text)
|
||||
|
@ -228,7 +228,7 @@ class HBSDCommon(object):
|
||||
first_type = 'dig'
|
||||
else:
|
||||
if (first_type == 'dig'
|
||||
or not re.match('\w\w:\w\w:\w\w', lists[i])):
|
||||
or not re.match(r'\w\w:\w\w:\w\w', lists[i])):
|
||||
msg = basic_lib.output_err(601, param=param)
|
||||
raise exception.HBSDError(message=msg)
|
||||
try:
|
||||
|
@ -116,7 +116,7 @@ class HBSDSNM2(basic_lib.HBSDBasicLib):
|
||||
|
||||
def get_comm_version(self):
|
||||
ret, stdout, stderr = self.exec_hsnm('auman', '-help')
|
||||
m = re.search('Version (\d+).(\d+)', stdout)
|
||||
m = re.search(r'Version (\d+).(\d+)', stdout)
|
||||
if not m:
|
||||
msg = basic_lib.output_err(
|
||||
600, cmd='auman', ret=ret, out=stdout, err=stderr)
|
||||
@ -958,8 +958,8 @@ class HBSDSNM2(basic_lib.HBSDBasicLib):
|
||||
|
||||
lines = stdout.splitlines()
|
||||
for line in lines[2:]:
|
||||
tc_cc = re.search('\s(\d+\.\d) GB\s+(\d+\.\d) GB\s', line)
|
||||
pool_tmp = re.match('\s*\d+', line)
|
||||
tc_cc = re.search(r'\s(\d+\.\d) GB\s+(\d+\.\d) GB\s', line)
|
||||
pool_tmp = re.match(r'\s*\d+', line)
|
||||
if (pool_tmp and tc_cc
|
||||
and int(pool_tmp.group(0)) == pool_id):
|
||||
total_gb = int(float(tc_cc.group(1)))
|
||||
@ -1047,10 +1047,10 @@ class HBSDSNM2(basic_lib.HBSDBasicLib):
|
||||
|
||||
def trans_status_hsnm2raid(self, str):
|
||||
status = None
|
||||
obj = re.search('Split\((.*)%\)', str)
|
||||
obj = re.search(r'Split\((.*)%\)', str)
|
||||
if obj:
|
||||
status = basic_lib.PSUS
|
||||
obj = re.search('Paired\((.*)%\)', str)
|
||||
obj = re.search(r'Paired\((.*)%\)', str)
|
||||
if obj:
|
||||
status = basic_lib.PAIR
|
||||
return status
|
||||
|
@ -1731,7 +1731,7 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver):
|
||||
schedule = ''.join(schedule)
|
||||
# We need to check the status of the schedule to make sure
|
||||
# it is not paused.
|
||||
result = re.search(".*paused\s+(\w+)", schedule)
|
||||
result = re.search(r".*paused\s+(\w+)", schedule)
|
||||
is_schedule_active = result.group(1) == 'false'
|
||||
|
||||
volume_info = cl.getVolumeByName(volume['name'])
|
||||
|
@ -304,7 +304,7 @@ class FlashSystemDriver(san.SanDriver,
|
||||
|
||||
# Ensure that the output is as expected
|
||||
match_obj = re.search(
|
||||
'Virtual Disk, id \[([0-9]+)\], successfully created', out)
|
||||
r'Virtual Disk, id \[([0-9]+)\], successfully created', out)
|
||||
|
||||
self._driver_assert(
|
||||
match_obj is not None,
|
||||
|
@ -75,7 +75,7 @@ class IBMStorageDriver(san.SanDriver,
|
||||
|
||||
2.0 - First open source driver version
|
||||
2.1.0 - Support Consistency groups through Generic volume groups
|
||||
- Support XIV\A9000 Volume independent QoS
|
||||
- Support XIV/A9000 Volume independent QoS
|
||||
- Support Consistency groups replication
|
||||
"""
|
||||
|
||||
|
@ -116,7 +116,7 @@ class XIVProxy(proxy.IBMStorageProxy):
|
||||
|
||||
2.0 - First open source driver version
|
||||
2.1.0 - Support Consistency groups through Generic volume groups
|
||||
- Support XIV\A9000 Volume independent QoS
|
||||
- Support XIV/A9000 Volume independent QoS
|
||||
|
||||
"""
|
||||
async_rates = (
|
||||
|
@ -704,8 +704,8 @@ class NetAppNfsDriver(driver.ManageableVD,
|
||||
conn, dr = None, None
|
||||
if image_location:
|
||||
nfs_loc_pattern = \
|
||||
('^nfs://(([\w\-\.]+:{1}[\d]+|[\w\-\.]+)(/[^\/].*)'
|
||||
'*(/[^\/\\\\]+)$)')
|
||||
(r'^nfs://(([\w\-\.]+:{1}[\d]+|[\w\-\.]+)(/[^\/].*)'
|
||||
r'*(/[^\/\\\\]+)$)')
|
||||
matched = re.match(nfs_loc_pattern, image_location, flags=0)
|
||||
if not matched:
|
||||
LOG.debug('Image location not in the'
|
||||
|
@ -279,9 +279,9 @@ class CapabilitiesLibrary(object):
|
||||
for key, value in extra_specs.items():
|
||||
|
||||
if isinstance(value, six.string_types):
|
||||
if re.match('<is>\s+True', value, re.I):
|
||||
if re.match(r'<is>\s+True', value, re.I):
|
||||
modified_extra_specs[key] = True
|
||||
elif re.match('<is>\s+False', value, re.I):
|
||||
elif re.match(r'<is>\s+False', value, re.I):
|
||||
modified_extra_specs[key] = False
|
||||
|
||||
return modified_extra_specs
|
||||
|
@ -592,7 +592,7 @@ class TintriDriver(driver.ManageableVD,
|
||||
conn, dr = None, None
|
||||
if image_location:
|
||||
nfs_loc_pattern = \
|
||||
'^nfs://(([\w\-\.]+:[\d]+|[\w\-\.]+)(/[^/].*)*(/[^/\\\\]+))$'
|
||||
r'^nfs://(([\w\-\.]+:[\d]+|[\w\-\.]+)(/[^/].*)*(/[^/\\\\]+))$'
|
||||
matched = re.match(nfs_loc_pattern, image_location)
|
||||
if not matched:
|
||||
LOG.debug('Image location not in the expected format %s',
|
||||
|
@ -131,7 +131,7 @@ class PloopDevice(object):
|
||||
|
||||
out, err = self.execute(*cmd, run_as_root=True)
|
||||
|
||||
m = re.search('dev=(\S+)', out)
|
||||
m = re.search(r'dev=(\S+)', out)
|
||||
if not m:
|
||||
raise Exception('Invalid output from ploop mount: %s' % out)
|
||||
|
||||
|
@ -38,7 +38,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
windows_opts = [
|
||||
cfg.StrOpt('windows_iscsi_lun_path',
|
||||
default='C:\iSCSIVirtualDisks',
|
||||
default=r'C:\iSCSIVirtualDisks',
|
||||
help='Path to store VHD backed volumes'),
|
||||
]
|
||||
|
||||
|
@ -55,7 +55,7 @@ class IetAdm(iscsi.ISCSITarget):
|
||||
|
||||
session_list = re.split('^tid:(?m)', sessions)[1:]
|
||||
for ses in session_list:
|
||||
m = re.match('(\d+) name:(\S+)\s+', ses)
|
||||
m = re.match(r'(\d+) name:(\S+)\s+', ses)
|
||||
if m and iqn in m.group(2):
|
||||
return m.group(1)
|
||||
|
||||
@ -206,7 +206,7 @@ class IetAdm(iscsi.ISCSITarget):
|
||||
|
||||
session_list = re.split('^tid:(?m)', sessions)[1:]
|
||||
for ses in session_list:
|
||||
m = re.match('(\d+) name:(\S+)\s+sid:(\d+).+\s+cid:(\d+)', ses)
|
||||
m = re.match(r'(\d+) name:(\S+)\s+sid:(\d+).+\s+cid:(\d+)', ses)
|
||||
if m and tid in m.group(1) and name in m.group(2):
|
||||
return m.group(3), m.group(4)
|
||||
|
||||
|
@ -43,7 +43,7 @@ class BrcdFCZoneClientCLI(object):
|
||||
switch_user = 'admin'
|
||||
switch_pwd = 'none'
|
||||
switch_key = 'none'
|
||||
patrn = re.compile('[;\s]+')
|
||||
patrn = re.compile(r'[;\s]+')
|
||||
|
||||
def __init__(self, ipaddress, username,
|
||||
password, port, key):
|
||||
|
@ -95,7 +95,7 @@ class CiscoFCZoneClientCLI(object):
|
||||
try:
|
||||
for line in switch_data:
|
||||
# Split on non-word characters,
|
||||
line_split = re.split('[\s\[\]]+', line)
|
||||
line_split = re.split(r'[\s\[\]]+', line)
|
||||
if ZoneConstant.CFG_ZONESET in line_split:
|
||||
# zoneset name [name] vsan [vsan]
|
||||
zone_set_name = \
|
||||
@ -291,7 +291,7 @@ class CiscoFCZoneClientCLI(object):
|
||||
try:
|
||||
for line in switch_data:
|
||||
# Split on non-word characters,
|
||||
line_split = re.split('[\s\[\]]+', line)
|
||||
line_split = re.split(r'[\s\[\]]+', line)
|
||||
if 'mode:' in line_split:
|
||||
# mode: <enhanced|basic>
|
||||
zone_status['mode'] = line_split[line_split.index('mode:')
|
||||
|
Loading…
Reference in New Issue
Block a user