Skip to content

Commit

Permalink
CP-47334: Python3.6 doesn't support f-string
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Cheng <[email protected]>
  • Loading branch information
stephenchengCloud committed Mar 8, 2024
1 parent 109b969 commit aee9e60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions python3/libexec/nbd_client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class NbdDeviceNotFound(Exception):

def __init__(self, nbd_device):
super().__init__(
f"NBD device '{nbd_device}' does not exist"
"NBD device '{}' does not exist".format(nbd_device)
)
self.nbd_device = nbd_device

Expand Down Expand Up @@ -131,7 +131,7 @@ def _find_unused_nbd_device():
Raises NbdDeviceNotFound if no devices are available.
"""
for device_no in range(0, 1000):
nbd_device = f"/dev/nbd{device_no}"
nbd_device = "/dev/nbd{}".format(device_no)
if not _is_nbd_device_connected(nbd_device=nbd_device):
return nbd_device
# Actually `_is_nbd_device_connected` will raise an exception
Expand All @@ -145,8 +145,8 @@ def _wait_for_nbd_device(nbd_device, connected):
while _is_nbd_device_connected(nbd_device=nbd_device) != connected:
if datetime.now() > deadline:
raise NbdConnStateTimeout(
f"Timed out waiting for connection state of "
f"device {nbd_device} to be {connected}"
"Timed out waiting for connection state of device %s to be %s"
% (nbd_device, connected)
)

LOGGER.debug(
Expand All @@ -168,7 +168,7 @@ def _get_persistent_connect_info_filename(device):
"""
matched = re.search("/dev/nbd([0-9]+)", device)
if not matched:
raise NotGetNbdNumber(f"Can not get the nbd number for device: {device}")
raise NotGetNbdNumber("Can not get the nbd number")
number = matched.group(1)
return PERSISTENT_INFO_DIR + "/" + number

Expand Down
2 changes: 1 addition & 1 deletion python3/unittest/test_nbd_client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class TestGetPersistentConnectInfoFilename(unittest.TestCase):
def test_get_persistent_connect_info_filename(self):
# Test for device /dev/nbd0
device = "/dev/nbd0"
expected_filename = f"{nbd_client_manager.PERSISTENT_INFO_DIR}/0"
expected_filename = "/var/run/nonpersistent/nbd/0"
self.assertEqual(nbd_client_manager._get_persistent_connect_info_filename(device),
expected_filename)

Expand Down

0 comments on commit aee9e60

Please sign in to comment.