Google App Engine Guestbook application gives error - google-app-engine

I upload the Google App Engine application which is at the url developers.google.com/appengine/docs/python/memcache/usingmemcache#Memcache
When I run the application on Google App Engine Launcher, it runs but the website shows:
(First error is there us no Python "PIL" module but I am not using image. Could you please suggest what is causing the error?
*** Running dev_appserver with the following flags:
--skip_sdk_update_check=yes --port=13080 --admin_port=8005
Python command: /usr/bin/python2.7
INFO 2014-01-17 20:43:22,217 devappserver2.py:660] Skipping SDK update check.
WARNING 2014-01-17 20:43:22,222 api_server.py:331] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO 2014-01-17 20:43:22,226 api_server.py:138] Starting API server at: localhost:55385
INFO 2014-01-17 20:43:22,230 dispatcher.py:171] Starting module "default" running at: localhost:13080
INFO 2014-01-17 20:43:22,238 admin_server.py:117] Starting admin server at: localhost:8005
ERROR 2014-01-17 20:43:24,601 wsgi.py:262]
Traceback (most recent call last):
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 301, in _LoadHandler
raise err
ImportError: <module 'guestbookw2' from '/Users/guestbookw2/guestbookw2.pyc'> has no attribute application
INFO 2014-01-17 20:43:24,607 module.py:617] default: "GET / HTTP/1.1" 500 -
ERROR 2014-01-17 20:43:24,727 wsgi.py:262]
Traceback (most recent call last):
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 301, in _LoadHandler
raise err
ImportError: <module 'guestbookw12' from '/Users/guestbookw2/guestbookw2.pyc'> has no attribute application
INFO 2014-01-17 20:43:24,732 module.py:617] default: "GET /favicon.ico HTTP/1.1" 500 -

