diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-10 17:05:51 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-10 17:11:37 +0200 |
| commit | 45ee6b4e2cd55b901770578e6915312e7792edae (patch) | |
| tree | 01ee3c661f2c9be67e1ac92628740423c1581f0d | |
| parent | 4bb5053efde9f40acc9be3033c517bf391e01eca (diff) | |
| download | jasper-client-45ee6b4e2cd55b901770578e6915312e7792edae.tar.gz jasper-client-45ee6b4e2cd55b901770578e6915312e7792edae.zip | |
Ported boot/boot.sh to python
| -rwxr-xr-x | boot/boot.py | 29 | ||||
| -rwxr-xr-x | boot/boot.sh | 19 |
2 files changed, 29 insertions, 19 deletions
diff --git a/boot/boot.py b/boot/boot.py index e107166..ed191f0 100755 --- a/boot/boot.py +++ b/boot/boot.py @@ -1,9 +1,33 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 import os -import urllib2 import sys +# Set $JASPER_HOME +jasper_home = os.getenv("JASPER_HOME") +if not jasper_home or not os.path.exists(jasper_home): + if os.path.exists("/home/pi"): + jasper_home = "/home/pi" + os.environ["JASPER_HOME"] = jasper_home + else: + print("Error: $JASPER_HOME is not set.") + sys.exit(0) + +# Change CWD to $JASPER_HOME/jasper/boot +os.chdir(os.path.join(os.getenv("JASPER_HOME"), "jasper", "boot")) + +# Set $LD_LIBRARY_PATH +os.environ["LD_LIBRARY_PATH"] = "/usr/local/lib" + +# Set $PATH +path = os.getenv("PATH") +if path: + path = os.pathsep.join([path, "/usr/local/lib/"]) +else: + path = "/usr/local/lib/" +os.environ["PATH"] = path + +import urllib2 import vocabcompiler import traceback @@ -13,7 +37,6 @@ sys.path.append(lib_path) import speaker as speak speaker = speak.newSpeaker() - def testConnection(): try: urllib2.urlopen("http://www.google.com").getcode() diff --git a/boot/boot.sh b/boot/boot.sh index e712c0d..f57da14 100755 --- a/boot/boot.sh +++ b/boot/boot.sh @@ -1,17 +1,4 @@ #!/bin/bash -if [[ -z "$JASPER_HOME" ]]; then - if [[ -d "/home/pi" ]]; then - JASPER_HOME="/home/pi" - export JASPER_HOME; - else - echo "Error: \$JASPER_HOME is not set." - exit 0; - fi -fi - -cd $JASPER_HOME/jasper/boot -LD_LIBRARY_PATH="/usr/local/lib" -export LD_LIBRARY_PATH -PATH=$PATH:/usr/local/lib/ -export PATH -python boot.py & +# This file exists for backwards compatibility with older versions of jasper. +# It might be removed in future versions. +"${0%/*}/boot.py" |
