[Sugar-devel] [PATCH sugar 1/2] Env variables for mime and activities defaults

Daniel Narvaez dwnarvaez at gmail.com
Fri Dec 7 09:12:26 EST 2012


From: Daniel Narvaez <dwnarvaez at gmail.com>

These are necessary for unit tests because we cannot assume
they are installed in the system. Also config.py is not
generated inside the jarabe package directory when building
out-of-source, so trying to import it fails

They might be used for customization too.
---
 bin/sugar.in                       |   10 ++++++++++
 src/jarabe/model/bundleregistry.py |    5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/bin/sugar.in b/bin/sugar.in
index 2df0ab8..e7cb068 100644
--- a/bin/sugar.in
+++ b/bin/sugar.in
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+sugardatadir=@prefix@/share/sugar/data
+
 if [ "$(id -u)" -eq 0 -o "$(id -ru)" -eq 0 ] ; then
 	echo Refusing to run as root.
 	exit 3
@@ -45,6 +47,14 @@ if test -z "$SUGAR_SCALING"; then
     export SUGAR_SCALING=72
 fi
 
+if test -z "$SUGAR_MIME_DEFAULTS"; then
+    export SUGAR_MIME_DEFAULTS="$sugardatadir/mime.defaults"
+fi
+
+if test -z "$SUGAR_ACTIVITIES_DEFAULTS"; then
+    export SUGAR_ACTIVITIES_DEFAULTS="$sugardatadir/activities.defaults"
+fi
+
 export GTK2_RC_FILES="@prefix@/share/sugar/data/sugar-$SUGAR_SCALING.gtkrc"
 
 # Needed for executing wpa_passphrase
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index 8a1fa37..0c20b9f 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -32,7 +32,6 @@ from sugar3.bundle.bundle import MalformedBundleException, \
     AlreadyInstalledException, RegistrationException
 from sugar3 import env
 
-from jarabe import config
 from jarabe.model import mimeregistry
 
 
@@ -109,7 +108,7 @@ class BundleRegistry(GObject.GObject):
     def _load_mime_defaults(self):
         defaults = {}
 
-        f = open(os.path.join(config.data_path, 'mime.defaults'), 'r')
+        f = open(os.environ["SUGAR_MIME_DEFAULTS"], 'r')
         for line in f.readlines():
             line = line.strip()
             if line and not line.startswith('#'):
@@ -152,7 +151,7 @@ class BundleRegistry(GObject.GObject):
 
     def _merge_default_favorites(self):
         default_activities = []
-        defaults_path = os.path.join(config.data_path, 'activities.defaults')
+        defaults_path = os.environ["SUGAR_ACTIVITIES_DEFAULTS"]
         if os.path.exists(defaults_path):
             file_mtime = os.stat(defaults_path).st_mtime
             if file_mtime > self._last_defaults_mtime:
-- 
1.7.10.4



More information about the Sugar-devel mailing list