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

Bug#513003: #513003 - progress?



On Tue, May 12, 2009 at 01:02:31AM +0300, Faidon Liambotis wrote [edited]:
> Serafeim, perhaps you could modify it yourself (in coordination with
> upstream, if that's possible)?

I've prepared a new package with the latest upstream and a couple of fixes,
including the tempfile issue.

http://www.cs.man.ac.uk/~zanikols/tmp/debian/pdfshuffler_0.4.1-1.dsc
http://www.cs.man.ac.uk/~zanikols/tmp/debian/pdfshuffler_0.3.1-1.dsc (for ref)

I'm attaching the patches for Konstantinos's convenience (I've contacted him
previously about them).

I'll commit to the python-apps svn once I know that it's been uploaded.

Cheers,
Serafeim
Index: pdfshuffler/pdfshuffler
===================================================================
--- pdfshuffler.orig/pdfshuffler	2009-05-12 17:28:46.000000000 +0200
+++ pdfshuffler/pdfshuffler	2009-05-12 17:28:51.000000000 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """
@@ -35,6 +35,7 @@
 import sys			#needed for proccessing of command line args
 import urllib		#needed to parse filename information passed by DnD
 import threading
+import tempfile
 
 import locale		#for multilanguage support
 import gettext
@@ -93,17 +94,8 @@
 
     def __init__(self):
         # Create the temporary directory
-        # The dir is /tmp/pdfshuffler/<num> where <num> is 1 or higher
-        # depending on the number of pdfshuffler sessions opened.
-        if not os.path.exists('/tmp/pdfshuffler/'):
-            os.makedirs('/tmp/pdfshuffler/')
-            os.chmod('/tmp/pdfshuffler/', 0700)
-        dir_number = 1
-        while os.path.exists('/tmp/pdfshuffler/' + str(dir_number)):
-            dir_number += 1
-        os.mkdir('/tmp/pdfshuffler/' + str(dir_number))
-        os.chmod('/tmp/pdfshuffler/' + str(dir_number), 0700)
-        self.tmp_dir = '/tmp/pdfshuffler/' + str(dir_number) + '/'
+        self.tmp_dir = tempfile.mkdtemp("pdfshuffler")
+        os.chmod(self.tmp_dir, 0700)
 
         pixmap = os.path.join(sys.prefix,'share','pixmaps','pdfshuffler.png')
         try:
@@ -313,7 +305,7 @@
         if self.rendering_thread.paused == True:
              self.rendering_thread.evnt.set()
              self.rendering_thread.evnt.clear()
-        if re.search('^/tmp/',self.tmp_dir):
+        if os.path.isdir(self.tmp_dir):
             shutil.rmtree(self.tmp_dir)
         if gtk.main_level():
             gtk.main_quit()
Index: pdfshuffler/pdfshuffler
===================================================================
--- pdfshuffler.orig/pdfshuffler	2009-05-12 17:54:39.000000000 +0200
+++ pdfshuffler/pdfshuffler	2009-05-12 17:55:20.000000000 +0200
@@ -473,12 +473,14 @@
 
         response = chooser.run()
         if response == gtk.RESPONSE_OK:
-            filenames = chooser.get_filenames()
+            for filename in chooser.get_filenames():
+                if os.path.isfile(filename):
+                    self.add_pdf_pages(filename)
+                else:
+                    print(_('Cannot add "%s", file does not exist"') % filename)
         elif response == gtk.RESPONSE_CANCEL:
             print(_('Closed, no files selected'))
         chooser.destroy()
-        for filename in filenames:
-            self.add_pdf_pages(filename)
 
     # =======================================================
     def clear_selected(self, button=None):

Reply to: