Changeset 446 for indytube/trunk
- Timestamp:
- 12/22/08 03:22:52 (19 months ago)
- Location:
- indytube/trunk/indytube
- Files:
-
- 1 removed
- 5 modified
-
. (modified) (1 prop)
-
__init__.py (modified) (1 diff)
-
config.py (modified) (1 diff)
-
indytube.conf (modified) (1 diff)
-
indytube.py (modified) (7 diffs)
-
locks (deleted)
Legend:
- Unmodified
- Added
- Removed
-
indytube/trunk/indytube
-
Property
svn:ignore set
to
content
logs
locks
-
Property
svn:ignore set
to
-
indytube/trunk/indytube/__init__.py
r249 r446 1 # 1 #module -
indytube/trunk/indytube/config.py
r289 r446 1 1 # configuration for indytube 2 2 3 CONF_FILE_DEFAULT = " indytube.conf"3 CONF_FILE_DEFAULT = "/etc/indytube/indytube.conf" -
indytube/trunk/indytube/indytube.conf
r344 r446 20 20 21 21 [paths] 22 BASE_DIRECTORY=/home/andy/src/EngageMedia/indytube/indytube-trunk/indytube/ 22 23 VIDEO_FILE_DIRECTORY=content/videos/ 23 24 FLV_FILE_DIRECTORY=content/transcoded/ -
indytube/trunk/indytube/indytube.py
r344 r446 17 17 #templating system 18 18 from Cheetah.Template import Template 19 #twisted networking 20 from twisted.internet import reactor 21 22 from config import CONF_FILE_DEFAULT 23 24 class IndyTubeTranscoder(object): 25 """ The IndyTube transcoding class . Invokes mencoder and ffmpeg2theora """ 19 # 20 # Define the indytube processor class 21 # Uses the queueing server API to get jobs to peform, and do downloading/torrenting/transcoding/ etc 22 # 23 # 24 25 class IndyTubeProcessor(object): 26 """ The IndyTube processing class . Uses the Indytube Queue Server API to get jobs to perform. """ 26 27 #holds statistics of files checked, and successfully transcoded, for each pass. 27 28 checked = 0 … … 32 33 33 34 def __init__(self): 34 """constructor for IndyTube Transcoder"""35 """constructor for IndyTubeProcessor""" 35 36 36 37 def rereadConfig(self,signal,frame): … … 56 57 self.DO_ENCODING=config.getboolean('encoder','DO_ENCODING') 57 58 self.NUMBER_OF_PARALLEL_ENCODERS=config.getint('encoder','NUMBER_OF_PARALLEL_ENCODERS') 58 self.ENCODER_LOCKFILE_BASE=config.get(' encoder','ENCODER_LOCKFILE_BASE')59 self.ENCODER_LOCKFILE_BASE=config.get('paths','BASE_DIRECTORY') + config.get('encoder','ENCODER_LOCKFILE_BASE') 59 60 self.POLLTIME=int(config.get('encoder','POLLTIME')) 60 61 61 self.VIDEO_FILE_DIRECTORY=config.get('paths',' VIDEO_FILE_DIRECTORY')62 self.FLV_FILE_DIRECTORY=config.get('paths',' FLV_FILE_DIRECTORY')63 self.INCLUDE_FILE_DIRECTORY=config.get('paths',' INCLUDE_FILE_DIRECTORY')64 self.TORRENT_DIRECTORY=config.get('paths',' TORRENT_DIRECTORY')62 self.VIDEO_FILE_DIRECTORY=config.get('paths','BASE_DIRECTORY') +config.get('paths','VIDEO_FILE_DIRECTORY') 63 self.FLV_FILE_DIRECTORY=config.get('paths','BASE_DIRECTORY') + config.get('paths','FLV_FILE_DIRECTORY') 64 self.INCLUDE_FILE_DIRECTORY=config.get('paths','BASE_DIRECTORY') + config.get('paths','INCLUDE_FILE_DIRECTORY') 65 self.TORRENT_DIRECTORY=config.get('paths','BASE_DIRECTORY') + config.get('paths','TORRENT_DIRECTORY') 65 66 66 67 self.INCLUDE_FILE_SUFFIX=config.get('paths','INCLUDE_FILE_SUFFIX') … … 73 74 self.SPLASH_IMAGE_FILE=config.get('urls','SPLASH_IMAGE_FILE') 74 75 75 self.LOG_FILE=config.get(' logging','LOG_FILE')76 self.LOG_FILE=config.get('paths','BASE_DIRECTORY') + config.get('logging','LOG_FILE') 76 77 #whoa, eval , from a conf file input. nasty 77 78 self.LOG_LEVEL=eval(config.get('logging','LOG_LEVEL')) … … 120 121 self.xmlrpc_ref = xmlrpclib.Server(self.BITTORRENT_QUEUE) 121 122 self.jobs = self.xmlrpc_ref.listofWaitingJobItems() 122 except :123 logging.info("Ending indytube downloading component because of exception! ")123 except Exception,e: 124 logging.info("Ending indytube downloading component because of exception!\n Exception %s" % e) 124 125 return 125 126 #processing.... … … 301 302 try: 302 303 # touch the lock file 303 os.mknod(lockfile) 304 #we should catch the exception here, and return FALSE! 305 try: 306 os.mknod(lockfile) 307 except: 308 logging.info("lock file creation failed! ABORTING. %s " % lockfile) 309 return False 304 310 305 311 # if the flv file (autogenerated) or html snippet is not there, then reencode! … … 394 400 return [ worked, f ] 395 401 396 def main():397 398 def looperInvoker(indytuber):399 """recursively invoked callback, to check invoking do_transcoding_loop"""400 401 logging.debug("started looperInvoker function at %s, calling loop every %s seconds " % (time.strftime("%D %H:%M:%S"), indytuber.POLLTIME))402 #check for others403 if indytuber.check_lock_file():404 405 #do downloading406 indytuber.do_downloading_loop()407 408 #do transcoding409 indytuber.do_transcoding_loop()410 411 #do torrrenting412 indytuber.do_torrent_loop()413 414 os.remove(indytuber.ENCODER_LOCKFILE)415 416 #recursive, time-delayed callback417 #periodically run this function ,to keep looping418 # passing along the indytube object as an argument. (try not to _call_ this function or else you'll end up in infinite recursion!)419 reactor.callLater(indytuber.POLLTIME,looperInvoker,indytuber)420 421 ##END looperInvoker422 423 #make an IndyTubeTranscoder object424 indytuber = IndyTubeTranscoder()425 #parse our config426 if not (os.path.exists(CONF_FILE_DEFAULT)):427 logging.error("cannot find configuration file %s " % (CONF_FILE_DEFAULT))428 #leaving!!429 sys.exit(0)430 #this code path ENDS HERE431 432 #ok, parse the file433 indytuber.parse_config(CONF_FILE_DEFAULT)434 435 #we have started!436 logging.info("started main function at %s, calling loop every %s seconds " % (time.strftime("%D %H:%M:%S"), indytuber.POLLTIME))437 #start it for real, once off438 looperInvoker(indytuber)439 440 #install a signal handler to re-read configuration files.441 # eg kill -s USR2 <pid>442 signal.signal(signal.SIGUSR2, indytuber.rereadConfig)443 444 #start the twisted reactor445 # see http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#Igetexceptions.ValueError:signalonlyworksinmainthreadwhenItrytorunmyTwistedprogramWhatswrong446 # if you want to not install the signal handlers447 reactor.run()448 449 # this only runs if the module was *not* imported450 if __name__ == '__main__':451 main()452 453 402 # Copyright John Duda, 2006 454 # Copyright Andy Nicholson, 2007 403 # Copyright Andy Nicholson, 2007,2008 455 404 456 405 # This program is free software; you can redistribute it and/or modify
