Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar

This commit is contained in:
Marco Pesenti Gritti 2007-12-14 13:26:48 +01:00
commit f87118c02c
2 changed files with 28 additions and 10 deletions

View File

@ -20,6 +20,7 @@ import logging
import tempfile import tempfile
import os import os
import time import time
import shutil
import gobject import gobject
import gtk import gtk
@ -80,8 +81,16 @@ class Shell(gobject.GObject):
def _start_journal_idle(self): def _start_journal_idle(self):
# Mount the datastore in internal flash # Mount the datastore in internal flash
datastore.mount(env.get_profile_path('datastore'), [], ds_path = env.get_profile_path('datastore')
timeout=120 * DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND) try:
datastore.mount(ds_path, [], timeout=120 * \
DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)
except:
# Don't explode if there's corruption; move the data out of the way
# and attempt to create a store from scratch.
shutil.move(ds_path, os.path.abspath(ds_path) + str(time.time()))
datastore.mount(ds_path, [], timeout=120 * \
DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)
# Checking for the bundle existence will also ensure # Checking for the bundle existence will also ensure
# that the shell service is started up. # that the shell service is started up.

View File

@ -20,28 +20,28 @@
import sys import sys
import unittest import unittest
from sugar import objects from sugar import mime
class TestMime(unittest.TestCase): class TestMime(unittest.TestCase):
def test_from_file_name(self): def test_from_file_name(self):
self.assertEqual(objects.mime.get_from_file_name('test.pdf'), self.assertEqual(mime.get_from_file_name('test.pdf'),
'application/pdf') 'application/pdf')
def test_choose_most_significant(self): def test_choose_most_significant(self):
# Mozilla's text in dnd # Mozilla's text in dnd
mime_type = objects.mime.choose_most_significant( mime_type = mime.choose_most_significant(
['text/plain', 'text/_moz_htmlcontext', 'text/unicode', ['text/plain', 'text/_moz_htmlcontext', 'text/unicode',
'text/html', 'text/_moz_htmlinfo']) 'text/html', 'text/_moz_htmlinfo'])
self.assertEqual(mime_type, 'text/html') self.assertEqual(mime_type, 'text/html')
# Mozilla's text in c&v # Mozilla's text in c&v
mime_type = objects.mime.choose_most_significant( mime_type = mime.choose_most_significant(
['text/_moz_htmlcontext', 'STRING', 'text/html', 'text/_moz_htmlinfo', ['text/_moz_htmlcontext', 'STRING', 'text/html', 'text/_moz_htmlinfo',
'text/x-moz-url-priv', 'UTF8_STRING', 'COMPOUND_TEXT']) 'text/x-moz-url-priv', 'UTF8_STRING', 'COMPOUND_TEXT'])
self.assertEqual(mime_type, 'text/html') self.assertEqual(mime_type, 'text/html')
# Mozilla gif in dnd # Mozilla gif in dnd
mime_type = objects.mime.choose_most_significant( mime_type = mime.choose_most_significant(
['application/x-moz-file-promise-url', ['application/x-moz-file-promise-url',
'application/x-moz-file-promise-dest-filename', 'text/_moz_htmlinfo', 'application/x-moz-file-promise-dest-filename', 'text/_moz_htmlinfo',
'text/x-moz-url-desc', 'text/_moz_htmlcontext', 'text/x-moz-url-data', 'text/x-moz-url-desc', 'text/_moz_htmlcontext', 'text/x-moz-url-data',
@ -49,24 +49,33 @@ class TestMime(unittest.TestCase):
self.assertEqual(mime_type, 'text/uri-list') self.assertEqual(mime_type, 'text/uri-list')
# Mozilla url in dnd # Mozilla url in dnd
mime_type = objects.mime.choose_most_significant( mime_type = mime.choose_most_significant(
['text/_moz_htmlcontext', 'text/html', 'text/_moz_htmlinfo', ['text/_moz_htmlcontext', 'text/html', 'text/_moz_htmlinfo',
'_NETSCAPE_URL', 'text/x-moz-url', 'text/x-moz-url-desc', '_NETSCAPE_URL', 'text/x-moz-url', 'text/x-moz-url-desc',
'text/x-moz-url-data', 'text/plain', 'text/unicode']) 'text/x-moz-url-data', 'text/plain', 'text/unicode'])
self.assertEqual(mime_type, 'text/x-moz-url') self.assertEqual(mime_type, 'text/x-moz-url')
# Abiword text in dnd # Abiword text in dnd
mime_type = objects.mime.choose_most_significant( mime_type = mime.choose_most_significant(
['text/rtf', 'text/uri-list']) ['text/rtf', 'text/uri-list'])
self.assertEqual(mime_type, 'text/uri-list') self.assertEqual(mime_type, 'text/uri-list')
# Abiword text in c&v # Abiword text in c&v
mime_type = objects.mime.choose_most_significant( mime_type = mime.choose_most_significant(
['UTF8_STRING', 'STRING', 'text/html', 'TEXT', 'text/rtf', ['UTF8_STRING', 'STRING', 'text/html', 'TEXT', 'text/rtf',
'COMPOUND_TEXT', 'application/rtf', 'text/plain', 'COMPOUND_TEXT', 'application/rtf', 'text/plain',
'application/xhtml+xml']) 'application/xhtml+xml'])
self.assertEqual(mime_type, 'application/rtf') self.assertEqual(mime_type, 'application/rtf')
# Abiword text in c&v
mime_type = mime.choose_most_significant(
['GTK_TEXT_BUFFER_CONTENTS',
'application/x-gtk-text-buffer-rich-text',
'UTF8_STRING', 'COMPOUND_TEXT', 'TEXT', 'STRING',
'text/plain;charset=utf-8', 'text/plain;charset=UTF-8',
'text/plain'])
self.assertEqual(mime_type, 'text/plain')
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()