Chromium Code Reviews| Index: build/android/pylib/utils/logdog_helper.py |
| diff --git a/build/android/pylib/utils/logdog_helper.py b/build/android/pylib/utils/logdog_helper.py |
| index 8dfab7e403952e580c327c1498bc77e5e79f2b9e..429f96bab54bd7e4fd69c21cce174f05e5df164e 100644 |
| --- a/build/android/pylib/utils/logdog_helper.py |
| +++ b/build/android/pylib/utils/logdog_helper.py |
| @@ -7,14 +7,21 @@ |
| import logging |
| import os |
| import sys |
| +import time |
| + |
| +from devil.utils import cmd_helper |
| from pylib import constants |
| +from pylib.constants import host_paths |
| from pylib.utils import decorators |
| sys.path.insert(0, os.path.abspath(os.path.join( |
| constants.DIR_SOURCE_ROOT, 'tools', 'swarming_client'))) |
| from libs.logdog import bootstrap # pylint: disable=import-error |
| +sys.path.append(os.path.join(host_paths.DIR_SOURCE_ROOT, 'build')) |
| +import find_depot_tools # pylint: disable=import-error |
| + |
| @decorators.NoRaiseException(default_return_value='') |
| def text(name, data): |
| @@ -78,6 +85,44 @@ def get_viewer_url(name): |
| return get_logdog_client().get_viewer_url(name) |
| +@decorators.NoRaiseException(default_return_value='') |
| +def image(name, image_path): |
| + """Uploads image to Google Storage. |
|
jbudorick
2017/02/21 18:32:40
This should not be in logdog_helper if it's not up
mikecase (-- gone --)
2017/02/23 00:21:26
done. Moved to its own module.
|
| + |
| + Args: |
| + name: Name of the image on Google Storage. |
| + image_path: Path to image you want to upload. |
| + """ |
| + # TODO(mikecase): Merge this with binary() function. Currently, logdog has no |
| + # support for viewing images in its log viewer. As a work-around, upload to |
| + # google storage directly. |
| + |
| + RENDER_TEST_BASE_URL = 'https://storage.googleapis.com/chromium-render-tests/' |
| + RENDER_TEST_BUCKET = 'gs://chromium-render-tests/' |
| + |
| + cmd_helper.RunCmd( |
| + [os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'gsutil.py'), 'cp', |
| + image_path, |
| + os.path.join(RENDER_TEST_BUCKET, name)]) |
|
jbudorick
2017/02/21 18:32:40
super nit: why is this not on the same line as ima
mikecase (-- gone --)
2017/02/23 00:21:26
it is now!
|
| + |
| + return os.path.join(RENDER_TEST_BASE_URL, name) |
| + |
| + |
| +def unique_name(basename, timestamp=True, device=None): |
| + """Helper function for creating a unique name for a logdog stream. |
| + |
| + Args: |
| + basename: Base of the unique name. |
| + timestamp: Whether or not to add a timestamp to name. |
| + device: Device to add device serial of to name. |
| + """ |
| + return '%s%s%s' % ( |
| + basename, |
| + '_%s' % time.strftime('%Y%m%dT%H%M%S', time.localtime()) |
| + if timestamp else '', |
| + '_%s' % device.serial if device else '') |
| + |
| + |
| @decorators.Memoize |
| def get_logdog_client(): |
| logging.debug('Getting logdog client.') |