Mercurial > ~darius > hgwebdir.cgi > amakode
changeset 3:de86a9e19151
Misc bug fixes, whitespace changes.
- Make it easier to schedule multiple jobs (which is useless until amarok
issues them..)
- Remove superfluous initialisation and closing of descriptors.
author | darius@inchoate.localdomain |
---|---|
date | Mon, 12 Nov 2007 14:52:41 +1030 |
parents | de1f6ba76d6d |
children | 65a9f99302cd |
files | amakode.py |
diffstat | 1 files changed, 7 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/amakode.py Tue Oct 23 10:07:23 2007 +0930 +++ b/amakode.py Mon Nov 12 14:52:41 2007 +1030 @@ -50,10 +50,10 @@ class QueueMgr: queuedjobs = [] activejobs = [] - maxjobs = 1 - def __init__(self, _callback): - self.callback = _callback + def __init__(self, callback = None, maxjobs = 2): + self.callback = callback + self.maxjobs = maxjobs pass def add(self, job): @@ -105,8 +105,6 @@ encode["flac"] = ["flac", "-c", "-"] def __init__(self, _inurl, _tofmt): - self.outfname = None - self.errfname = None self.errormsg = None log.debug("Creating job") self.inurl = _inurl @@ -117,7 +115,7 @@ else: log.debug("unable to decode " + self.inext) raise KeyError("no available decoder") - + if (self.tofmt in self.encode): log.debug("can encode with " + str(self.encode[self.tofmt])) else: @@ -131,7 +129,7 @@ self.outfd, self.outfname = tempfile.mkstemp(prefix="transcode-", suffix="." + self.tofmt) #self.outfname = string.join(string.rsplit(self.inurl, ".")[:-1] + [self.tofmt], ".") - self.errfd, self.errfname = tempfile.mkstemp(prefix="transcode-", suffix=".log") + self.errfh, self.errfname = tempfile.mkstemp(prefix="transcode-", suffix=".log") self.outurl = urlparse.urlunsplit(["file", None, self.outfname, None, None]) log.debug("Outputting to " + self.outfname + " " + self.outurl + ")") log.debug("Errors to " + self.errfname) @@ -153,9 +151,6 @@ if (rtn == None): return(False) - os.close(self.errfd) - os.close(self.outfd) - if (rtn == 0): os.unlink(self.errfname) self.errormsg = None @@ -181,7 +176,7 @@ self.readSettings() - self.queue = QueueMgr(self.notify) + self.queue = QueueMgr(callback = self.notify, maxjobs = 1) while True: # Check for finished jobs, etc @@ -297,6 +292,7 @@ if 1: app = amaKode(sys.argv) else: + # Quick test case q = QueueMgr(reportJob) j = TranscodeJob("file:///tmp/test.mp3", "ogg") q.add(j)