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

Unified Diff: tools/android/loading/gce/google_storage_accessor.py

Issue 1895033002: tools/android/loading Switch the GCE worker to pull queues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@appengine
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/android/loading/gce/deploy.sh ('k') | tools/android/loading/gce/main.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/loading/gce/google_storage_accessor.py
diff --git a/tools/android/loading/gce/google_storage_accessor.py b/tools/android/loading/gce/google_storage_accessor.py
deleted file mode 100644
index 59c47da3ec04976fa2d1ee6dc428ce11727144df..0000000000000000000000000000000000000000
--- a/tools/android/loading/gce/google_storage_accessor.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-from gcloud import storage
-from oauth2client.client import GoogleCredentials
-
-
-class GoogleStorageAccessor(object):
- """Utility class providing helpers for Google Cloud Storage.
- """
- def __init__(self, project_name, bucket_name):
- """project_name is the name of the Google Cloud project.
- bucket_name is the name of the bucket that is used for Cloud Storage calls.
- """
- self._credentials = GoogleCredentials.get_application_default()
- self._project_name = project_name
- self._bucket_name = bucket_name
-
- def _GetStorageClient(self):
- """Returns the storage client associated with the project"""
- return storage.Client(project = self._project_name,
- credentials = self._credentials)
-
- def _GetStorageBucket(self, storage_client):
- return storage_client.get_bucket(self._bucket_name)
-
- def UploadFile(self, filename_src, filename_dest):
- """Uploads a file to Google Cloud Storage
-
- Args:
- filename_src: name of the local file
- filename_dest: name of the file in Google Cloud Storage
-
- Returns:
- The URL of the file in Google Cloud Storage.
- """
- client = self._GetStorageClient()
- bucket = self._GetStorageBucket(client)
- blob = bucket.blob(filename_dest)
- with open(filename_src) as file_src:
- blob.upload_from_file(file_src)
- return blob.public_url
-
- def UploadString(self, data_string, filename_dest):
- """Uploads a string to Google Cloud Storage
-
- Args:
- data_string: the contents of the file to be uploaded
- filename_dest: name of the file in Google Cloud Storage
-
- Returns:
- The URL of the file in Google Cloud Storage.
- """
- client = self._GetStorageClient()
- bucket = self._GetStorageBucket(client)
- blob = bucket.blob(filename_dest)
- blob.upload_from_string(data_string)
- return blob.public_url
-
« no previous file with comments | « tools/android/loading/gce/deploy.sh ('k') | tools/android/loading/gce/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698