Make sure that you have the following files in the path that you are uploading your application from:
index.yaml (auto-generated; you don't need to add or change anything in here at this point).
favicon.ico (in the correct format; should be 16x16 or 32x32 pixels if I remember correctly).
main.py (mapping all the paths in your web-site; example given below):
from webapp2 import WSGIApplication
from Server import MainRequestHandler
from Server import SomeRequestHandler
from Server import OtherRequestHandler
app = WSGIApplication([
('/' ,MainRequestHandler),
('/abc' ,SomeRequestHandler),
('/def' ,SomeRequestHandler),
('/xyz' ,OtherRequestHandler),
])
app.yaml (with the following contents; using <...> where you need to set a value):
application: <the app-id you chose when use signed in for GAE>
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.1" // you might need to change this as well
Note:
if you wish to avoid handling 'favicon.ico' request, then you must remove the reference in file 'app.yaml'.
Supplemental:
You will need to implement all the request handlers imported in 'main.py'.
In the example above, 'main.py' expects to find them in a Python module named 'Server'.
Each request handler must inherit class RequestHandler, imported from webapp2.
Supplemental #2:
In order to solve the 'PIL' issue (had a similar problem if memory serves correctly), simply install it.
From a Windows command line, enter: pip install pil.

Related

Error Response: [13] An internal error occurred, when deploying project on Google Cloud SDK

I have been trying to deploy my project on Google Cloud SDK since yesterday and have been getting the same error over and over.
My app.yaml file looks like:
runtime: python27
api_version: 1
threadsafe: yes
- url: /
static_files: bin/index.html
upload: bin/index.html
- url: /assets
static_dir: bin/assets
- url: /src
static_dir: bin/src
- url: /vendor
static_dir: bin/vendor
- url: /templates-app.js
static_files: static/templates-app.js
upload: static/templates-app.js
- url: /templates-common.js
static_files: static/templates-common.js
upload: static/templates-common.js
- url: .*
script: main.app
I use this command to deploy:
gcloud preview app deploy app.yaml --version 1 --promote --force
And I get this error:
Beginning deployment...
Copying files to Google Cloud Storage...
Synchronizing files to [gs://staging.myapp.appspot.com/].
Updating module [default]...failed.
ERROR: (gcloud.preview.app.deploy) Error Response: [13] An internal error occurred.
I got the same error today Error Response: [13] An internal error occurred.
In my case, the issue was because I have a folder that has over 1000 files. Once I moved some of these files elsewhere, the internal error message disappeared!
I tried 1000 files in one folder, and it worked, then, I added one file (1001 files total) in the same folder, and the same internal error came back. It seems that it is kind of a limit that google app engine has 1000 files per folder.
I notice you don't have your app name in the app.yaml file and you also don't specify it in the upload cmd. I'd suggest making a habit in providing as much as the info as possible in the app.yaml to minimize the chances of human error. You can also specify the version in the app.yaml as well. This habit will help when you'll get to multi-modules apps, where such info is mandatory. See examples in the modules config doc.
From a different prospective, I saw several reports in which gcloud preview app deploy tripped, you can always try alternate approaches to rule out such cases, see my answer to this Q&A: Google App Engine deploy with Django module after gcloud update?
It ended up being the reportlab python library in the lib folder.
I found inserting it as a zip file rather than a normal folder worked.
import sys
sys.path.insert(0, 'reportlab.zip')
import reportlab
...
I have no idea why it wouldn't work. But I remember seeing something about a file limit when uploading projects with app-engine. Deploying 1 zip file is better than 181 files that make up reportlab.

gcloud preview app deploy returns 400 error

Trying to deploy some static content to GAE, since they removed the push-to-deploy pipeline feature. I've setup a brand new project. It's in the US region. Did gcloud auth login again. Still getting the same response.
Verbose debug output below. [REDACTED] is my addition to the code.
$ gcloud preview app deploy dist/app.yaml --verbosity debug
DEBUG: Running gcloud.preview.app.deploy with Namespace(__calliope_internal_deepest_parser=ArgumentParser(prog='gcloud.preview.app.deploy', usage=None, description="*(BETA)* This command is used to deploy both code and configuration to the App Engine\nserver. As an input it takes one or more ``DEPLOYABLES'' that should be\nuploaded. A ``DEPLOYABLE'' can be a module's .yaml file or a configuration's\n.yaml file.", version=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False), cmd_func=<bound method Command.Run of <googlecloudsdk.calliope.backend.Command object at 0x10bf14290>>, command_path=['gcloud', 'preview', 'app', 'deploy'], deployables=['dist/app.yaml'], document=None, env_vars=None, force=False, format=None, h=None, help=None, http_timeout=None, log_http=None, markdown=None, project=None, quiet=None, remote=False, server=None, set_default=False, trace_token=None, user_output_enabled=None, verbosity='debug', version=None).
You are about to deploy the following modules:
- [PROJECT_ID]/default/20150612t130942 From: [/Users/[ME]/Dropbox/Sites/[PROJECT_ID]/site/dist/app.yaml]
Do you want to continue (Y/n)? Y
Updating module [default]...DEBUG: Host: appengine.google.com
DEBUG: Host: appengine.google.com
DEBUG: Getting current resource limits.
DEBUG: Send: /api/appversion/getresourcelimits, params={'version': '20150612t130942', 'app_id': '[PROJECT_ID]'}
DEBUG: _Authenticate configuring auth; needs_auth=False
DEBUG: Sending request to https://appengine.google.com/api/appversion/getresourcelimits?app_id=[PROJECT_ID]&version=20150612t130942 headers={'X-appcfg-api-version': '1', 'content-length': '0', 'Content-Type': 'application/octet-stream'} body=
INFO: Attempting refresh to obtain initial access_token
INFO: Refreshing access_token
DEBUG: Got response: max_file_size: 32000000
max_blob_size: 32000000
max_files_to_clone: 2000
max_total_file_size: 9223372036854775807
max_file_count: 10000
DEBUG: Using resource limits: {'max_file_size': 32000000, 'max_total_file_size': 9223372036854775807, 'max_blob_size': 32000000, 'max_files_to_clone': 2000, 'max_file_count': 10000}
INFO: Reading app configuration.
DEBUG:
Starting update of app: [PROJECT_ID], version: 20150612t130942
DEBUG: Scanning files on local disk.
INFO: Processing file [app.yaml]
INFO: Processing file [index.html]
INFO: Processing file [views/6a0e56b1.main.html]
INFO: Processing file [views/partials/90bc29e6.case-study.html]
INFO: Processing file [views/partials/cc69dea5.home.html]
INFO: Processing file [styles/9960b040.main.css]
INFO: Processing file [scripts/8a12aff1.scripts.js]
INFO: Processing file [scripts/8e6de882.libraries.js]
DEBUG: Send: /api/appversion/create, params={'version': '20150612t130942', 'app_id': '[PROJECT_ID]', 'module': 'default'}
DEBUG: _Authenticate configuring auth; needs_auth=False
DEBUG: Sending request to https://appengine.google.com/api/appversion/create?app_id=[PROJECT_ID]&module=default&version=20150612t130942 headers={'X-appcfg-api-version': '1', 'content-length': '633', 'Content-Type': 'application/octet-stream'} body=api_version: '1'
application: [PROJECT_ID]
auto_id_policy: default
builtins:
- default: 'on'
derived_file_type:
- python_precompiled
handlers:
- script: index.html
secure: optional
url: /
- secure: optional
static_dir: styles
url: /styles
- secure: optional
static_dir: scripts
url: /scripts
- secure: optional
static_dir: views
url: /views
- secure: optional
static_dir: fonts
url: /fonts
- secure: optional
static_dir: images
url: /images
- secure: optional
static_dir: res
url: /res
module: default
runtime: php
threadsafe: true
version: 20150612t130942
vm_settings:
module_yaml_path: app.yaml
INFO: Attempting refresh to obtain initial access_token
INFO: Refreshing access_token
Updating module [default].../DEBUG: Got http error 400.
DEBUG: Unexpected results: {'status': '400', 'alternate-protocol': '443:quic,p=1', 'content-length': '318', 'expires': 'Fri, 01 Jan 1990 00:00:00 GMT', 'server': 'Google Frontend', 'cache-control': 'no-cache', 'date': 'Fri, 12 Jun 2015 18:09:47 GMT', 'content-type': 'text/plain'}
Updating module [default]...done.
DEBUG: (gcloud.preview.app.deploy) Server responded with code [400]:
Bad Request Unexpected HTTP status 400
Traceback (most recent call last):
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 538, in Execute
result = args.cmd_func(cli=self, args=args)
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/calliope/backend.py", line 1124, in Run
result = command_instance.Run(args)
File "/Users/[ME]/Applications/google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/deploy.py", line 119, in Run
client.DeployModule(module, version, info.parsed, info.file)
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/appengine_client.py", line 276, in DeployModule
return appversion.DoUpload()
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/appengine_deployments.py", line 1016, in DoUpload
missing_files = self.Begin()
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/appengine_deployments.py", line 561, in Begin
payload=config_copy.ToYAML())
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/util.py", line 288, in Send
result = self.rpcserver.Send(url, payload=payload, **kwargs)
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/util.py", line 353, in Send
response = self._server.Send(*args, **kwargs)
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/external/tools/appengine_rpc_httplib2.py", line 269, in Send
'Unexpected HTTP status %s' % status)
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/external/tools/appengine_rpc_httplib2.py", line 67, in RaiseHttpError
raise urllib2.HTTPError(url, response_info.status, msg, response_info, stream)
RPCError: Server responded with code [400]:
Bad Request Unexpected HTTP status 400
ERROR: (gcloud.preview.app.deploy) Server responded with code [400]:
Bad Request Unexpected HTTP status 400
You might have to set the project id again if you have disabled/removed previous application from google cloud console.
gcloud config set project PROJECT_ID
The generic issue is that the error did not have a message.
Starting in the cloud SDK release tomorrow, the reason for whatever error (billing issue, not enough quota, whatever) will be displayed, so please try to get the newer cloud SDK tomorrow.
For me I hadn't enabled billing in Compute > Compute Engine > VM instances on my Google Console project. It works now!
If you have appcfg.py installed, you can run that to deploy and it will give the exact error message, I found mine to be an invalid api_version for the java runtime (to which i can't find the valid number and 1 isn't it)
My initial deployment was fine and after I uploaded the update, it started to fail and get the same errors as you did. I found the issue with oauth. Logout from google and running:
$ gcloud auth login
After relogin, I was able to deploy. No re-coding or Managed VM setting changes were done.

