Fixed verbose == 0 to no longer produce output or attempt to reset the
terminal. Bug pointed out by Gary Lawrence Murphy.
Fixed bug with -m option.
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+mp3togo (0.5.10) unstable; urgency=low
+
+ * Made quiet mode really quiet. Fixed -m option.
+
+ -- Simeon Veldstra <reallifesim@gmail.com> Mon, 12 Feb 2007 19:25:48 -0800
+
mp3togo (0.5.9) unstable; urgency=low
* Added -u update switch for conditional --force. Thanks Mark J. Hewitt.
--- a/debian/mp3togo.1
+++ b/debian/mp3togo.1
@@ -134,4 +134,4 @@ License can be found in /usr/share/commo
.PP
mp3togo can be found online at http://puddle.ca/mp3togo
-.\" created by instant / docbook-to-man, Sun 04 Feb 2007, 16:42
+.\" created by instant / docbook-to-man, Mon 12 Feb 2007, 19:29
--- a/mp3togo/__init__.py
+++ b/mp3togo/__init__.py
@@ -21,5 +21,5 @@
# __all__ = ('converter', 'main', 'options', 'setup')
-version = '0.5.9'
+version = '0.5.10'
--- a/mp3togo/conf.py
+++ b/mp3togo/conf.py
@@ -104,7 +104,7 @@ class Options(options.Options):
'''The encoder to use to create the output files. Options are wav, lame or oggenc.'''),
('encopts', 'E', 'encoder-options', '', None,
'''Compression options for the encoder.'''),
- ('compfactor', 'z', 'compression-factor', 16.0, None,
+ ('compfactor', 'z', 'compression-factor', 18.0, None,
'''If you change the lame options, you must change this factor to match the compression rate of the new options. This is used to estimate completed file size.'''),
('makecache', '', 'make-cache', '', self._absfile, '''Make an output file cache at the given path.'''),
('cachesize', '', '', 0L, None, ''),
--- a/mp3togo/main.py
+++ b/mp3togo/main.py
@@ -140,8 +140,14 @@ def main(argv):
def execute_sequential(playlist, opts, cooked=None):
"""Run the conversions one at a time"""
- print "mp3togo %s\n" % mp3togo.version
- print "<space> or 'p' to pause, <esc> or 'q' to quit\n"
+ # shouldn't print if verbose is 0:
+ if opts['verbosity']:
+ tryp = conf.try_print
+ else:
+ tryp = lambda x: None
+
+ tryp("mp3togo %s\n\n" % mp3togo.version)
+ tryp("<space> or 'p' to pause, <esc> or 'q' to quit\n\n")
c = ''
start_time = time.time()
good_ones = 0
@@ -150,25 +156,27 @@ def execute_sequential(playlist, opts, c
try:
# Terminal sushi
- fd = sys.stdin.fileno()
- oldterm = termios.tcgetattr(fd)
- newattr = termios.tcgetattr(fd)
- newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
- termios.tcsetattr(fd, termios.TCSANOW, newattr)
-
- oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
- fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
-
+ raw = False
if opts['verbosity']:
- tryp = conf.try_print
- else:
- tryp = lambda x: None
+ try:
+ fd = sys.stdin.fileno()
+ oldterm = termios.tcgetattr(fd)
+ newattr = termios.tcgetattr(fd)
+ newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
+ termios.tcsetattr(fd, termios.TCSANOW, newattr)
+ oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
+ fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
+ raw = True
+ except:
+ fail('Error setting the terminal to raw mode.\nIs this a tty?')
+
+ pl = pool.Pool(opts) # make a new one for every track? Huh?
for name in playlist:
track_start = time.time()
tryp("(%d/%d) %s: \n" % (playlist.cur_file() + 1, len(playlist), name))
trk = track.Track(name, opts, cooked)
- pl = pool.Pool(opts) # make a new one for every track? Huh?
+ #pl = pool.Pool(opts) # make a new one for every track? Huh?
if pl.add_track(trk):
tsk = trk.getfirst()
try:
@@ -229,8 +237,7 @@ def execute_sequential(playlist, opts, c
tryp("Undo: %s\n" % tsk.name)
tsk.undo()
tsk = tsk.prev()
- sys.exit(1)
- pass
+ break
else:
opts.log(1, "Out of space. Exiting.")
break
@@ -259,14 +266,15 @@ def execute_sequential(playlist, opts, c
bad_str = ", %d tracks failed." % bad_ones
else:
bad_str = "."
- #bytes = format_bytes(pl.produced_bytes) # you are using a new pool each time!
- tryp("\n%d tracks done%s %s total time elapsed.\n" %
- (good_ones, bad_str, ts))
+ bytes = format_bytes(pl.produced_bytes)
+ tryp("\n%s written for %d tracks%s %s total time elapsed.\n" %
+ (bytes, good_ones, bad_str, ts))
finally:
# Fry some fish:
- termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
- fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
+ if raw:
+ termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
+ fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
def format_time(tm):
@@ -286,14 +294,12 @@ def format_bytes(bytes):
k = 1024.0
m = 1024 * k
g = 1024 * m
- if 0 < bytes < k:
- ret = str(int(bytes/k)) + " KB"
- elif k <= bytes < m:
- ret = str(int(bytes/k)) + " KB"
- elif m <= bytes < g:
- ret = str(int(bytes/m)) + " MB"
+ if k <= bytes < m:
+ return "%.2f KB" % (bytes/k)
+ elif m <= bytes: # < g:
+ return "%.2f MB" % (bytes/m)
else:
- ret = str(bytes) + " Bytes"
+ return str(bytes) + " Bytes"
if __name__ == "__main__": main(sys.argv)
--- a/mp3togo/track.py
+++ b/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."""
@@ -252,16 +245,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
@@ -275,6 +258,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:
@@ -286,6 +270,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