From 3b957dd6d75e0bf8f6c2f073d61c03acab2cd1d8 Mon Sep 17 00:00:00 2001 From: Aneesh Dogra Date: Thu, 20 Dec 2012 18:16:25 +0000 Subject: Use tempfile module to generate tempfile instead of hardcoding it. --- diff --git a/SliderPuzzleWidget.py b/SliderPuzzleWidget.py index a88a144..59a8660 100644 --- a/SliderPuzzleWidget.py +++ b/SliderPuzzleWidget.py @@ -21,7 +21,7 @@ from gi.repository import Gtk, GObject, Pango, GdkPixbuf, Gdk import md5 import logging - +import tempfile from mamamedia_modules import utils #from utils import load_image, calculate_matrix, debug, SliderCreator, trace @@ -580,9 +580,11 @@ class SliderPuzzleWidget (Gtk.Table): # and it looks like save_to_callback's data is being truncated on NULL. # Check http://ubuntuforums.org/showthread.php?t=1877793 # XXX: Hack - self.image.savev("tmp.png", "png", [], []) - pb_s = GdkPixbuf.Pixbuf.new_from_file("tmp.png").to_string() - os.remove("tmp.png") + tmp_file = tempfile.NamedTemporaryFile() + tmp_file_name = tmp_file.name + self.image.savev(tmp_file_name, "png", [], []) + pb_s = GdkPixbuf.Pixbuf.new_from_file(tmp_file_name).to_string() + tmp_file.close() return pb_s def _freeze (self, journal=True): -- cgit v0.9.1