I'm not sure if this will completely solve your problem, but here is what I learned trying to get pyro-nsd
working with python2.7. I used Ubuntu 14.04 in this case. It may be different on the Wheezy version.
- I installed using
sudo apt-get install pyro4
since pyro4-nsd
is not installed via pip.
- First thing I notice is that
pyro4-nsc list
was not recognized.
- So then I pyro4 using
sudo pip install pyro4
.
- Now
pyro4-nsc list
works, but I get the Failed to locate the nameserver
error.
So I took a look at the configuration for /etc/init.d/pyro4-nsd
and found some interesting things.
1.
The script checks if python3 is installed. If it is, it will use the python3 version of pyro4, which gets installed as a dependency with sudo apt-get install pyro4
.
Here I just make it use python2.7
.
Now pyro4-nsc list
actually works, but I get this error: Error: CommunicationError - cannot connect: hmac key config not symmetric
, which leads to number 2
2.
Next thing I notice is the export PYRO_HMAC_KEY=12345
line in the pyro4-nsd
.
In the Pyro4/configuration.py
file, it seems this is only used for python3: (https://github.com/delmic/Pyro4/blob/ccea9c2870a1280010bcc56f4146bc1617ec6e8d/src/Pyro4/configuration.py#L81). See this snippet here:
if self.HMAC_KEY and sys.version_info>=(3,0):
if type(self.HMAC_KEY) is not bytes:
self.HMAC_KEY=bytes(self.HMAC_KEY, "utf-8") # convert to bytes
So, basically I just removed the PYRO_HMAC_KEY
export line.
3.
Minor thing but doing sudo service pyro4-nsd restart
, starts and then stops the service when it should stop the service and then start it.
Here is the modified pyro4-nsd file:
#!/bin/sh
### BEGIN INIT INFO
# Provides: pyro4-nsd
# Required-Start: $time $local_fs $remote_fs $network
# Required-Stop: $time $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Pyro4 name server daemon
# Description: Debian init script for pyro4-nsd (Pyro4 name server daemon)
### END INIT INFO
# -------------------------------------------------------------------------
# <Pyro4 NameServer Daemon Script>
# Copyright (C) <2011> <Pierre PACORY> - ppacory@gmail.com
# Licensed under the "MIT Software License" for inclusion in Pyro4.
# -------------------------------------------------------------------------
LISTEN_ADDRESS=0.0.0.0
LISTEN_PORT=9999
MESSAGEDIR=/var/log/Pyro4
MESSAGELOG=/var/log/Pyro4/NameServer.log
PID=/var/run/Pyro4-NameServer.pid
# Defaults - don't touch, edit /etc/default/pyro-nsd
ENABLED=0
if [ -f /etc/default/pyro4-nsd ] ; then
. /etc/default/pyro4-nsd
fi
if [ "$ENABLED" = "0" ]; then
echo "pyro4-nsd: disabled, see /etc/default/pyro4-nsd"
exit 0
fi
# Add Pyro Config
# here you can add others ...
# NOTE: Comment out PYRO_HMAC_KEY since it appears to be used only for Python3
#export PYRO_HMAC_KEY=12345
export PYRO_LOGFILE="$MESSAGELOG"
export PYRO_LOGLEVEL=DEBUG
. /lib/lsb/init-functions
# Check the script is being run by root user
if [ "$(id -u)" != "0" ]; then
echo 1>&2 "ERROR: The $0 script must be run as root"
exit 1
fi
# Create the PID File
touch $PID
# Detect if Python 2.x or Python 3.y is installed
# NOTE: For the use of python2.7 here
PYTHON=python2.7
[ -x /usr/bin/$PYTHON ] || PYTHON=python
case "$1" in
start)
# create the log directory if not exist
[ ! -d "$MESSAGEDIR" ] && mkdir -p "$MESSAGEDIR"
echo "Starting Pyro4 Name Server"
# test if not already running
if [ ! -f "/proc/$(cat $PID)/exe" ]; then
$PYTHON -m Pyro4.naming -n "$LISTEN_ADDRESS" -p "$LISTEN_PORT" >/dev/null 2>&1 &
echo $!>"$PID"
else
echo "Pyro4 Name Server already running"
fi
;;
stop)
echo "Stopping Pyro4 Name Server"
# test if running
if [ -f "/proc/$(cat $PID)/exe" ]; then
kill -9 "$(cat $PID)"
rm -rf "$PID"
else
echo "Pyro4 Name Server already stopped"
fi
;;
restart)
# Stop, then Start
$0 stop
$0 start
;;
force-reload)
# Stop, then Start
$0 stop
$0 start
;;
*)
echo "usage: $0 {start|stop|restart|force-reload}"
esac
exit 0