[Notes] [Git][BuildGrid/buildgrid][master] Fix CAS issues on Python 3.5



Title: GitLab

finnball pushed to branch master at BuildGrid / buildgrid

Commits:

2 changed files:

Changes:

  • buildgrid/server/cas/storage/disk.py
    ... ... @@ -32,14 +32,14 @@ class DiskStorage(StorageABC):
    32 32
     
    
    33 33
         def __init__(self, path):
    
    34 34
             self._path = pathlib.Path(path)
    
    35
    -        os.makedirs(self._path / "temp", exist_ok=True)
    
    35
    +        os.makedirs(str(self._path / "temp"), exist_ok=True)
    
    36 36
     
    
    37 37
         def has_blob(self, digest):
    
    38 38
             return (self._path / (digest.hash + "_" + str(digest.size_bytes))).exists()
    
    39 39
     
    
    40 40
         def get_blob(self, digest):
    
    41 41
             try:
    
    42
    -            return open(self._path / (digest.hash + "_" + str(digest.size_bytes)), 'rb')
    
    42
    +            return (self._path / (digest.hash + "_" + str(digest.size_bytes))).open('rb')
    
    43 43
             except FileNotFoundError:
    
    44 44
                 return None
    
    45 45
     
    
    ... ... @@ -49,7 +49,7 @@ class DiskStorage(StorageABC):
    49 49
         def commit_write(self, digest, write_session):
    
    50 50
             # Atomically move the temporary file into place.
    
    51 51
             path = self._path / (digest.hash + "_" + str(digest.size_bytes))
    
    52
    -        os.replace(write_session.name, path)
    
    52
    +        os.replace(write_session.name, str(path))
    
    53 53
             try:
    
    54 54
                 write_session.close()
    
    55 55
             except FileNotFoundError:
    

  • tests/cas/test_services.py
    ... ... @@ -83,7 +83,7 @@ def test_bytestream_read(data_to_read, instance):
    83 83
         request = bytestream_pb2.ReadRequest()
    
    84 84
         if instance != "":
    
    85 85
             request.resource_name = instance + "/"
    
    86
    -    request.resource_name += f"blobs/{HASH(data_to_read).hexdigest()}/{len(data_to_read)}"
    
    86
    +    request.resource_name += "blobs/{}/{}".format(HASH(data_to_read).hexdigest(), len(data_to_read))
    
    87 87
     
    
    88 88
         data = b""
    
    89 89
         for response in servicer.Read(request, None):
    
    ... ... @@ -101,7 +101,7 @@ def test_bytestream_read_many(instance):
    101 101
         request = bytestream_pb2.ReadRequest()
    
    102 102
         if instance != "":
    
    103 103
             request.resource_name = instance + "/"
    
    104
    -    request.resource_name += f"blobs/{HASH(data_to_read).hexdigest()}/{len(data_to_read)}"
    
    104
    +    request.resource_name += "blobs/{}/{}".format(HASH(data_to_read).hexdigest(), len(data_to_read))
    
    105 105
     
    
    106 106
         data = b""
    
    107 107
         for response in servicer.Read(request, None):
    
    ... ... @@ -119,7 +119,7 @@ def test_bytestream_write(instance, extra_data):
    119 119
         if instance != "":
    
    120 120
             resource_name = instance + "/"
    
    121 121
         hash_ = HASH(b'abcdef').hexdigest()
    
    122
    -    resource_name += f"uploads/UUID-HERE/blobs/{hash_}/6"
    
    122
    +    resource_name += "uploads/UUID-HERE/blobs/{}/6".format(hash_)
    
    123 123
         resource_name += extra_data
    
    124 124
         requests = [
    
    125 125
             bytestream_pb2.WriteRequest(resource_name=resource_name, data=b'abc'),
    
    ... ... @@ -139,7 +139,7 @@ def test_bytestream_write_rejects_wrong_hash():
    139 139
     
    
    140 140
         data = b'some data'
    
    141 141
         wrong_hash = HASH(b'incorrect').hexdigest()
    
    142
    -    resource_name = f"uploads/UUID-HERE/blobs/{wrong_hash}/9"
    
    142
    +    resource_name = "uploads/UUID-HERE/blobs/{}/9".format(wrong_hash)
    
    143 143
         requests = [
    
    144 144
             bytestream_pb2.WriteRequest(resource_name=resource_name, data=data, finish_write=True)
    
    145 145
         ]
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]