Merge with bugfix-0.5
/mp3togo/track.py
blob:1598d6776c0c5dba75274c891e8cb6138cd7e6da -> blob:2fd35d38de998f19d34802bde260b839f975312c
--- mp3togo/track.py
+++ mp3togo/track.py
@@ -28,18 +28,11 @@ import mp3togo.task as task
import mp3togo.cache as cache
from mp3togo.helpers import helpers
-#helpers = mp3togo.helpers.helpers
-
-
READY = "ready"
RUNNING = "running"
DONE = 0
FAILED = None
-DOGGFACTOR = 10
-DMP3FACTOR = 10
-DFLACFACTOR = 3
-
class Track:
"""Encapsulate the transformation of a file."""
@@ -233,7 +226,13 @@ class Track:
# tag files from the cache as well, brwarning may have changed
if not opts['notags']:
def tag_output():
- self.tags.write(self._outname)
+ try:
+ self.tags.write(self._outname)
+ except:
+ if opts['verbosity'] > 3:
+ import sys, traceback
+ traceback.print_exc(file=sys.stdout)
+ raise
return True
job = task.SimpleTask(self, tag_output, None,
lambda: True, name="Tagging")
@@ -255,16 +254,6 @@ class Track:
tasks.append(job)
del job
- ## Consider the track done if the output file exists:
- #if os.path.exists(self._outname) and not opts['force']:
- # opts.log(1, "Skipping existing file: %s\n" % self._outname)
- # self._queue = tuple(tasks)
- # if self._hash and self._cache:
- # self._cache.release(self._hash)
- # for tsk in self._queue:
- # tsk._status = task.DONE
- # self._state = DONE
- # return
if not opts['force']:
if os.path.exists(self._outname):
# In update mode, consider the track done if an existing file is older than the source
@@ -278,6 +267,7 @@ class Track:
self._cache.release(self._hash)
for tsk in self._queue:
tsk._status = task.DONE
+ self.bytes = os.stat(self._outname).st_size
self._state = DONE
return
else:
@@ -289,6 +279,7 @@ class Track:
self._cache.release(self._hash)
for tsk in self._queue:
tsk._status = task.DONE
+ self.bytes = os.stat(self._outname).st_size
self._state = DONE
return