[soundconverter] - Fix command-line batch mode (#656526). Also skip conversion if input file name is same as output

Michael Schwendt mschwendt at fedoraproject.org
Wed Nov 24 16:45:08 UTC 2010


commit 5885fb680bca4ddaee369071888a96bf59d7ef9f
Author: Michael Schwendt <mschwendt at fedoraproject.org>
Date:   Wed Nov 24 17:45:11 2010 +0100

    - Fix command-line batch mode (#656526). Also skip conversion if input
      file name is same as output file name (as that would not have worked
      so far and would have emptied/delete the input files instead).

 soundconverter-1.5.3-cli-batch.patch |   55 ++++++++++++++++++++++++++++++++++
 soundconverter.spec                  |   10 +++++-
 2 files changed, 64 insertions(+), 1 deletions(-)
---
diff --git a/soundconverter-1.5.3-cli-batch.patch b/soundconverter-1.5.3-cli-batch.patch
new file mode 100644
index 0000000..4afdb3f
--- /dev/null
+++ b/soundconverter-1.5.3-cli-batch.patch
@@ -0,0 +1,55 @@
+diff -Nur soundconverter-1.5.3-orig/src/soundconverter.py soundconverter-1.5.3/src/soundconverter.py
+--- soundconverter-1.5.3-orig/src/soundconverter.py	2010-06-16 22:49:49.000000000 +0200
++++ soundconverter-1.5.3/src/soundconverter.py	2010-11-24 17:42:18.644171229 +0100
+@@ -769,6 +769,12 @@
+ 			# add a task to a stalled taskqueue, shake it!
+ 			self.start_next_task()
+ 
++	def get_current_task(self):
++		if self.running and self.running_tasks:
++			return self.running_tasks[0]
++		else:
++			return None
++
+ 	def start_next_task(self):
+ 		to_start = get_option('jobs') - len(self.running_tasks)
+ 		for i in range(to_start):
+@@ -794,7 +800,7 @@
+ 
+ 	def finished(self):
+ 		""" BackgroundTask finish callback """
+-		log('Queue done in %.3fs (%s tasks)' % (time.time() - self.start_time, self.count))
++		log('\nQueue done in %.3fs (%s tasks)' % (time.time() - self.start_time, self.count))
+ 		self.queue_ended()
+ 		self.running = False
+ 
+@@ -2845,21 +2851,25 @@
+ 	progress = CliProgress()
+ 
+ 	queue = TaskQueue()
+-	for input_file in input_files:
+-		input_file = SoundFile(input_file)
++	for input_name in input_files:
++		input_file = SoundFile(input_name)
+ 		output_name = generator.get_target_name(input_file)
++		if input_name == output_name:
++			print 'WARNING: Not reconverting', input_name
++			continue
+ 		c = Converter(input_file, output_name, output_type)
+ 		c.overwrite = True
+ 		c.init()
+-		queue.add(c)
++		queue.add_task(c)
+ 
+ 	previous_filename = None
+-	queue.run()
++	queue.start()
+ 	while queue.running:
+ 		t = queue.get_current_task()
+ 		if t and not get_option('quiet'):
+ 			if previous_filename != t.sound_file.get_filename_for_display():
+ 				if previous_filename:
++					print
+ 					print _('%s: OK') % previous_filename
+ 				previous_filename = t.sound_file.get_filename_for_display()
+ 
diff --git a/soundconverter.spec b/soundconverter.spec
index e8ed615..7bcd381 100644
--- a/soundconverter.spec
+++ b/soundconverter.spec
@@ -1,6 +1,6 @@
 Name:           soundconverter
 Version:        1.5.3
-Release:        4%{?dist}
+Release:        5%{?dist}
 Summary:        Simple sound converter application for GNOME
 
 Group:          Applications/Multimedia
@@ -21,6 +21,8 @@ Patch0: soundconverter-1.5.3-bz647336.patch
 Patch1: soundconverter-1.5.3-target-folder-is-uri.patch
 # bz #654045
 Patch2: soundconverter-1.5.3-artist-albums.patch
+# bz #656526
+Patch3: soundconverter-1.5.3-cli-batch.patch
 
 # version 2.10 is old enough not to need an explicit version here
 Requires:       pygtk2
@@ -42,6 +44,7 @@ writes anything the GStreamer library can.
 %patch0 -p1 -b .bz647336
 %patch1 -p1 -b .target-folder-is-uri
 %patch2 -p1 -b .artist-albums
+%patch3 -p1 -b .cli-batch
 
 
 %build
@@ -95,6 +98,11 @@ update-desktop-database &> /dev/null ||:
 
 
 %changelog
+* Wed Nov 24 2010 Michael Schwendt <mschwendt at fedoraproject.org> - 1.5.3-5
+- Fix command-line batch mode (#656526). Also skip conversion if input
+  file name is same as output file name (as that would not have worked
+  so far and would have emptied/delete the input files instead).
+
 * Wed Nov 17 2010 Michael Schwendt <mschwendt at fedoraproject.org> - 1.5.3-4
 - Fix target folder for artist/album creation when the source files are
   stored in subdirectories (#654045).


More information about the scm-commits mailing list