Open WPS Platform

How To Debug ZOO Services

Authors:Luca Delucchi
Last Updated:$Date: 2013-03-27 00:06:12 +0100 (Wed, 27 Mar 2013) $

There are different ways to debug your services, the most used solutions are via web or via command line.

Web

Using the web request you can see any problem in the log file of Apache.

On Unix system the log file is usually in /var/log/apache2 and the relevant file is error_log. A simple way to read the file is to use the tail command, it permits to see the update of the file for each request

tail -f /var/log/apache2/error_log

If the log is not clear enough you can add some more debug information to your code. You have to write to standard error.

Python

Using Python, you can for example do this

import sys

#add this line when you want see an own message
sys.stderr.write("My message")

Javascript

You can user alert to print a string to standard error:

// add this line when you want see an own message
alert('My message')
// you can debug value of inputs, outputs or conf
alert(inputs["S"]["value"])

Note

If you try to pass an object it will only return [object Object]

Command line

It is possible to use the ZOO kernel zoo_loader.cgi also from command line. This is really useful to debug in a deeper way your service:

# in order to use it you have to copy test_service.py and HelloPy.zcfg from
# the example services
./zoo_loader.cgi "service=wps&version=1.0.0&request=execute&identifier=HelloPy&datainputs=a=your name&responsedocument=Result"

Working this way you can use the standard debug system of the actual programming language used to develop your service.

GDB

From command line you can use also the command line tool GDB to debug zoo_loader.cgi, you have to run:

# launch zoo_loader.cgi from gdb
gdb zoo_loader.cgi
# now run your request
run "service=wps&version=1.0.0&request=execute&identifier=HelloPy&datainputs=a=your name&responsedocument=Result"

At this point you can ask help at the ZOO mailing list copying the result of the command.

Python

For Python, you can use pdb, more info at http://docs.python.org/2/library/pdb.html

import pdb

# add this line when you want investigate your code in more detail
pdb.set_trace()

Javascript

You can use alert also to print in the console, more info in the Javascript web section