Changeset 446 for indytube/trunk

Show
Ignore:
Timestamp:
12/22/08 03:22:52 (19 months ago)
Author:
andy
Message:

add in svn:igore

Location:
indytube/trunk/indytube
Files:
1 removed
5 modified

Legend:

Unmodified
Added
Removed
  • indytube/trunk/indytube

    • Property svn:ignore set to
      content
      logs
      locks

  • indytube/trunk/indytube/__init__.py

    r249 r446  
    1 # 
     1#module 
  • indytube/trunk/indytube/config.py

    r289 r446  
    11# configuration for indytube 
    22 
    3 CONF_FILE_DEFAULT = "indytube.conf" 
     3CONF_FILE_DEFAULT = "/etc/indytube/indytube.conf" 
  • indytube/trunk/indytube/indytube.conf

    r344 r446  
    2020 
    2121[paths] 
     22BASE_DIRECTORY=/home/andy/src/EngageMedia/indytube/indytube-trunk/indytube/ 
    2223VIDEO_FILE_DIRECTORY=content/videos/ 
    2324FLV_FILE_DIRECTORY=content/transcoded/ 
  • indytube/trunk/indytube/indytube.py

    r344 r446  
    1717#templating system 
    1818from 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 
     25class IndyTubeProcessor(object): 
     26   """ The IndyTube processing class . Uses the Indytube Queue Server API to get jobs to perform. """ 
    2627   #holds statistics of files checked, and successfully transcoded, for each pass. 
    2728   checked = 0 
     
    3233 
    3334   def __init__(self): 
    34     """constructor for IndyTubeTranscoder""" 
     35    """constructor for IndyTubeProcessor""" 
    3536 
    3637   def rereadConfig(self,signal,frame): 
     
    5657    self.DO_ENCODING=config.getboolean('encoder','DO_ENCODING') 
    5758    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') 
    5960    self.POLLTIME=int(config.get('encoder','POLLTIME')) 
    6061 
    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') 
    6566 
    6667    self.INCLUDE_FILE_SUFFIX=config.get('paths','INCLUDE_FILE_SUFFIX') 
     
    7374    self.SPLASH_IMAGE_FILE=config.get('urls','SPLASH_IMAGE_FILE') 
    7475 
    75     self.LOG_FILE=config.get('logging','LOG_FILE') 
     76    self.LOG_FILE=config.get('paths','BASE_DIRECTORY') + config.get('logging','LOG_FILE') 
    7677    #whoa, eval , from a conf file input. nasty 
    7778    self.LOG_LEVEL=eval(config.get('logging','LOG_LEVEL')) 
     
    120121        self.xmlrpc_ref = xmlrpclib.Server(self.BITTORRENT_QUEUE) 
    121122        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) 
    124125        return 
    125126    #processing....   
     
    301302                try: 
    302303                        # 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 
    304310 
    305311                        # if the flv file (autogenerated) or html snippet is not there, then reencode! 
     
    394400        return [ worked, f ] 
    395401 
    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 others 
    403         if indytuber.check_lock_file(): 
    404  
    405             #do downloading 
    406             indytuber.do_downloading_loop() 
    407  
    408             #do transcoding 
    409             indytuber.do_transcoding_loop() 
    410  
    411             #do torrrenting 
    412             indytuber.do_torrent_loop() 
    413  
    414             os.remove(indytuber.ENCODER_LOCKFILE) 
    415  
    416         #recursive, time-delayed callback 
    417         #periodically run this function ,to keep looping 
    418         # 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 looperInvoker 
    422    
    423     #make an IndyTubeTranscoder object 
    424     indytuber = IndyTubeTranscoder() 
    425     #parse our config 
    426     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 HERE 
    431  
    432     #ok, parse the file 
    433     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 off 
    438     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 reactor 
    445     # see http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#Igetexceptions.ValueError:signalonlyworksinmainthreadwhenItrytorunmyTwistedprogramWhatswrong 
    446     # if you want to not install the signal handlers 
    447     reactor.run() 
    448  
    449 # this only runs if the module was *not* imported 
    450 if __name__ == '__main__': 
    451     main() 
    452  
    453402# Copyright John Duda, 2006 
    454 # Copyright Andy Nicholson, 2007 
     403# Copyright Andy Nicholson, 2007,2008 
    455404 
    456405# This program is free software; you can redistribute it and/or modify