Reputation: 4668
I'm trying to run a custom stript to upload static files to a bucket.
import os
import sys
sys.path.append("/tools/google_appengine")
from google.appengine.ext import vendor
from google.appengine.api import app_identity
vendor.add('../libraries')
import cloudstorage as gcs
STATIC_DIR = '../dashboard/dist'
def main():
bucket_path = ''.join('/' + app_identity.get_default_gcs_bucket_name())
What I've been trying so far: - initialize stubs manuaIlly
def initialize_service_apis():
from google.appengine.tools import dev_appserver
from google.appengine.tools.dev_appserver_main import ParseArguments
args, option_dict = ParseArguments(sys.argv) # Otherwise the option_dict isn't populated.
dev_appserver.SetupStubs('local', **option_dict)
But this gives me import error when importing dev_appserver
lib.
Is there any way to resolve the issue ? I need this script for an automatic deployment process.
Upvotes: 2
Views: 1462
Reputation: 39834
The No api proxy found for service <blah>
error messages typically indicate attempts to use GAE standard env infrastructure (packages under google.appengine
in your case) inside standalone scripts, which is not OK. See GAE: AssertionError: No api proxy found for service "datastore_v3".
You have 2 options:
Upvotes: 1
Reputation: 7298
I'm not familiar with dev_appserver.SetupStubs()
, but I received this same error message while running unit tests in a testbed. In that environment, you have to explicitly enable stubs for any services you wish to test (see the docs).
In particular, initializing the app identity stub solved my problem:
from google.appengine.ext import testbed
t = testbed.Testbed()
t.init_app_identity_stub()
Upvotes: 0