GAE Cloud endpoints not showing in the explorer

i'm new to the cloud endpoint of GAE. I've made a small example, but it does not work,
this is the terminal output:
INFO 2014-04-17 16:34:50,293 sdk_update_checker.py:242] Checking for updates to the SDK.
INFO 2014-04-17 16:34:51,227 sdk_update_checker.py:286] This SDK release is newer than the advertised release.
WARNING 2014-04-17 16:34:51,240 api_server.py:374] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO 2014-04-17 16:34:51,244 api_server.py:171] Starting API server at: http://localhost:64102
INFO 2014-04-17 16:34:51,248 dispatcher.py:182] Starting module "default" running at: http://localhost:8080
INFO 2014-04-17 16:34:51,253 admin_server.py:117] Starting admin server at: http://localhost:8000
INFO 2014-04-17 16:34:58,926 module.py:627] default: "GET /_ah/api/static/proxy.html?jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.5SU5w8-2ONg.O%2Fm%3D__features__%2Fam%3DAQ%2Frt%3Dj%2Fd%3D1%2Fz%3Dzcms%2Frs%3DAItRSTMA_WMz6FduGUvb6_l_lrFfWB57ig HTTP/1.1" 200 7327
INFO 2014-04-17 16:34:59,038 module.py:627] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 404 -
INFO 2014-04-17 16:34:59,038 module.py:627] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 500 60
as you see there's a 404 and a 500, which i don't know why
this is the code i wrote:
import endpoints
from protorpc import messages
from protorpc import message_types
from protorpc import remote
package = 'mypackage'
class YourResponseMessageClass(messages.Message):
message = messages.StringField(1)
#endpoints.api(name='myendpoint', version='v1')
class ExampleAPI(remote.Service):
#endpoints.method(message_types.VoidMessage,
YourResponseMessageClass,
name='foo.bar')
def user_get(self, request):
return YourResponseMessageClass(message="ciao")
APPLICATION = endpoints.api_server([ExampleAPI])
i've all the file in the same folder (can i move the api in subfolder btw?), and my yaml file looks like this:
application: ls-gae-api
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
# Endpoints handler
- url: /_ah/api/.*
script: myfile.APPLICATION
libraries:
- name: webapp2
version: "2.5.2"
- name: endpoints
version: 1.0
Correct path for Endpoints handler must be the following:
# Endpoints handler
- url: /_ah/spi/.*
script: myfile.APPLICATION
Note the spi part (you have api).

