Skip to content
Snippets Groups Projects
Commit 9d1bccd7 authored by Carter Sande's avatar Carter Sande
Browse files

Fix CAS issues on Python 3.5

parent 49cc153a
No related branches found
No related tags found
Loading
Pipeline #26618607 passed
......@@ -32,14 +32,14 @@ class DiskStorage(StorageABC):
def __init__(self, path):
self._path = pathlib.Path(path)
os.makedirs(self._path / "temp", exist_ok=True)
os.makedirs(str(self._path / "temp"), exist_ok=True)
def has_blob(self, digest):
return (self._path / (digest.hash + "_" + str(digest.size_bytes))).exists()
def get_blob(self, digest):
try:
return open(self._path / (digest.hash + "_" + str(digest.size_bytes)), 'rb')
return (self._path / (digest.hash + "_" + str(digest.size_bytes))).open('rb')
except FileNotFoundError:
return None
......@@ -49,7 +49,7 @@ class DiskStorage(StorageABC):
def commit_write(self, digest, write_session):
# Atomically move the temporary file into place.
path = self._path / (digest.hash + "_" + str(digest.size_bytes))
os.replace(write_session.name, path)
os.replace(write_session.name, str(path))
try:
write_session.close()
except FileNotFoundError:
......
......@@ -83,7 +83,7 @@ def test_bytestream_read(data_to_read, instance):
request = bytestream_pb2.ReadRequest()
if instance != "":
request.resource_name = instance + "/"
request.resource_name += f"blobs/{HASH(data_to_read).hexdigest()}/{len(data_to_read)}"
request.resource_name += "blobs/{}/{}".format(HASH(data_to_read).hexdigest(), len(data_to_read))
data = b""
for response in servicer.Read(request, None):
......@@ -101,7 +101,7 @@ def test_bytestream_read_many(instance):
request = bytestream_pb2.ReadRequest()
if instance != "":
request.resource_name = instance + "/"
request.resource_name += f"blobs/{HASH(data_to_read).hexdigest()}/{len(data_to_read)}"
request.resource_name += "blobs/{}/{}".format(HASH(data_to_read).hexdigest(), len(data_to_read))
data = b""
for response in servicer.Read(request, None):
......@@ -119,7 +119,7 @@ def test_bytestream_write(instance, extra_data):
if instance != "":
resource_name = instance + "/"
hash_ = HASH(b'abcdef').hexdigest()
resource_name += f"uploads/UUID-HERE/blobs/{hash_}/6"
resource_name += "uploads/UUID-HERE/blobs/{}/6".format(hash_)
resource_name += extra_data
requests = [
bytestream_pb2.WriteRequest(resource_name=resource_name, data=b'abc'),
......@@ -139,7 +139,7 @@ def test_bytestream_write_rejects_wrong_hash():
data = b'some data'
wrong_hash = HASH(b'incorrect').hexdigest()
resource_name = f"uploads/UUID-HERE/blobs/{wrong_hash}/9"
resource_name = "uploads/UUID-HERE/blobs/{}/9".format(wrong_hash)
requests = [
bytestream_pb2.WriteRequest(resource_name=resource_name, data=data, finish_write=True)
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment