Skip to content
Snippets Groups Projects
Commit c5b1d467 authored by Martin Blanchard's avatar Martin Blanchard
Browse files

cmd_execute.py: Port to new CAS downloader helper

#79
parent 0facefbb
No related branches found
No related tags found
Loading
......@@ -20,7 +20,6 @@ Execute command
Request work to be executed and monitor status of jobs.
"""
import errno
import logging
import os
import stat
......@@ -30,10 +29,8 @@ from urllib.parse import urlparse
import click
import grpc
from buildgrid.client.cas import upload
from buildgrid.client.cas import download, upload
from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2, remote_execution_pb2_grpc
from buildgrid._protos.google.bytestream import bytestream_pb2_grpc
from buildgrid.utils import write_fetch_blob
from ..cli import pass_context
......@@ -143,8 +140,6 @@ def run_command(context, input_root, commands, output_file, output_directory):
skip_cache_lookup=True)
response = stub.Execute(request)
stub = bytestream_pb2_grpc.ByteStreamStub(context.channel)
stream = None
for stream in response:
context.logger.info(stream)
......@@ -152,20 +147,15 @@ def run_command(context, input_root, commands, output_file, output_directory):
execute_response = remote_execution_pb2.ExecuteResponse()
stream.response.Unpack(execute_response)
with download(context.channel, instance=context.instance_name) as downloader:
for output_file_response in execute_response.result.output_files:
path = os.path.join(output_directory, output_file_response.path)
if not os.path.exists(os.path.dirname(path)):
os.makedirs(os.path.dirname(path), exist_ok=True)
try:
os.makedirs(os.path.dirname(path))
except OSError as exc:
if exc.errno != errno.EEXIST:
raise
with open(path, 'wb+') as f:
write_fetch_blob(f, stub, output_file_response.digest, context.instance_name)
downloader.download_file(output_file_response.digest, path)
if output_file_response.path in output_executeables:
st = os.stat(path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment