summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-09-10 18:04:23 -0400
committerschneefux <schneefux+commit@schneefux.xyz>2014-09-10 18:04:23 -0400
commit757bfb7a62105eebe37aa846f9fd0cbea4a4187c (patch)
treee41c33094c8ea0661e89872fef25908a0b095347
parent8233bd3e1ded9edf607df142c9b13f302f957def (diff)
parent6357df0b1f0e3fd51162a040e69636fb7567f039 (diff)
downloadjasper-client-757bfb7a62105eebe37aa846f9fd0cbea4a4187c.tar.gz
jasper-client-757bfb7a62105eebe37aa846f9fd0cbea4a4187c.zip
Merge branch 'Holzhaus-pure-python'
Conflicts: boot/boot.py boot/boot.sh client/main.py client/start.sh
-rwxr-xr-xboot/boot.py27
-rwxr-xr-xboot/boot.sh19
-rwxr-xr-xclient/main.py11
-rwxr-xr-xclient/start.sh6
4 files changed, 43 insertions, 20 deletions
diff --git a/boot/boot.py b/boot/boot.py
index cb49552..5291ea2 100755
--- a/boot/boot.py
+++ b/boot/boot.py
@@ -1,9 +1,34 @@
#!/usr/bin/env python2
# -*- coding: utf-8-*-
+
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
diff --git a/boot/boot.sh b/boot/boot.sh
index f4e577d..9fc8af8 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
-./boot.py &
+# This file exists for backwards compatibility with older versions of Jasper.
+# It might be removed in future versions.
+"${0%/*}/boot.py"
diff --git a/client/main.py b/client/main.py
index 6683188..d57acd7 100755
--- a/client/main.py
+++ b/client/main.py
@@ -1,5 +1,16 @@
#!/usr/bin/env python2
# -*- coding: utf-8-*-
+
+import os
+import shutil
+
+# Change CWD to $JASPER_HOME/jasper/client
+os.chdir(os.path.join(os.getenv("JASPER_HOME"), "jasper", "client"))
+
+old_client = os.path.abspath(os.path.join(os.pardir, "old_client"))
+if os.path.exists(old_client):
+ shutil.rmtree(old_client)
+
import yaml
import sys
import speaker
diff --git a/client/start.sh b/client/start.sh
index 052db18..cde8d8d 100755
--- a/client/start.sh
+++ b/client/start.sh
@@ -1,4 +1,4 @@
#!/bin/bash
-cd $JASPER_HOME/jasper/client
-rm -rf ../old_client
-./main.py &
+# This file exists for backwards compatibility with older versions of Jasper.
+# It might be removed in future versions.
+"${0%/*}/main.py"