Error running using web.py on Google App Engine - application instance has no __call__ method

I've been trying to use web.py to run a simple web app on Google App Engine but have been running into some pretty basic errors. I've searched over the site and haven't found anything to address my issue. Here is the outline of the code I'm trying to run:
import web
urls = (
"/","Index"
)
app = web.application(urls,globals())
render = web.template.render('pages/', base="layout")
class Index:
def GET(self):
#code...
if __name__ == "__main__":
app.cgirun()
and this is the app.yaml code:
application: #appname
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: home.app
- url: /static
static_dir: static
But then I get this in the log:
2013-08-22 06:11:13 Running command: "['C:\\Python27\\pythonw.exe', 'C:\\Program Files\\Google\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=8080', '--admin_port=8000', 'C:\\.....\\root\\home-gae']"
INFO 2013-08-22 06:11:16,956 devappserver2.py:557] Skipping SDK update check.
WARNING 2013-08-22 06:11:16,976 api_server.py:317] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO 2013-08-22 06:11:17,006 api_server.py:138] Starting API server at: http://localhost:64510
INFO 2013-08-22 06:11:17,013 dispatcher.py:164] Starting module "default" running at: http://localhost:8080
INFO 2013-08-22 06:11:17,019 admin_server.py:117] Starting admin server at: http://localhost:8000
ERROR 2013-08-22 10:11:24,303 wsgi.py:235]
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 223, in Handle
result = handler(dict(self._environ), self._StartResponse)
AttributeError: application instance has no __call__ method
INFO 2013-08-22 06:11:24,313 module.py:593] default: "GET / HTTP/1.1" 500 -
The AttributeError is confusing me because there does appear to be a call method in web/application module. Any ideas? Any thoughts would be appreciated.
I found a way to work it out.
import web
urls = (
"/.*", "hello"
)
application = web.application(urls, globals())
#app = web.application(urls, globals())
class hello:
def GET(self):
return "HelloWorld"
#app = app.gaerun()
#app.cgirun()
app = application.wsgifunc()
using "app = application.wsgifunc() ", then the code would work well.
First, there is a little problem with your app.yaml. You need to put your static handler before the catch-all handler:
handlers:
- url: /static
static_dir: static
- url: /.*
script: home.app
Otherwise, you will not be able to serve static files.
To fix your issue with the website not loading, it looks like the development server is trying to treat your CGI app as a WSGI app. Try to fit you home.py file to the official example for web.py on GAE. That is, get rid of the if __name__ == "__main__:" part and simply replace it with:
app = app.gaerun()

Error in deploying my code to Google App Engine

My simple application which just fetches the contents from a given URL is working fine on local server, but on deployment gives error. Check here
The application consists of just two files which I am including here
compare-hatke.py
from google.appengine.api import urlfetch
url = "http://www.google.com/"
result = urlfetch.fetch(url)
if result.status_code == 200:
print(result.content)
app.yaml
application: compare-hatke
version: 3
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: compare-hatke.app
Log - Version 1
Traceback (most recent call last):
File "/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 196, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 269, in _LoadHandler
raise ImportError('%s has no attribute %s' % (handler, name))
ImportError: <module 'compare-hatke' from '/base/data/home/apps/s~compare-hatke/1.365150810067162164/compare-hatke.pyc'> has no attribute app
Now, I am completely clueless why this is not working. Any suggestion or help would be crucial.
Thanks !

Resources