2

I don't know if this should be posted under serverfault or stackoverflow. I don't know if it's a locale problem on my server or if it's python or the OpenERP application that is acting up.

I have a OpenERP system and I have encountered a quite strange problem.

In the openERP modules there are some "print"-lines that various developers used for debugging the application.

Like these:

print "Value: %s" % variable

and

 print "Value: " + str(variable)

If I start OpenERP in a ordinary terminal it will run just fine in the foreground and print the debug log and the prints in the console. The application never gives me an exception.

Now to the problem!

Earlier I've started the application in a screen so that I could detach it and close my connection to the server while the application is till running.

The code does not throw any exception when run in a 'screen'

Instead of a screen I want to have init.d script. I've made this script:

#!/bin/sh

# Configuration variables for openerp
DAEMON="/opt/openerp-server-6.0.3/bin/openerp-server.py"
ARGS="--config=/opt/openerp-server-6.0.3/openerp-server.conf"
NAME="openerp"
USER="openerp"
DESC="openerp"
PIDFILE="/var/run/$NAME.pid"

# Startup alternatives
case "$1" in
        start)
                echo "Starting ${DESC}"
                start-stop-daemon --start --background --pidfile $PIDFILE --chuid $USER --make-pidfile --exec $DAEMON -- $ARGS
                ;;
        stop)
                echo "Stopping ${DESC}"
                start-stop-daemon --stop --quiet --pidfile /var/run/${NAME}.pid --oknodo
                echo "${NAME}."
                ;;
        *)
                echo "Usage: start|stop"
        ;;
esac

The script works, it start and stops the server.

When I use the module that imports data from a excel file I get this exception. I also get the exception in other places in the code where it tries to print a string containing the swedish letters 'åäö'.

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 3: ordinal not in range(128)

I thought it was something with the 'start-stop-daemon' command that changed the locale or somthing. So instead of forceing the application to the background with the argument '--background' I tried this:

start-stop-daemon --start --pidfile $PIDFILE --chuid $USER --make-pidfile --exec $DAEMON -- $ARGS &> /dev/null

This solved the UnicodeEncodeError. All joy I thought. But!

Now I get a Input/Output error

IOError: [Errno 5] Input/output error

And the code that generates this

print pay_order

The 'pay_order' variable is a string that sometimes contain 'åäö'.

I can't understand why it behaves like this.

4

1 回答 1

0

I have experienced the Unicode errors while using print for debugging errors similar to what you describe.

I think you should solve the problem at it's root: use grep to find the lines with print commands in the addons, and comment them out with #. The print command is never used in the standard modules.

于 2012-10-17T22:42:32.240 回答