From 101e0c038ce321dd5524cfe9e35f9cb1ff35e775 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Thu, 18 Dec 2008 19:01:44 -0600 Subject: [PATCH] sugar-run-from-journal: use common code to generate files from journal objects --- bin/sugar-run-from-journal | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/bin/sugar-run-from-journal b/bin/sugar-run-from-journal index 415a784..e278e16 100755 --- a/bin/sugar-run-from-journal +++ b/bin/sugar-run-from-journal @@ -119,27 +119,19 @@ class ObjectChooser(object): self._response_code = RESPONSE_CANCEL self._cleanup() -# FIXME: This is duplicated from wineactivity.py; we should move it to some -# common area. -def mime_to_extension(mimetype): - if mimetype == 'application/x-msi': - return '.msi' - else: - return '.exe' - def start_wine(*args): gobject.spawn_async( ['wine', 'explorer', '/desktop=%s' % os.environ['WINE_DESKTOP_NAME']] + [str(x) for x in args], flags=gobject.SPAWN_SEARCH_PATH) def start_object(dsobject): - import tempfile, atexit, shutil + import shutil + import sys + from sugar.activity import activity + sys.path.insert(0, activity.get_bundle_path()) + import filenames file_path = dsobject.get_file_path() - try: - fd, filename = tempfile.mkstemp(suffix=mime_to_extension(dsobject.metadata['mime_type'])) - except (AttributeError, KeyError): - print("can't start file without a mime type") - return + fd, filename = filenames.create_dsobject_file(dsobject.metadata) os.chmod(filename, int('0770', 8)) shutil.copyfile(file_path, filename) os.close(fd) -- 2.11.4.GIT