[alacarte] Don't use a hardcoded path in /tmp



commit 8cffcacf24ee96689c60042e48ef919c7575549c
Author: Colin Walters <walters verbum org>
Date:   Wed May 4 13:54:10 2011 -0400

    Don't use a hardcoded path in /tmp

 Alacarte/MainWindow.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/Alacarte/MainWindow.py b/Alacarte/MainWindow.py
index e43ea9a..260efe5 100644
--- a/Alacarte/MainWindow.py
+++ b/Alacarte/MainWindow.py
@@ -545,8 +545,12 @@ class MainWindow:
 			content_type = file_info.get_content_type()
 			if content_type == 'application/x-desktop':
 				input_stream = myfile.read()
-				open('/tmp/alacarte-dnd.desktop', 'w').write(input_stream.read())
-				parser = util.DesktopParser('/tmp/alacarte-dnd.desktop')
+				(fd, tmppath) = tempfile.mkstemp(prefix='alacarte-dnd', suffix='.desktop')
+				os.close(fd)
+				f = os.open(tmppath, 'w')
+				f.write(input_stream.read())
+				f.close()
+				parser = util.DesktopParser(tmppath)
 				self.editor.createItem(parent, parser.get('Icon'), parser.get('Name', self.editor.locale), parser.get('Comment', self.editor.locale), parser.get('Exec'), parser.get('Terminal'), before, after)
 			elif content_type in ('application/x-shellscript', 'application/x-executable'):
 				self.editor.createItem(parent, None, os.path.split(file_path)[1].strip(), None, file_path.replace('file://', '').strip(), False, before, after)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]