Running local GAE - google-app-engine

I have followed these instructions:
https://cloud.google.com/appengine/docs/php/quickstart
I had to manually associate the bundled python with .py files. When I run:
dev_appserver.py --port 8087 helloworld/
I get "too few parameters" errors?
Googling has hinted at having to explicitly state the PHP binary, etc...but the docs linked above are very clear this is not required for Windows (7) as GAE comes with a bundled PHP environment.
What am I missing? What happened to the GUI launcher - that worked nicely for me :)
C:\Users\alex.DOMAIN\Desktop\temp>dev_appserver.py "temp\helloworld\"
usage: dev_appserver.py [-h] [-A APP_ID] [--host HOST] [--port PORT]
[--admin_host ADMIN_HOST] [--admin_port ADMIN_PORT]
[--auth_domain AUTH_DOMAIN] [--storage_path PATH]
[--log_level {debug,info,warning,critical,error}]
[--max_module_instances MAX_MODULE_INSTANCES]
[--use_mtime_file_watcher [USE_MTIME_FILE_WATCHER]]
[--threadsafe_override THREADSAFE_OVERRIDE]
[--php_executable_path PATH]
[--php_remote_debugging [PHP_REMOTE_DEBUGGING]]
[--php_gae_extension_path PATH]
[--php_xdebug_extension_path PATH]
[--appidentity_email_address APPIDENTITY_EMAIL_ADDRESS]
[--appidentity_private_key_path APPIDENTITY_PRIVATE_KEY_
PATH]
[--python_startup_script PYTHON_STARTUP_SCRIPT]
[--python_startup_args PYTHON_STARTUP_ARGS]
[--jvm_flag JVM_FLAG]
[--custom_entrypoint CUSTOM_ENTRYPOINT]
[--runtime RUNTIME] [--blobstore_path BLOBSTORE_PATH]
[--mysql_host MYSQL_HOST] [--mysql_port MYSQL_PORT]
[--mysql_user MYSQL_USER]
[--mysql_password MYSQL_PASSWORD]
[--mysql_socket MYSQL_SOCKET]
[--datastore_path DATASTORE_PATH]
[--clear_datastore [CLEAR_DATASTORE]]
[--datastore_consistency_policy {consistent,random,time}
]
[--require_indexes [REQUIRE_INDEXES]]
[--auto_id_policy {sequential,scattered}]
[--logs_path LOGS_PATH]
[--show_mail_body [SHOW_MAIL_BODY]]
[--enable_sendmail [ENABLE_SENDMAIL]]
[--smtp_host SMTP_HOST] [--smtp_port SMTP_PORT]
[--smtp_user SMTP_USER]
[--smtp_password SMTP_PASSWORD]
[--smtp_allow_tls [SMTP_ALLOW_TLS]]
[--prospective_search_path PROSPECTIVE_SEARCH_PATH]
[--clear_prospective_search [CLEAR_PROSPECTIVE_SEARCH]]
[--search_indexes_path SEARCH_INDEXES_PATH]
[--clear_search_indexes [CLEAR_SEARCH_INDEXES]]
[--enable_task_running [ENABLE_TASK_RUNNING]]
[--allow_skipped_files [ALLOW_SKIPPED_FILES]]
[--api_port API_PORT]
[--automatic_restart [AUTOMATIC_RESTART]]
[--dev_appserver_log_level {debug,info,warning,critical,
error}]
[--skip_sdk_update_check [SKIP_SDK_UPDATE_CHECK]]
[--default_gcs_bucket_name DEFAULT_GCS_BUCKET_NAME]
yaml_path [yaml_path ...]
dev_appserver.py: error: too few arguments
here is my app.yaml:
runtime: php55
api_version: 1
handlers:
- url: /.*
script: helloworld.php

This has many possible problems and solutions, and has been asked before. Check out:
GAE Python : dev_appserver.py: error: too few arguments
Starting Google App Engine Web Server
Google App Engine PHP on windows
https://github.com/wri/api-hello-world/issues/1

Try: dev_appserver.py --port=8087 helloworld/
EDIT: Make sure that helloworld/ exists in your current directory, and that it contains a valid app.yaml

Related

how to set up 'chromedriver.exe' executable in PATH on gitlab ci

