Author: duncan
Date: Sat Nov 3 12:19:43 2007
New Revision: 10069
Log:
Added more doc strings and debug messages
Modified:
branches/rel-1-7/freevo/src/helpers/encodingserver.py
branches/rel-1-7/freevo/src/plugins/idlebar/transcode.py
Modified: branches/rel-1-7/freevo/src/helpers/encodingserver.py
==============================================================================
--- branches/rel-1-7/freevo/src/helpers/encodingserver.py (original)
+++ branches/rel-1-7/freevo/src/helpers/encodingserver.py Sat Nov 3
12:19:43 2007
@@ -70,21 +70,26 @@
class EncodingServer(xmlrpc.XMLRPC):
def __init__(self, debug=False):
+ """ Initialise the EncodingServer class """
+ _debug_('__init__(debug=%r)' % (debug), 1)
self.jobs = {}
self.queue = EncodingQueue()
_debug_("EncodingServer started...", DINFO)
def xmlrpc_echotest(self, blah):
- _debug_("xmlrpc_echotest(self, blah)", 3)
+ """ Using Twisted check the connection """
+ _debug_('xmlrpc_echotest(blah=%r)' % (blah), 1)
return (True, 'EncodingServer::echotest: %s' % blah)
def xmlrpc_initEncodeJob(self, source, output, friendlyname="",
chapter=None):
- _debug_("xmlrpc_initEncodeJob(self, %s, %s, %s, %s)" % (source,
output, friendlyname, chapter), 3)
+ """ Using Twisted initialise an encoding job """
+ _debug_('xmlrpc_initEncodeJob(source=%r, output=%r, friendlyname=%r,
chapter=%r)' % \
+ (source, output, friendlyname, chapter), 1)
#safety checks
if not (source or output):
return (False, 'EncodingServer::initEncodeJob: no source or
output given')
#generate a "random" idnr based on the time
- #in p2.3 , int() can return long int's, wich is fine, except it makes
XMLRPC fail somwhere along the way
+ #in p2.3, int() can return long int's, wich is fine, except it makes
XMLRPC fail somwhere along the way
# so we devide or random number by 100 :)
idnr = int((time.time() / random.random()) / 100)
_debug_("idnr=%s" % (idnr), 2)
@@ -94,16 +99,18 @@
while not self.jobs[idnr].finishedanalyze:
time.sleep(0.1)
- _debug_("Initialized job %s (idnr : %s)" % (friendlyname,idnr), DINFO)
+ _debug_("Initialized job %s (idnr : %s)" % (friendlyname, idnr), DINFO)
return (True, idnr)
def xmlrpc_getContainerCAP(self, idnr):
- _debug_("xmlrpc_getContainerCAP(self, idnr)", 3)
+ """ Using Twisted get the container capabilities """
+ _debug_('xmlrpc_getContainerCAP(idnr=%r)' % (idnr), 1)
return (True, jam(self.jobs[idnr].getContainerList()))
def xmlrpc_setContainer(self, idnr, container):
- _debug_("xmlrpc_setContainer(self, idnr, container)", 3)
+ """ Using Twisted set the container """
+ _debug_('xmlrpc_setContainer(idnr=%r, container=%r)' % (idnr,
container), 1)
status = self.jobs[idnr].setContainer(container)
if not status:
@@ -112,12 +119,14 @@
return (False, "EncodingServer::setContainer: %s" % status)
def xmlrpc_getVideoCodecCAP(self, idnr):
- _debug_("xmlrpc_getVideoCodecCAP(self, idnr)", 3)
+ """ Using Twisted get the video capabilities """
+ _debug_('xmlrpc_getVideoCodecCAP(idnr=%r)' % (idnr), 1)
return (True, jam(self.jobs[idnr].getVideoCodecList()))
def xmlrpc_setVideoCodec(self, idnr, vcodec, tgtsize, multipass=False,
vbitrate=0):
- _debug_("xmlrpc_setVideoCodec(self, %s, %s, %s, %s %s)" % \
- (idnr, vcodec, tgtsize, multipass, vbitrate), 3)
+ """ Using Twisted set the video codec """
+ _debug_('xmlrpc_setVideoCodec(idnr=%r, vcodec=%r, tgtsize=%r,
multipass=%r, vbitrate==%r)' % \
+ (idnr, vcodec, tgtsize, multipass, vbitrate), 1)
#safety checks
if not (vcodec or (tgtsize and vbitrate)):
return (False, 'EncodingServer::setVideoCodec: no codec or target
size given')
@@ -130,11 +139,13 @@
return (False, "EncodingServer::setVideoCodec: %s" % status)
def xmlrpc_getAudioCodecCAP(self, idnr):
- _debug_("xmlrpc_getAudioCodecCAP(self, idnr)", 3)
+ """ Using Twisted get the audio capabilities """
+ _debug_('xmlrpc_getAudioCodecCAP(idnr=%r)' % (idnr), 1)
return (True, jam(self.jobs[idnr].getAudioCodecList()))
def xmlrpc_setAudioCodec(self, idnr, acodec, abrate):
- _debug_("xmlrpc_setAudioCodec(self, idnr, acodec, abrate)", 3)
+ """ Using Twisted set the audio codec """
+ _debug_('xmlrpc_setAudioCodec(idnr=%r, acodec=%r, abrate=%r)' % (idnr,
acodec, abrate), 1)
#safety checks
if not (acodec or abrate):
return (False, 'EncodingServer::setAudioCodec: no codec or
bitrate given')
@@ -147,12 +158,14 @@
return (False, "EncodingServer::setAudioCodec: %s" % status)
def xmlrpc_getVideoFiltersCAP(self, idnr):
- _debug_("xmlrpc_getVideoFiltersCAP(self, idnr)", 3)
+ """ Using Twisted get the video filter capabilities """
+ _debug_('xmlrpc_getVideoFiltersCAP(idnr=%r)' % (idnr), 1)
return (True, jam(self.jobs[idnr].getVideoFiltersList()))
def xmlrpc_setVideoFilters(self, idnr, filters):
- _debug_("xmlrpc_setVideoFilters(self, idnr, filters)", 3)
+ """ Using Twisted set the video filter list """
+ _debug_('xmlrpc_setVideoFilters(idnr, filters)', 1)
#safety checks
if not filters:
return (False, 'EncodingServer::setAudioCodec: no codec or
bitrate given')
@@ -165,7 +178,8 @@
return (False, "EncodingServer::setVideoFilters: %s" % status)
def xmlrpc_queueIt(self, idnr, now=False):
- _debug_("xmlrpc_queueIt(self, idnr, now=False)", 3)
+ """ Using Twisted queue a job to run """
+ _debug_('xmlrpc_queueIt(idnr=%r, now=%r)' % (idnr, now), 1)
self.queue.addEncodingJob(self.jobs[idnr])
del self.jobs[idnr]
_debug_("Added job %s to the queue" % idnr, DINFO)
@@ -174,24 +188,29 @@
return (True, "EncodingServer::queueIt: OK")
def xmlrpc_getProgress(self):
- _debug_("xmlrpc_getProgress(self)", 3)
+ """ Using Twisted get the progress status of the current job """
+ _debug_('xmlrpc_getProgress()', 1)
prog = self.queue.getProgress()
if type(prog) is str:
return (False, "EncodingServer::getProgress: %s" % prog)
return (True, jam(prog))
def xmlrpc_startQueue(self):
- _debug_("xmlrpc_startQueue(self)", 3)
+ """ Using Twisted start the job queue """
+ _debug_('xmlrpc_startQueue()', 1)
self.queue.startQueue()
return (True, "EncodingServer::startqueue: OK")
def xmlrpc_listJobs(self):
- _debug_("xmlrpc_listJobs(self)", 3)
+ """ List the current jobs """
+ _debug_('xmlrpc_listJobs()', 1)
jlist = self.queue.listJobs()
return (True, jam(jlist))
def main():
+ """ The main entry point for the server """
+ _debug_('main()', 1)
global DEBUG
tmppath = tempfile.mkdtemp(prefix = 'encodeserver')
os.chdir(tmppath)
Modified: branches/rel-1-7/freevo/src/plugins/idlebar/transcode.py
==============================================================================
--- branches/rel-1-7/freevo/src/plugins/idlebar/transcode.py (original)
+++ branches/rel-1-7/freevo/src/plugins/idlebar/transcode.py Sat Nov 3
12:19:43 2007
@@ -42,8 +42,8 @@
def returnFromJelly(status, response):
- '''Un-serialize EncodingServer responses'''
- _debug_('returnFromJelly(status, response)', 2)
+ """Un-serialize EncodingServer responses"""
+ _debug_('returnFromJelly(status, response)', 1)
if status:
return (status, unjellyFromXML(response))
else:
@@ -59,7 +59,8 @@
"""
def __init__(self):
- _debug_('transcode.PluginInterface.__init__(self)', 2)
+ """ Initialise the transcode idlebar plug-in """
+ _debug_('transcode.PluginInterface.__init__()', 1)
IdleBarPlugin.__init__(self)
self.plugin_name = 'idlebar.transcode'
@@ -86,15 +87,13 @@
self.leftclamp_x = 0
self.rightclamp_x = 0
-
self.poll_interval = 82 # 82*1/120th seconds (~1sec)
self.draw_interval = self.poll_interval
self.last_interval = self.poll_interval
self.lastdraw = 0
self.lastpoll = 0
self.drawtime = 0
- server_string = 'http://%s:%s/' % \
- (config.ENCODINGSERVER_IP, config.ENCODINGSERVER_PORT)
+ server_string = 'http://%s:%s/' % (config.ENCODINGSERVER_IP,
config.ENCODINGSERVER_PORT)
self.server = xmlrpclib.Server(server_string, allow_none=1)
self.skin = skin.get_singleton()
@@ -108,15 +107,20 @@
self.font = self.skin.get_font('small0')
if self.font == skin.get_font('default'):
self.font = skin.get_font('info value')
+ _debug_('transcode.PluginInterface.__init__() done.')
def config(self):
- return [ ('ENCODING_IDLEBAR', True, 'Show on the idlebar, otherwise on
the main screen'), ]
+ _debug_('config()', 1)
+ return [
+ ('ENCODINGSERVER_IP', 'localhost', 'The host name or IP address of
the encoding server'),
+ ('ENCODINGSERVER_PORT', 6666, 'The port of the encoding server'),
+ ]
def getprogress(self):
- _debug_('getprogress(self)', 2)
- '''Get the progress & pass information of the job currently encoding.
+ """
+ Get the progress & pass information of the job currently encoding.
This call returns False if no job is currently encoding (fx the queue
is not active).
When the queue is active, this call returns a tuple of 4 values:
@@ -132,7 +136,8 @@
perc is the percentage completed of the current pass
timerem is the estimated time remaining of the current pass, formatted
as a
human-readable string.
- '''
+ """
+ _debug_('getprogress()', 1)
try:
(status, response) = self.server.getProgress()
@@ -143,27 +148,32 @@
def listjobs(self):
- _debug_('listjobs(self)', 2)
- '''Get a list with all jobs in the encoding queue and their current
state
+ """
+ Get a list with all jobs in the encoding queue and their current state
- Returns a list of tuples containing all the current queued jobs. When
the queue is
- empty, an empty list is returned.
- Each job in the list is a tuple containing 3 values (idnr,
friendlyname, status)
- These values have the same meaning as the corresponding values
returned by the
- getProgress call'''
+ Returns a list of tuples containing all the current queued jobs. When
the queue
+ is empty, an empty list is returned. Each job in the list is a tuple
+ containing 3 values (idnr, friendlyname, status) These values have the
same
+ meaning as the corresponding values returned by the getProgress call
+ """
+ _debug_('listjobs() server=%r' % self.server, 1)
+ result = (FALSE, [])
try:
(status, response) = self.server.listJobs()
except:
return (False, 'EncodingClient: connection error')
-
- return returnFromJelly(status, response)
+ result = returnFromJelly(status, response)
+ _debug_('listjobs() result=%r' % (result, ), 1)
+ return result
def getimage(self, image, osd, cache=False):
- '''load the image from the cache when available otherwise load the
image
- and save in the cache'''
- _debug_('getimage(image=%r, osd=%r, cache=%s)' % (image, osd, cache),
2)
+ """
+ Load the image from the cache when available otherwise load the image
and save
+ in the cache.
+ """
+ _debug_('getimage(image=%r, osd=%r, cache=%s)' % (image, osd, cache),
1)
if image.find(config.ICON_DIR) == 0 and
image.find(osd.settings.icon_dir) == -1:
new_image = os.path.join(osd.settings.icon_dir,
image[len(config.ICON_DIR)+1:])
if os.path.isfile(new_image):
@@ -177,9 +187,8 @@
def set_sprite(self):
- _debug_('set_sprite(self)', 2)
- '''set the sprite image name and the drawing interval
- '''
+ """ set the sprite image name and the drawing interval """
+ _debug_('set_sprite()', 1)
(status, jobs) = self.listjobs()
if not status:
self.sprite = self.notrunning
@@ -239,12 +248,12 @@
def calculatesizes(self, osd, font):
- '''size calcs is not necessery on every pass
+ """size calcs is not necessery on every pass
There are some shortcuts here, the left and right clamps are the same
with
all sprites are the same size and the background
return true when the progress has changed, false otherwise
- '''
- _debug_('calculatesizes(self, osd, font)', 2)
+ """
+ _debug_('calculatesizes(osd, font)', 1)
if self.progress_x == None:
background = self.getimage(self.background, osd)
rightclamp = self.getimage(self.rightclamp, osd, True)
@@ -271,12 +280,11 @@
def draw(self, (type, object), x, osd):
- '''Build the image by blitting sub images on the background and draw
the background
- '''
+ """ Build the image by blitting sub images on the background and draw
the background """
_debug_('draw((type=%r, object=), x=%r, osd=)' % (type, x), 3)
now = time.time()
duration = now - self.drawtime
- _debug_("draw=%.2f, interval=%s, state=%s" % (duration,
self.draw_interval, self.state), 2)
+ _debug_("draw=%.2f, interval=%s, state=%s" % (duration,
self.draw_interval, self.state), 1)
self.drawtime = now
self.lastdraw = now
@@ -305,12 +313,12 @@
def poll(self):
- '''poll function'''
+ """poll function"""
now = time.time()
pollduration = now - self.lastpoll
drawduration = now - self.lastdraw
self.lastpoll = now
- _debug_("poll(self): poll=%.2f, draw=%.2f, interval=%s, state=%s" % \
+ _debug_("poll(): poll=%.2f, draw=%.2f, interval=%s, state=%s" % \
(pollduration, drawduration, self.draw_interval, self.state), 2)
if drawduration >= self.draw_interval / 100:
if skin.active():
@@ -325,6 +333,6 @@
def update(self):
- _debug_('update(self)', 2)
+ _debug_('update()', 1)
bar = plugin.getbyname('idlebar')
if bar: bar.poll()
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog