Package not generated from endpointscfg - google-app-engine

I'm trying to generate an Android client lib from my Python endpoints API by running endpointscfg.py
endpointscfg.py get_client_lib java -o . -f rest services.MyApi
The problem I have is that a none-.*-sources.jar is generated, and the client classes are created under a Java package named "none.MyApi".
How can I override the generated package name to fix this?

This is mentioned in the docs. Try specifying the hostname either as a flag to endpointscfg.py when invoked from command line:
endpointscfg.py get_client_lib java \
> --hostname=some-client-id.appspot.com \
> services.MyApi
or in your API definition:
#endpoints.api(name='apiname', version='version',
hostname='some-client-id.appspot.com',
...)

Related

Using SQLAlchemy in AWS LAMBDA

I am trying to use SQL Alchemy in AWS Lambda function but it is throwing error:
module not found.
Also I am attaching the folder structure which I am deploying to Lambda layer after zipping.
I am using the following command to create the folder for lambda layer.
pip3 install sqlalchemy --target Alchemy_layer/
The layer needs a different folder structure according to the documentation.
Try this:
pip3 install sqlalchemy --target python/
zip -r sqlalchemy-layer.zip python/
Upload that ZIP as layer and try again.

How to set up Google App Engine PHP SDK on Ubuntu

I tried to follow the instructions on
https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_PHP
When I start up the app engine with the hello world example like this:
go_appengine/dev_appserver.py --php_executable_path=/home/jan/php-5.4.25/installdir/bin/php-cgi helloworld/
I get a error in the console saying:
ERROR php_runtime.py:348] The PHP runtime is not available
If I go to localhost:8080, I get:
The PHP interpreter specified with the --php_executable_path flag
("/home/jan/php-5.4.25/installdir/bin/php-cgi") is not compatible with
the App Engine PHP development environment.
No input file specified.
I thought maybe they just refered to an old version or something in the docs, so I also tried the same method with php 5.5.30, and even just apt-get php5-cgi changing php_executable_path each time with the same result.
This is on a fresh install of ubuntu 14.04 on a VM.
Anyone know what's going on here?
EDIT:
app.yaml
application: helloworld
version: 1
runtime: php55
api_version: 1
handlers:
- url: /.*
script: helloworld.php
OUTPUT:
INFO 2016-01-05 12:11:42,024 sdk_update_checker.py:229] Checking for updates to the SDK.
INFO 2016-01-05 12:11:42,299 sdk_update_checker.py:257] The SDK is up to date.
INFO 2016-01-05 12:11:42,355 api_server.py:205] Starting API server at: http://localhost:37460
INFO 2016-01-05 12:11:42,357 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
INFO 2016-01-05 12:11:42,360 admin_server.py:116] Starting admin server at: http://localhost:8000
ERROR 2016-01-05 12:11:43,418 php_runtime.py:348] The PHP runtime is not available
Traceback (most recent call last):
File "/appengine/google/appengine/tools/devappserver2/php_runtime.py", line 344, in new_instance
self._check_binaries(php_executable_path, gae_extension_path)
File "/appengine/google/appengine/tools/devappserver2/php_runtime.py", line 284, in _check_binaries
cls._check_environment(php_executable_path, env)
File "/appengine/google/appengine/tools/devappserver2/php_runtime.py", line 259, in _check_environment
raise _PHPEnvironmentError(check_process_stdout)
_PHPEnvironmentError: No input file specified.
Does the same error appear on multiple projects/apps or just one project/app? Is your app.yaml configured to display PHP pages properly?
The official documentation on this subject did not work for me either (and does not cover PHP 5.5 usage instructions).
I had to compile a custom PHP 5.5 CGI binary for my PHP SDK on Ubuntu 14.04.
Note: the following worked on my system, and there might be some variables per system which need adjusting.
Download the source for PHP 5.5.30 and open the directory in your terminal
$ cd /downloaded/php/source/dir/path
ls should display a configure file inside the directory. Then inside the source directory run a configure as follows (\ for formatting, can be left out and make the command one-line):
$ ./configure --prefix=/php/5.5/ \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-mbstring \
--enable-opcache \
--enable-soap \
--enable-sockets \
--enable-zip \
--disable-fileinfo \
--disable-flatfile \
--disable-posix \
--with-curl \
--with-gd \
--with-openssl \
--without-sqlite3 \
--without-pdo-sqlite \
--without-imap \
--without-kerberos \
--without-imap-ssl \
--without-interbase \
--without-ldap \
--without-mssql \
--without-oci8 \
--without-pgsql \
--without-pear \
--disable-phar \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-mysql=mysqlnd
Then just
$ sudo make && sudo make install
The prefix then sets the make && make install commands to install the php-cgi binary into /php/5.5/bin/php-cgi, which is the binary to use in the SDK's --php_executable_path (i.e. --php_executable_path=/php/5.5/bin/php-cgi).
Additionally, make sure the PHP SDK has the permission to run the php-cgi executable some way, e.g. chown the PHP installation to the same user who runs the SDK.
Note: if you try to install php-memcache(d) for the SDK executable, the SDK will not work with it. As far as I know the SDK uses some internal mechanism to emulate memcached usage in the dev server. Some other extensions also trigger SDK errors like this.
Sorry, but I had downloaded the SDK for Go instead of PHP. Thank you for trying to help me.

