Julien Valroff wrote:
> Le lundi 02 janvier 2006 à 18:19 +0000, Ben Hutchings a écrit :
> > 
> > I've actually succeeded in making it build and run in sarge with some
> > quite small changes, so it might be worth leaving the dependencies as
> > they are.  I'm attaching a patch that addresses all the issues I
> > originally mentioned.  This also puts the changes you made to
> > configure
> > (in patch 01_disable_modules_check.dpatch) into configure.ac along
> > with
> > the change needed to accept gnome.vfs in place of gnomevfs, as I
> > believe
> > it is considered bad practice to patch generated files such as
> > configure
> > scripts.
> 
> May you please add the attachment?

That would be a good idea!

Ben.

-- 
Ben Hutchings
Any sufficiently advanced bug is indistinguishable from a feature.
diff -urN freeloader-0.3/configure.ac freeloader-0.3-mine/configure.ac
--- freeloader-0.3/configure.ac
+++ freeloader-0.3-mine/configure.ac
@@ -9,9 +9,15 @@
 
 AX_PYTHON
 AC_PYTHON_MODULE(pygtk, 1)
-AC_PYTHON_MODULE(gtk, 1)
-AC_PYTHON_MODULE(gtk.glade, 1)
-AC_PYTHON_MODULE(gtk.gdk, 1)
+# HACK
+# importing these module fails if no DISPLAY is set
+# which means it fails with pbuilder build and since we do have
+# this module present (due to dependencies) I am going to ignore this
+# error, see: http://oss.codepoet.no/bugzilla/show_bug.cgi?id=155
+#AC_PYTHON_MODULE(gtk, 1)
+#AC_PYTHON_MODULE(gtk.glade, 1)
+#AC_PYTHON_MODULE(gtk.gdk, 1)
+# HACK
 AC_PYTHON_MODULE(gnome, 1)
 AC_PYTHON_MODULE(gnome.ui, 1)
 AC_PYTHON_MODULE(gobject, 1)
@@ -22,7 +28,10 @@
 AC_PYTHON_MODULE(BitTorrent, 1)
 AC_PYTHON_MODULE(BitTorrent.bencode, 1)
 AC_PYTHON_MODULE(BitTorrent.download, 1)
-AC_PYTHON_MODULE(gnomevfs, 1)
+AC_PYTHON_MODULE(gnomevfs)
+if test $HAVE_PYMOD_GNOMEVFS = no; then
+    AC_PYTHON_MODULE(gnome.vfs, 1)
+fi
 AC_PYTHON_MODULE(gconf, 1)
 AC_PYTHON_MODULE(tempfile, 1)
 AC_PYTHON_MODULE(urllib, 1)
diff -urN freeloader-0.3/src/Makefile.am freeloader-0.3-mine/src/Makefile.am
--- freeloader-0.3/src/Makefile.am
+++ freeloader-0.3-mine/src/Makefile.am
@@ -3,7 +3,7 @@
 bin_SCRIPTS = freeloader
 
 localdistdir = $(datadir)/@PACKAGE_NAME@
-localdist_SCRIPTS = genericdl.py webdl.py btdl.py sockdae.py
+localdist_SCRIPTS = genericdl.py webdl.py btdl.py sockdae.py gdklock.py
 
 EXTRA_DIST = $(bin_SCRIPTS) $(localdist_SCRIPTS)
 
diff -urN freeloader-0.3/src/btdl.py freeloader-0.3-mine/src/btdl.py
--- freeloader-0.3/src/btdl.py	2005-04-07 03:28:06.000000000 +0100
+++ freeloader-0.3-mine/src/btdl.py	2006-01-02 04:13:36.000000000 +0000
@@ -22,6 +22,7 @@
 import BitTorrent
 import BitTorrent.download
 import genericdl
+from gdklock import GdkLock
 import urllib
 import threading
 import os
@@ -96,17 +97,15 @@
 		self.update_fields()
 
 	def error(self, errormsg):
-		gtk.gdk.threads_enter()
+		gdk_lock = GdkLock()
 		self.print_log(errormsg, gtk.STOCK_DIALOG_ERROR)
-		gtk.gdk.threads_leave()
 
 	def finished(self):
 		self.downRate = 0
 		self.completed()
-		gtk.gdk.threads_enter()
+		gdk_lock = GdkLock()
 		self.print_log("Completed Torrent: " + self.get_tail(),
 				"arrows-up")
-		gtk.gdk.threads_leave()
 
 	def run(self):
 		args = ()
@@ -125,10 +124,10 @@
 
 		args += ("--saveas", self.des_file, self.src_file)
 
-		gtk.gdk.threads_enter()
+		gdk_lock = GdkLock()
 		self.print_log("Starting Torrent: " + self.get_tail(),
 				"arrows-down-up")
-		gtk.gdk.threads_leave()
+		del gdk_lock
 
 		try:
 			BitTorrent.download.download(	args,
@@ -140,16 +139,16 @@
 							20)
 		except:
 			#there are non fatal exceptions?
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			self.print_log("Error in Torrent thread",
 					gtk.STOCK_DIALOG_ERROR)
-			gtk.gdk.threads_leave()
+			del gdk_lock
 
 		if self.killflag.isSet():
 			self.downRate = 0
 			self.completed()
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			self.print_log("Stopped Torrent: " + self.get_tail(),
 					gtk.STOCK_DIALOG_INFO)
-			gtk.gdk.threads_leave()
+			del gdk_lock
 
diff -urN freeloader-0.3/src/freeloader.in freeloader-0.3-mine/src/freeloader.in
--- freeloader-0.3/src/freeloader.in	2005-04-07 03:31:52.000000000 +0100
+++ freeloader-0.3-mine/src/freeloader.in	2006-01-02 04:33:22.000000000 +0000
@@ -39,7 +39,10 @@
 import gconf
 import socket
 import random
-import gnomevfs
+try:
+	import gnomevfs
+except ImportError:
+	import gnome.vfs as gnomevfs
 import BitTorrent.bencode
 import string
 try:
@@ -78,6 +81,7 @@
 import btdl
 import genericdl
 import sockdae
+from gdklock import GdkLock
 #import webbtdl
 #import fldservice
 
@@ -673,16 +681,14 @@
 	def sync_ui_timer(self):
 		if self.killflag.isSet():
 			return False
-		gtk.gdk.threads_enter()
+		gdk_lock = GdkLock()
 		if gtk.main_level() == 0:
-			gtk.gdk.threads_leave()
 			return False
 		try:
 			self.sync_ui()
 		except:
-			gtk.gdk.threads_leave()
 			return False
-		gtk.gdk.threads_leave()
+		del gdk_lock
 		if self.use_gamin == 1:
 			if self.gam.event_pending() > 0:
 				self.gam.handle_events()
@@ -717,7 +720,8 @@
 			if gtk.main_level() == 0:
 				gtk.gdk.threads_leave()
 				return False
-			self.tooltips.set_tip(self.applet_window, res)
+			if use_tray:
+				self.tooltips.set_tip(self.applet_window, res)
 			gtk.gdk.threads_leave()
 			return True
 		except:
@@ -1140,7 +1144,8 @@
 	def on_quit(self, obj, ev=None):
 		gobject.timeout_add(QUIT_TIMEOUT, self.quit_update)
 		self.lstore.foreach(self.kill_thread, None)
-		self.applet_window.hide()
+		if use_tray:
+			self.applet_window.hide()
 		self.main_window.hide()
 		self.log_window.hide()
 		if not self.killflag.isSet():
diff -urN freeloader-0.3/src/gdklock.py freeloader-0.3-mine/src/gdklock.py
--- freeloader-0.3/src/gdklock.py	1970-01-01 01:00:00.000000000 +0100
+++ freeloader-0.3-mine/src/gdklock.py	2006-01-02 04:13:36.000000000 +0000
@@ -0,0 +1,7 @@
+import gtk.gdk
+
+class GdkLock:
+    def __init__(self):
+        gtk.gdk.threads_enter()
+    def __del__(self):
+        gtk.gdk.threads_leave()
diff -urN freeloader-0.3/src/genericdl.py freeloader-0.3-mine/src/genericdl.py
--- freeloader-0.3/src/genericdl.py	2005-04-07 03:28:06.000000000 +0100
+++ freeloader-0.3-mine/src/genericdl.py	2006-01-02 04:52:15.000000000 +0000
@@ -26,7 +26,8 @@
 import gnome.ui
 import os
 import os.path
-import commands
+import shutil
+from gdklock import GdkLock
 
 def format(num):
 	num = float(num)
@@ -118,18 +119,15 @@
 		return '%.1f %s' % (num, tail)
 
 	def update_fields(self):
+		gdk_lock = GdkLock()
 		try:
-			gtk.gdk.threads_enter()
 			if gtk.main_level() == 0:
-				gtk.gdk.threads_leave()
 				return
 			self.store.set(self.iter, 1, self.build_markup())
 			self.store.set(self.iter, 2, max(0, self.progress))
 			self.store.set(self.iter, 4, self.format_time())
-			gtk.gdk.threads_leave()
 		except:
 			self.print_log("Problem updating fields! in thread: " + str(self))
-			gtk.gdk.threads_leave()
 
 	def completed(self):
 		if self.completed_ev.isSet():
@@ -138,9 +136,9 @@
 
 		self.completed_ev.set()
 
-		gtk.gdk.threads_enter()
+		gdk_lock = GdkLock()
 		(width,height) = gtk.icon_size_lookup(gtk.ICON_SIZE_DND)
-		gtk.gdk.threads_leave()
+		del gdk_lock
 		self.done = 1
 
 		if self.killflag.isSet() and self.progress < 100:
@@ -155,45 +153,40 @@
 			self.progress = 100
 			self.time_est = 0
 
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			theme = gtk.icon_theme_get_default()
 			fact = gnome.ui.ThumbnailFactory(
 					gnome.ui.THUMBNAIL_SIZE_NORMAL)
-			iname = gnome.ui.icon_lookup(theme,	fact,
-								self.des_file,
-								"")
-			#pb = theme.load_icon(iname[0], height, 0)
-			gtk.gdk.threads_leave()
-			self.mime_pb = iname[0]
+			try:
+				iname = gnome.ui.icon_lookup(theme,	fact,
+							     self.des_file,
+							     "")
+			except AttributeError:
+				iname = None
+			del gdk_lock
+			if iname:
+				self.mime_pb = iname[0]
+			else:
+				self.mime_pb = "gnome-fs-regular"
 				
 			if self.final_file:
 				try:
-				
-					# fixme: possible bug with specially
-					# formed urls
-					cmd = "mv \'" + self.des_file + \
-						"\' \'" + self.final_file + \
-						"\'"
-					res = commands.getstatusoutput(cmd)
-				#	os.renames(self.des_file,
-				#			self.final_file)
-					if res[0] != 0:
-						raise
+					shutil.move(self.des_file,
+						    self.final_file)
 					self.des_file = self.final_file
 				except:
-					#sec reasons, no move across vols
-					gtk.gdk.threads_enter()
+					gdk_lock = GdkLock()
 					self.print_log('Error moving %s to final %s.' % (self.des_file, self.final_file), gtk.STOCK_DIALOG_ERROR)
 					self.print_log(cmd[1])
-					gtk.gdk.threads_leave()
+					del gdk_lock
 
 		try:
 			self.watch_func(self.des_file, self.iter)
 		except:
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			self.print_log("Error Watching " + self.des_file,
 					gtk.STOCK_DIALOG_ERROR)
-			gtk.gdk.threads_leave()
+			del gdk_lock
 		# disable buttons against self when kill pushed
 		# this means one download was highlighted at least
 		self.update_fields()
diff -urN freeloader-0.3/src/sockdae.py freeloader-0.3-mine/src/sockdae.py
--- freeloader-0.3/src/sockdae.py	2005-04-07 03:28:06.000000000 +0100
+++ freeloader-0.3-mine/src/sockdae.py	2006-01-02 04:13:36.000000000 +0000
@@ -24,6 +24,7 @@
 import os.path
 import gtk
 import gtk.gdk
+from gdklock import GdkLock
 
 class Sockdae(threading.Thread):
 	def __init__(self, sock, key, loader):
@@ -55,24 +56,20 @@
 		count = 0
 		if s.find('s') >= 0:
 			count += 1
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			self.loader.setwindowvis(gtk.TRUE)
-			gtk.gdk.threads_leave()
 		elif s.find('h') >= 0:
 			count += 1
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			self.loader.setwindowvis(gtk.FALSE)
-			gtk.gdk.threads_leave()
 		if s.find('x') >= 0:
 			count += 1
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			self.loader.on_stop_all_transfers(None)
-			gtk.gdk.threads_leave()
 		if s.find('q') >= 0:
 			count += 1
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			self.loader.on_quit(None)
-			gtk.gdk.threads_leave()
 		return count
 			
 	def run(self):
@@ -118,10 +115,8 @@
 
 	def handle_file(self, uri):
 		if os.path.isfile(uri):
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			self.loader.start_torrent(None, uri)
-			gtk.gdk.threads_leave()
 		else:
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			self.loader.start_url(None, uri)
-			gtk.gdk.threads_leave()
diff -urN freeloader-0.3/src/webdl.py freeloader-0.3-mine/src/webdl.py
--- freeloader-0.3/src/webdl.py	2005-04-07 03:28:06.000000000 +0100
+++ freeloader-0.3-mine/src/webdl.py	2006-01-02 04:13:36.000000000 +0000
@@ -4,6 +4,7 @@
 import pygtk
 import gtk
 import genericdl
+from gdklock import GdkLock
 import urllib
 import os
 import os.path
@@ -39,17 +40,17 @@
 	def run(self):
 		self.time_est = -1
 
-		gtk.gdk.threads_enter()
+		gdk_lock = GdkLock()
 		self.print_log("Starting Download: " + self.get_tail(),
 				"arrows-down")
-		gtk.gdk.threads_leave()
+		del gdk_lock
 
 		try:
 			desfp = file(self.des_file, "wb")
 		except:
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			self.print_log("Error opening local file: " + self.des_file, gtk.STOCK_DIALOG_ERROR)
-			gtk.gdk.threads_leave()
+			del gdk_lock
 			self.please_exit()
 			self.completed()
 			return
@@ -62,9 +63,9 @@
 
 			self.size_total = int(addin.info()['Content-Length'])
 		except:
-			gtk.gdk.threads_enter()
+			gdk_lock = GdkLock()
 			self.print_log("Error opening remote file: " + self.src_file, gtk.STOCK_DIALOG_ERROR)
-			gtk.gdk.threads_leave()
+			del gdk_lock
 			self.please_exit()
 
 		lastd = self.sofar = 0
@@ -109,12 +110,11 @@
 
 		urllib.urlcleanup()
 		self.completed()
-		gtk.gdk.threads_enter()
+		gdk_lock = GdkLock()
 		if self.sofar != self.size_total and self.size_total > 0:
 			self.print_log("Unfinished Download: " +self.get_tail(),
 					gtk.STOCK_DIALOG_ERROR)
 		else:
 			self.print_log("Completed Download: " + self.get_tail(),
 					gtk.STOCK_DIALOG_INFO)
-		gtk.gdk.threads_leave()
 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to