From bc60d52846ba11369f73a80a394345b47caea876 Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 12 Sep 2014 17:37:09 +0200 Subject: Added `jasperpath` module --- client/jasperpath.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 client/jasperpath.py (limited to 'client') diff --git a/client/jasperpath.py b/client/jasperpath.py new file mode 100644 index 0000000..b8865cf --- /dev/null +++ b/client/jasperpath.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8-*- +import os + +# Jasper main directory +APP_PATH = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)) + +DATA_PATH = os.path.join(APP_PATH, "static") +LIB_PATH = os.path.join(APP_PATH, "client") +PLUGIN_PATH = os.path.join(LIB_PATH, "modules") + +CONFIG_PATH = os.path.expanduser(os.getenv('JASPER_CONFIG', '~/.jasper')) + +def config(*fname): + return os.path.join(CONFIG_PATH, *fname) + +def data(*fname): + return os.path.join(DATA_PATH, *fname) \ No newline at end of file -- cgit v1.3.1 From 84df4377e0794d657b783a93b5a15ccfcaa375f2 Mon Sep 17 00:00:00 2001 From: schneefux Date: Wed, 17 Sep 2014 14:34:47 +0200 Subject: Use jasperpath in brain.py --- client/brain.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/brain.py b/client/brain.py index 039b1db..a1fdea4 100644 --- a/client/brain.py +++ b/client/brain.py @@ -3,6 +3,7 @@ import logging import os import pkgutil import importlib +import jasperpath def logError(): @@ -41,7 +42,7 @@ class Brain(object): module, a priority of 0 is assumed. """ - module_locations = [os.path.join(os.path.dirname(__file__), 'modules')] + module_locations = [jasperpath.PLUGIN_PATH] module_names = [name for loader, name, ispkg in pkgutil.iter_modules(module_locations)] modules = [] for name in module_names: -- cgit v1.3.1 From a230f623eeeda960e19dadc6fac0e940137a9776 Mon Sep 17 00:00:00 2001 From: schneefux Date: Wed, 17 Sep 2014 14:37:16 +0200 Subject: Use jasperpath in diagnose.py Removed jasper_modules_path() function --- client/diagnose.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'client') diff --git a/client/diagnose.py b/client/diagnose.py index 415eb6e..28cd9c8 100755 --- a/client/diagnose.py +++ b/client/diagnose.py @@ -4,7 +4,7 @@ import re import socket import os from subprocess import check_output, call - +import jasperpath class Diagnostics: @@ -15,9 +15,6 @@ class Diagnostics: To add new checks, add a boolean returning method with a name that starts with `check_` """ - @classmethod - def jasper_modules_path(cls): - return os.path.abspath('../../') @classmethod def check_network_connection(cls): @@ -35,7 +32,7 @@ class Diagnostics: @classmethod def check_phonetisaurus_dictionary_file(cls): - return os.path.isfile(os.path.join(cls.jasper_modules_path(), "phonetisaurus/g014b2b.fst")) + return os.path.isfile(os.path.join(jasperpath.APP_PATH, "..", "phonetisaurus/g014b2b.fst")) @classmethod def check_phonetisaurus_program(cls): -- cgit v1.3.1 From 21cc35e631c87251efecf9b725d6bd313349ad18 Mon Sep 17 00:00:00 2001 From: schneefux Date: Wed, 17 Sep 2014 14:40:28 +0200 Subject: Style fix: Added newline at the EOF --- client/jasperpath.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/jasperpath.py b/client/jasperpath.py index b8865cf..fdc1494 100644 --- a/client/jasperpath.py +++ b/client/jasperpath.py @@ -15,4 +15,4 @@ def config(*fname): return os.path.join(CONFIG_PATH, *fname) def data(*fname): - return os.path.join(DATA_PATH, *fname) \ No newline at end of file + return os.path.join(DATA_PATH, *fname) -- cgit v1.3.1