From 5dc7f8f6322ba595849dad9faaccb61c82b3ab2f Mon Sep 17 00:00:00 2001 From: Benjamin Saller Date: Tue, 16 Oct 2007 15:21:22 +0000 Subject: Merge branch 'master' of git+ssh://dev.laptop.org/git/projects/datastore --- diff --git a/NEWS b/NEWS index dc69e96..5f6df2d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +Snapshot 89ae26ced4 + +* Improved mime type handling. (marco) + Snapshot cb0acdf653 * Support for external properties. (bcsaller) diff --git a/bin/datastore-service b/bin/datastore-service index 1a62dfc..140f494 100755 --- a/bin/datastore-service +++ b/bin/datastore-service @@ -1,10 +1,10 @@ #!/usr/bin/env python -import sys, os, signal +import sys, os, signal, logging import gobject import dbus.service import dbus.mainloop.glib -from olpc.datastore import DataStore, backingstore, logger -import logging +from olpc.datastore import DataStore, backingstore +from sugar import logger # Path handling profile = os.environ.get('SUGAR_PROFILE', 'default') diff --git a/src/olpc/datastore/Makefile.am b/src/olpc/datastore/Makefile.am index e32b314..480a5a7 100644 --- a/src/olpc/datastore/Makefile.am +++ b/src/olpc/datastore/Makefile.am @@ -5,7 +5,6 @@ datastore_PYTHON = \ bin_copy.py \ converter.py \ datastore.py \ - logger.py \ model.py \ xapianindex.py \ utils.py \ diff --git a/src/olpc/datastore/logger.py b/src/olpc/datastore/logger.py deleted file mode 100644 index d1c9080..0000000 --- a/src/olpc/datastore/logger.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2007 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -import sys -import os -import logging -import time - -# Let's keep this self contained so that it can be easily -# pasted in external sugar service like the datastore. - -def get_logs_dir(): - profile = os.environ.get('SUGAR_PROFILE', 'default') - logs_dir = os.path.join(os.path.expanduser('~'), - '.sugar', profile, 'logs') - return logs_dir - -def set_level(level): - levels = { 'error' : logging.ERROR, - 'warning' : logging.WARNING, - 'debug' : logging.DEBUG, - 'info' : logging.INFO } - if levels.has_key(level): - logging.getLogger('').setLevel(levels[level]) - -def start(log_filename=None): - logging.basicConfig(level=logging.WARNING, - format="%(created)f %(levelname)s %(message)s") - - if os.environ.has_key('SUGAR_LOGGER_LEVEL'): - set_level(os.environ['SUGAR_LOGGER_LEVEL']) - - if log_filename and not sys.stdin.isatty(): - log_path = os.path.join(get_logs_dir(), log_filename + '.log') - log_file = open(log_path, 'w') - - os.dup2(log_file.fileno(), sys.stdout.fileno()) - os.dup2(log_file.fileno(), sys.stderr.fileno()) diff --git a/src/olpc/datastore/model.py b/src/olpc/datastore/model.py index ecf8777..9b00e2c 100644 --- a/src/olpc/datastore/model.py +++ b/src/olpc/datastore/model.py @@ -11,10 +11,10 @@ __copyright__ = 'Copyright ObjectRealms, LLC, 2007' __license__ = 'The GNU Public License V2+' import datetime -import mimetypes import os import time import warnings +from sugar import mime from olpc.datastore.utils import timeparse @@ -249,7 +249,7 @@ class Content(object): # try to get an extension from the mimetype if available mt = self.get_property('mime_type', None) if mt: - ext = mimetypes.guess_extension(mt) + ext = mime.get_primary_extension(mt) # .ksh is a strange ext for plain text if ext and ext == '.ksh': ext = '.txt' if ext and ext == '.jpe': ext = '.jpg' # fixes #3163 -- cgit v0.9.1