How can I debug a Dart AppEngine app

I'm now able to run a Dart app using
gcloud --verbosity debug preview app run app.yaml
and also to deploy and run on AppEngine
gcloud --verbosity debug preview app deploy app.yaml
but I haven't found a way to connect a debugger to the Dart app running on the development server.
I found http://dartbug.com/21067 but still couldn't find a way to make it work.
See also https://groups.google.com/a/dartlang.org/forum/#!topic/cloud/OK1nJtg7AjQ
Update 2015-02-27
The app can be run without Docker and then be debugged like any Dart command line application:
Source. https://groups.google.com/a/dartlang.org/d/msg/cloud/zrxgOHFz_lA/q5CdLLQPBAgJ
The API server is part of the App Engine SDK, and we are using it for
running tests in the appengine package. If you look at
https://github.com/dart-lang/appengine/blob/master/tool/run_tests.sh
you will see that it expects the environment variable
APPENGINE_API_SERVER.
The API server is in /platform/google_appengine/api_server.py
and takes a number of arguments. I just tested running it like this:
$ $CLOUD_SDK/platform/google_appengine/api_server.py \ -A
dev~test-application \ --api_port 4444 \ --high_replication \
--datastore_path /tmp/datastore
To run an app engine application outside the normal development server
requires that a number of environment variables are set. This worked
for my application:
$ GAE_LONG_APP_ID=test-application \ GAE_MODULE_NAME=default \
GAE_MODULE_VERSION=version \ GAE_PARTITION=dev \ API_PORT=4444 \
API_HOST=127.0.0.1 \ dart bin/server.dart
In the Dart Editor you cannot set environment variables for each
launch configuration, so they have to be set globally before starting
the Dart Editor. In WebStorm it is possible to have run configuration
specific environment variables.
This simple setup will of cause not support everything the normal
development server support. Some of the issues are:
Only one application at the time as it is always listening on port
8080 (can easily be made configurable) * The users API (mocking this
shouldn't be that difficult) * The modules API * No health-checks
(should not be a problem) * All HTTP headers are direct from the
client (no x-appengine- headers) * The admin web interface is not
available * Probably other stuff as well
This is all experimental, but it is one solution for a simpler
developer setup, which of cause does not match the deployment
environment as closely as the development server.
Running the API Server using Docker is also possible as the image
google/cloud-sdk with the Cloud SDK is on hub.docker.com.
Use the following Dockerfile
FROM google/cloud-sdk EXPOSE 4444 ENTRYPOINT
["/google-cloud-sdk/platform/google_appengine/api_server.py", \
"-A", "dev~test-application", \ "--api_port", "4444", \
"--high_replication", \ "--datastore_path", "/tmp/datastore"]
Build and run
$ docker build -t api_server . $ docker run -d -p 4444:4444 api_server
Change API_HOST above to 192.166.59.103 (of wherever your Docker
containers are) and run.
Regards, Søren Gjesse
Update 2014-11-27
Debugging from DartEditors debugger started working with the bleeding Dart build 1.8.0.edge_042017.
I assume that the next dev build (probably 1.9.0-dev1.0) will include the related fixes as well?
Detailed steps how this works can be found here: https://groups.google.com/a/dartlang.org/d/msg/cloud/OK1nJtg7AjQ/u-GzUDI-0VIJ
Build a custom Docker image with the latest Dart dev build 1.8.0-dev.4.6.
The Dart team is actually preparing an easy way to do this yourself (see https://github.com/dart-lang/dart_docker)
Installe the latest bleeding_edge on the host system (using this script https://gist.github.com/zoechi/d240f56a32ed5649797f or manual download from http://gsdview.appspot.com/dart-archive/channels/be/raw/latest/editor/darteditor-linux-x64.zip)
Add this to the app.yaml file
env_variables:
DBG_ENABLE: 'true'
# disable health-checking because this is so annoying during debugging
vm_health_check:
enable_health_check: False
See How to disable health checking for `gcloud preview app run` for more details about customizing health checking.
Launch the server code of your app with glcoud --verbosity debug app run app.yaml or glcoud --verbosity debug app run app.yaml index.yaml
Wait until the Docker container is ready (check with docker ps if the Command column shows a value starting with /dart_runtime/dart_
Open DartEditor
Open Menu Run > Remote Connection...
Connect to: Command-line VM
Host: localhost if you dont use boot2dockeror the IP address returned by the commandboot2docker ip`
Port: 5005
Select Folder... select the directory which contains the source code of your project.
Click OK
Set breakpoints and continue as usual.
Old
A first step is using the Observatory which includes a browser based debugger UI.
To make this work add the following lines to the app.yaml file
network:
forwarded_ports: ["8181"]
This might be useful as well to make the server.dart wait until we had the chance to set breakpoints using the observatory.
env_variables:
DART_VM_OPTIONS: '--pause-isolates-on-start'
boot2docker gives us the Docker ip (192.168.59.103) and after starting with gcloud preview app run app.yaml we can connect to http://192.168.59.103:8181 which should open the Observatory GUI.

Google App Engine endpointscfg.py command starting 1.8.6 does not accept argument -f

This problem just started in Google App Engine version 1.8.6:
When executing command (based on instruction https://developers.google.com/appengine/docs/python/endpoints/gen_clients):
endpointscfg.py get_client_lib java -o . -f rest your_module.YourApi
We get error:
endpointscfg.py: error: unrecognized arguments: -f
The command with argument -f execute without any issue for Google App Engine version 1.8.5.
With 1.8.6, I don't know how to generate client end point library, because of this error. If you have a workaround, please help.
When you use get_client_lib to generate client library, rest format is the only option. So if you intend to generate a Rest client library, simply remove ".f rest" option. And you will get your Rest client without any problem.
If you want to use RPC client (which is currently only supported in iOS client). Please refer to https://developers.google.com/appengine/docs/python/endpoints/consume_ios for instruction.
I think one piece might be missing from the documentation above. In order to get the api-v1-rpc.discovery, you need to run get_discovery_doc command like following:
endpointscfg.py get_discovery_doc -o . -f rpc your_module.YourApi
Hope it helps.

wsgen not creating wsdl file

I was following http://code.google.com/appengine/articles/soap.html to create a Web Service in Google App Engine. After reach item no 4, where i need to run wsgen to generate wsdl file for my Web Service, I found the sample syntax was given for Linux. I managed to find the syntax for Window but when i run it, It creates a package called jaxws but no xsd and wsdl file created. It only creates package com.example.jaxws and no other java files created in side the package.
What I did:
1st I compile the java file in CMD
C:\Smartag_Eclipse_Project\HelloSOAPServer\src>javac com\example\Greeter.java
2nd I run wsgen
C:\Smartag_Eclipse_Project\HelloSOAPServer\src>wsgen -cp . com.example.Greeter -
wsdl
Appreciate if someone could help me on this. Thanks.
Problem solved.
wsgen -cp C:\Smartag_Eclipse_Project\HelloSOAPServer\war\WEB-INF\classes -wsdl -keep -r C:\Smartag_Eclipse_Project\HelloSOAPServer\war -d C:\Smartag_Eclipse_Project\HelloSOAPServer\war\WEB-INF\classes -s C:\Smartag_Eclipse_Project\HelloSOAPServer\src com.example.Greeter

Resources