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

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

Issue 2854083004: Fix feedback to populate the right content in issue creation page. (Closed)
Patch Set: add assertion to check links Created 3 years, 7 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
« no previous file with comments | « build/android/pylib/results/presentation/test_results_presentation.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Helper functions to upload data to Google Storage. 5 """Helper functions to upload data to Google Storage.
6 6
7 Text data should be streamed to logdog using |logdog_helper| module. 7 Text data should be streamed to logdog using |logdog_helper| module.
8 Due to logdog not having image or HTML viewer, those instead should be uploaded 8 Due to logdog not having image or HTML viewer, those instead should be uploaded
9 to Google Storage directly using this module. 9 to Google Storage directly using this module.
10 """ 10 """
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 suffix: Suffix of filename. 72 suffix: Suffix of filename.
73 timestamp: Whether or not to add a timestamp to name. 73 timestamp: Whether or not to add a timestamp to name.
74 device: Device to add device serial of to name. 74 device: Device to add device serial of to name.
75 """ 75 """
76 return '%s%s%s%s' % ( 76 return '%s%s%s%s' % (
77 basename, 77 basename,
78 '_%s' % time.strftime('%Y_%m_%d_T%H_%M_%S-UTC', time.gmtime()) 78 '_%s' % time.strftime('%Y_%m_%d_T%H_%M_%S-UTC', time.gmtime())
79 if timestamp else '', 79 if timestamp else '',
80 '_%s' % device.serial if device else '', 80 '_%s' % device.serial if device else '',
81 suffix) 81 suffix)
82
83
84 def get_url_link(name, bucket, authenticated_link=True):
85 """Get url link before/without uploading.
86
87 Args:
88 name: Name of the file on Google Storage.
89 bucket: Bucket to upload file to.
90 authenticated_link: Whether to return a link that requires user to
91 authenticate with a Google account. Setting this to false will return
92 a link that does not require user to be signed into Google account but
93 will only work for completely public storage buckets.
94 Returns:
95 Web link to item to be uploaded to Google Storage bucket
96 """
97 if bucket.startswith('gs://'):
98 bucket = bucket[len('gs://'):]
99 if bucket.endswith('/'):
100 bucket = bucket[:-1]
101 url_template = _AUTHENTICATED_URL if authenticated_link else _PUBLIC_URL
102 return os.path.join(url_template % bucket, name)
OLDNEW
« no previous file with comments | « build/android/pylib/results/presentation/test_results_presentation.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698