class Application(object):
def __init__(self):
self.driver = webdriver.Chrome(executable_path='C:/Users/Admin/365_python_test/chromedriver.exe')
this is my initialization of webdriver. It works fine on my machine, but when I push code to gitlab CI I get error 'chromedriver.exe' executable needs to be in PATH. As I understand I must set up Path in .gitlab-ci.yml in 'before script' section but I don't know how to do it. I tried different script I found here but it doesn't work. I tried also:
self.driver = webdriver.Chrome(ChromeDriverManager().install())
which doesn't work on CI as well:
venv/lib/python3.7/site-
packages/selenium/webdriver/common/service.py:111: WebDriverException
---------------------------- Captured stdout setup ---------------------
--------
Checking for linux64 chromedriver:2.46 in cache
There is no cached driver. Downloading new one...
Trying to download new driver from
http://chromedriver.storage.googleapis.com/2.46/chromedriver_linux64.zip
Unpack archive /root/.wdm/chromedriver/2.46/linux64/chromedriver.zip
=========================== 1 error in 1.30 seconds
============================
ERROR: Job failed: exit code 1
Help, please!

Starting Go server on App Engine localhost throws error

Can anyone tell me why this is happening:
$ dev_appserver.py nmg_server
INFO 2017-07-08 17:15:37,369 application_configuration.py:461] No version specified. Generated version id: 20170708t171537
WARNING 2017-07-08 17:15:37,369 application_configuration.py:166] The Managed VMs runtime is deprecated, please consider migrating your application to use the Flexible runtime. See https://cloud.google.com/appengine/docs/flexible/python/migrating for more details.
INFO 2017-07-08 17:15:37,472 devappserver2.py:116] Skipping SDK update check.
INFO 2017-07-08 17:15:37,513 api_server.py:312] Starting API server at: http://localhost:54096
INFO 2017-07-08 17:15:37,517 api_server.py:938] Applying all pending transactions and saving the datastore
INFO 2017-07-08 17:15:37,517 api_server.py:941] Saving search indexes
Traceback (most recent call last):
File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 103, in <module>
_run_file(__file__, globals())
File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 97, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 381, in <module>
main()
File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 369, in main
dev_server.start(options)
File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 196, in start
options.api_host, apiserver.port, wsgi_request_info_, options.grpc_apis)
File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 223, in start
_module.start()
File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 1647, in start
self._add_instance()
File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 1799, in _add_instance
expect_ready_request=True)
File "/Users/dgaedcke/gcloud_tools/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/go_runtime.py", line 189, in new_instance
self._go_application.maybe_build()):
TypeError: maybe_build() takes exactly 2 arguments (1 given)
I'm trying to run my server for testing on localhost and it keeps exiting with this error
This appears to be a bug in Cloud SDK which is affecting dev_appserver.py when using with App Engine Managed VMs. It does not seem to be affecting App Engine Standard or App Engine Flex environments.
Until Google releases a new Cloud SDK with the fix, you can modify the CLOUD_SDK_INSTALL_DIR//platform/google_appengine/google/appengine/tools/devappserver2/go_managedvm.py file locally as shown below (added both the patchable unified diff as well as before/after just for convenience).
Also consider moving to App Engine Flex since Managed VMs are deprecated and will not be supported after October 27, 2017.
Warning: The Managed VMs beta environment (applications deployed with
vm:true) is deprecated and will be decommissioned. This page is for
users who are already using the flexible environment with vm:true in
their app.yaml and want to upgrade to the latest release. If you are
updating your application from the standard environment, see the
Migrating Services from the Standard Environment to the Flexible
Environment instead.
Diff in patchable format
--- /Users/tuxdude/google-cloud-sdk-orig/platform/google_appengine/google/appengine/tools/devappserver2go_managedvm.py 2017-07-08 11:11:11.000000000 -0700
+++ /Users/tuxdude/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/go_managedvm.py 2017-07-08 11:11:11.000000000 -0700
## -152,15 +152,9 ##
logging.debug('Build succeeded:\n%s\n%s', stdout, stderr)
self._go_executable = exe_name
- def maybe_build(self, maybe_modified_since_last_build):
+ def maybe_build(self):
"""Builds an executable for the application if necessary.
- Args:
- maybe_modified_since_last_build: True if any files in the application root
- or the GOPATH have changed since the last call to maybe_build, False
- otherwise. This argument is used to decide whether a build is Required
- or not.
-
Returns:
True if compilation was successfully performed (will raise
an exception if compilation was attempted but failed).
## -173,9 +167,6 ##
self._work_dir = tempfile.mkdtemp('appengine-go-bin')
atexit.register(_rmtree, self._work_dir)
- if self._go_executable and not maybe_modified_since_last_build:
- return False
-
if self._go_executable:
logging.debug('Rebuilding Go application due to source modification')
else:
Before:
def maybe_build(self, maybe_modified_since_last_build):
"""Builds an executable for the application if necessary.
Args:
maybe_modified_since_last_build: True if any files in the application root
or the GOPATH have changed since the last call to maybe_build, False
otherwise. This argument is used to decide whether a build is Required
or not.
Returns:
True if compilation was successfully performed (will raise
an exception if compilation was attempted but failed).
False if compilation was not attempted.
Raises:
BuildError: if building the executable fails for any reason.
"""
if not self._work_dir:
self._work_dir = tempfile.mkdtemp('appengine-go-bin')
atexit.register(_rmtree, self._work_dir)
if self._go_executable and not maybe_modified_since_last_build:
return False
if self._go_executable:
logging.debug('Rebuilding Go application due to source modification')
else:
logging.debug('Building Go application')
self._build()
return True
After:
def maybe_build(self):
"""Builds an executable for the application if necessary.
Returns:
True if compilation was successfully performed (will raise
an exception if compilation was attempted but failed).
False if compilation was not attempted.
Raises:
BuildError: if building the executable fails for any reason.
"""
if not self._work_dir:
self._work_dir = tempfile.mkdtemp('appengine-go-bin')
atexit.register(_rmtree, self._work_dir)
if self._go_executable:
logging.debug('Rebuilding Go application due to source modification')
else:
logging.debug('Building Go application')
self._build()
return True

How to use Axis2c to generate C files from WSDL file

I want to use a webservice in C code. I am trying to make a client. I need something to do what Axis2java does and generates the classes from a wsdl files.
I found that Axis2c makes (.c) files generated from wsdl file.
I downloaded it from here . unzipped it. I created the environment variable for AXIS2C_HOME and I created AXIS2C_CLASSPATH.
but I can't make it work.
when I type this command :
WSDL2C -uri -ss -sd -d none -u -f -o
I get this error :
echo off
Error: Could not find or load main class org.apache.axis2.wsdl.WSDL2C
how can I solve this problem. and please tell me how to use this Axis2c tool properly.
Thank you in advance.
#loentar : I installed Axis2/Java and I set the environment variable for it. now I run the wsdl2c.bat I get this :
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>WSDL2C.bat
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>echo off
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server.
-cp
-classpath
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D=
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:...|:]
-enableassertions[:...|:]
enable assertions with specified granularity
-da[:...|:]
-disableassertions[:...|:]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:[=]
load native agent library , e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:[=]
load native agent library by full pathname
-javaagent:[=]
load Java programming language agent, see java.lang.instrument
-splash:
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m
ore details.
after that I run this command :
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>WSDL2C.bat -uri hello.wsdl
-u -uw
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>echo off
Unrecognized option: -uri
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
what can I do ?
I'm using windows 8 by the way.
In addition to Axis2/C you must have Axis2/Java installed.
AXIS2_HOME must point to Axis2/Java installation.
For details please see README of codegen.
The complete list of commands to create and compile client is:
# create stubs
sh $AXIS2C_HOME/bin/tools/wsdl2c/WSDL2C.sh -uri Calculator.wsdl -u -uw
# implement main() in src/your_client.c
# see samples/codegen/client/calculator for example
# compile and link client
gcc -o calculator_client src/*.c -I$AXIS2C_HOME/include/axis2-1.6.0 -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -laxis2_engine -lpthread -laxis2_http_sender -laxis2_http_receiver -ldl -Wl,--rpath -Wl,$AXIS2C_HOME/lib
I set the envinroment variable for JAVA_HOME, AXIS2_HOME, AXIS2C_HOME, and added their lib folder to CLASSPATH. after running this command:
WSDL2C.bat -uri hello.wsdl -u -uw
I got this message:
echo off
Error: Could not find or load main class org.apache.axis2.wsdl.WSDL2C
I found the solution myself. :)
I double checked if I had created the environment variable for AXIS2_HOME and I saw that it is there, correctly.
in spite of it's existence I tried to set it again in command prompt. so I typed:
SET AXIS2_HOME=E:\dev\Tools\axis2-1.6.2
then I typed the command for WSDL2C code generator:
WSDL2C.bat -uri hello.wsdl -u -uw
And BAM ! it worked properly.
Now I can generate C files from WSDL file.

How to get rid of SolrJ logging error? No appenders could be found for logger (org.apache.solr.client.solrj.impl.HttpClientUtil)

log4j:WARN No appenders could be found for logger (org.apache.solr.client.solrj.impl.HttpClientUtil).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
I'm using SolrJ as a library in a custom Java app.
Here are the jars in my app:
lib/c3p0-0.9.5-pre8.jar
lib/commons-exec-1.2.jar
lib/lucene-analyzers-common-4.8.0.jar
lib/mchange-commons-java-0.2.7.jar
lib/mysql-connector-java-5.0.8-bin.jar
lib/solr-core-4.7.2.jar
lib/solr-solrj-4.7.2.jar
lib/solrj-lib:
commons-io-2.1.jar
httpclient-4.3.1.jar
httpcore-4.3.jar
httpmime-4.3.1.jar
jcl-over-slf4j-1.6.6.jar
jul-to-slf4j-1.6.6.jar
log4j-1.2.16.jar
noggit-0.5.jar
slf4j-api-1.6.6.jar
slf4j-log4j12-1.6.6.jar
wstx-asl-3.2.7.jar
zookeeper-3.4.5.jar
And here's my log4j.properties file, which is located in my $ROOT/src/ folder. When I remove this file, the logger starts outputting lots of debug logs, so I know it's being detected at some level.
# Logging level
solr.log=log/
#log4j.rootLogger=INFO, file, CONSOLE
log4j.rootLogger=INFO
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%-4r [%t] %-5p %c %x \u2013 %m%n
log4j.logger.com.mchange.v2.c3p0=DEBUG
log4j.category.com.mchange=DEBUG
log4j.logger.com.mchange=DEBUG
#- size rotation with log cleanup.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=4MB
log4j.appender.file.MaxBackupIndex=9
#- File to log to and log format
log4j.appender.file.File=${solr.log}/solr.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-5p - %d{yyyy-MM-dd HH:mm:ss.SSS}; %C; %m\n
log4j.logger.org.apache.zookeeper=WARN
log4j.logger.org.apache.hadoop=WARN
# set to INFO to enable infostream log messages
log4j.logger.org.apache.solr.update.LoggingInfoStream=OFF
Please this config and place it in the directory src/test/resources
log4j.properties :
# Root logger option
log4j.rootLogger=INFO, stdout
log4j.logger.com.rizze.xx.tools=DEBUG
log4j.logger.com.rizze.yy.inject=DEBUG
log4j.logger.com.rizze.zz.tools.db=DEBUG
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
you can use the command as a VM argument when you call your program : -Dlog4j.debug=true
in order to debug the log4j config.
please take also a look to solr wiki that seems to be hard, but that is great! :)

GAE creating a new project?

i have been working on GAE - tried to create a new project: and getting an error on command
abid#abid-webdev:~/Documents/GAE_projects$ python google_appengine/dev_appserver.py exe1.py/
ERROR
INFO 2013-10-29 08:27:57,104 module.py:608] default: "GET / HTTP/1.1" 500 -
ERROR 2013-10-29 08:29:43,171 wsgi.py:262]
Traceback (most recent call last):
File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 298, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 84, in LoadObject
obj = import(path[0])
ImportError: No module named helloworld
INFO 2013-10-29 08:29:43,191 module.py:608] default: "GET / HTTP/1.1" 500 -
ERROR 2013-10-29 08:29:51,775 wsgi.py:262]
Traceback (most recent call last):
File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 298, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py", line 84, in LoadObject
obj = import(path[0])
ImportError: No module named helloworld
1) ImportError: No module named helloworld -> i noticed this error
currently working on this project exercise1, copied app.yaml file from previous project helloworld/
checked app.yaml and it's content are as follows:
application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.application>
2) on google URL -> Every request to a URL whose path matches the regular expression /.* (all URLs) should be handled by the application object in the helloworld module.
3) my directory structure
abid#abid-webdev:~/Documents/GAE_projects$ ls
exercise1
helloworld
google_appengine
Question:
how can i modify my app.yaml to work with my other projects e.g.
exercise1?
thanks all for your help.
Let's take this from the top!
For your new project you will need to have this structure in the exercise1 directory:
Directory: exercise1
File: app.yaml
File: exercise1.py
In the app.yaml you'll need something like this:
application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: exercise1.application
The line "script: exercise1.application" tells it which file to use (in this case exercise1.py) and the instance of a WSGI Handler to use (in this case application)
In exercise1.py you'll need something like this:
import webapp2
class HomePage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hey Y'all!')
application = webapp2.WSGIApplication([
('/', HomePage),
], debug=True)
Here you can see application that we referred to in app.yaml.
Once you have this basic structure you need to start the dev appserver. The way you are doing it in the question is incorrect:
You need to run the dev_appserver with the directory "exercise1", not a python file.
Assuming that the Google App Engine sdk is still located at "~/Documents/GAE_projects/google_appengine" run the following command from the exercise1 directory:
python ~/Documents/GAE_projects/google_appengine/dev_appserver.py ./
This will start the dev_appserver.py script telling it to use the current directory (which is what the "./" means).
If you follow this, then you should be up and rolling!

Resources