Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Side by Side Diff: build/android/pylib/utils/logdog_helper.py

Issue 2664873002: Add logdog_helper script. (Closed)
Patch Set: Add logdog_helper script. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Helper functions to upload data to logdog."""
6
7 import os
8 import sys
9
10 from pylib import constants
11 from pylib.utils import python_utils
12
13 sys.path.insert(0, os.path.abspath(os.path.join(
14 constants.DIR_SOURCE_ROOT, 'tools', 'swarming_client')))
15 from libs.logdog import bootstrap # pylint: disable=import-error
16
17
18 @python_utils.NoRaiseException(default_return_value='')
mikecase (-- gone --) 2017/01/30 23:20:49 Currently, all of the logdog code is surrounded in
19 def text(name, data):
20 """Uploads text to logdog.
21
22 Args:
23 name: Name of the logdog stream.
24 data: String with data you want to upload.
25
26 Returns:
27 Link to view uploaded text in logdog viewer.
28 """
29 with get_logdog_client().text(name) as stream:
30 stream.write(data)
31 return stream.get_viewer_url()
32
33
34 @python_utils.NoRaiseException(default_return_value=None)
35 def open_text(name):
36 """Returns a file like object which you can write to.
37
38 Args:
39 name: Name of the logdog stream.
40
41 Returns:
42 A file like object. close() file when done.
43 """
44 return get_logdog_client().open_text(name)
45
46
47 @python_utils.NoRaiseException(default_return_value='')
48 def binary(name, binary_path):
49 """Uploads binary to logdog.
50
51 Args:
52 name: Name of the logdog stream.
53 binary_path: Path to binary you want to upload.
54
55 Returns:
56 Link to view uploaded binary in logdog viewer.
57 """
58 with get_logdog_client().binary(name) as stream:
59 with open(binary_path, 'r') as f:
60 stream.write(f.read())
61 return stream.get_viewer_url()
62
63
64 @python_utils.NoRaiseException(default_return_value='')
65 def get_viewer_url(name):
66 """Get Logdog viewer URL.
67
68 Args:
69 name: Name of the logdog stream.
70
71 Returns:
72 Link to view uploaded binary in logdog viewer.
73 """
74 return get_logdog_client().get_viewer_url(name)
75
76
77 @python_utils.Memoize
mikecase (-- gone --) 2017/01/30 23:20:49 Pretty sure (99%) you only need to get the stream_
jbudorick 2017/01/31 16:11:53 I'm not sure I like this, though you may be right.
78 def get_logdog_client():
79 return bootstrap.ButlerBootstrap.probe().stream_client()
80
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698