misc cleanups (#39501)

This commit is contained in:
Adeeb Shihadeh
2026-11-28 12:10:20 -06:00
committed by firestar5683
parent bed2eb71a2
commit 4e41b7bc00
2 changed files with 14 additions and 7 deletions
+3 -3
View File
@@ -32,18 +32,18 @@ def upload_route(path: str, exclude_patterns: Iterable[str] | None = None) -> No
def sync_to_ci_public(route: str) -> bool:
dest_container, dest_key = DEST.get_client_and_key()
key_prefix = route.replace('|', '/')
dongle_id = key_prefix.split('/')[0]
if next(dest_container.list_blob_names(name_starts_with=key_prefix), None) is not None:
if DEST.has_prefix(key_prefix):
return True
dest_key = DEST.sas()
print(f"Uploading {route}")
for source_container in SOURCES:
# assumes az login has been run
print(f"Trying {source_container.ACCOUNT}/{source_container.CONTAINER}")
_, source_key = source_container.get_client_and_key()
source_key = source_container.sas()
cmd = [
"azcopy",
"copy",
+11 -4
View File
@@ -47,11 +47,18 @@ class AzureContainer:
def BASE_URL(self) -> str:
return f"{self.ACCOUNT_URL}/{self.CONTAINER}/"
def get_client_and_key(self):
def _client(self):
from azure.storage.blob import ContainerClient
client = ContainerClient(self.ACCOUNT_URL, self.CONTAINER, credential=get_azure_credential())
key = get_container_sas(self.ACCOUNT, self.CONTAINER)
return client, key
return ContainerClient(self.ACCOUNT_URL, self.CONTAINER, credential=get_azure_credential())
def sas(self) -> str:
return get_container_sas(self.ACCOUNT, self.CONTAINER)
def has_prefix(self, prefix: str) -> bool:
return next(self._client().list_blob_names(name_starts_with=prefix), None) is not None
def get_client_and_key(self):
return self._client(), self.sas()
def get_url(self, route_name: str, segment_num: str, filename: str) -> str:
return self.BASE_URL + f"{route_name.replace('|', '/')}/{segment_num}/{filename}"