def transcodeVideos(self):
   logging.info("Starting VideoTranscoder thread")
   while not self.must_die_event.wait(2):
     # Bug de python <2.7: la methode wait() de threadin.Event renvoie
     # tout le temps None. On teste donc le flag pour savoir si il faut
     # quitter.
     if self.must_die_event.isSet():
       return
     try:
       video = self.transcode_queue.get_nowait()
       try:
         os.stat(video.local_filename)
       except OSError, e:
         logging.warning("%s n'existe pas !" % video.local_filename)
         continue
       if self.transcodeOneVideo(video):
         self.transcoded_files.add(video)
         # La video contient le nom unique du Pipeline dont elle est issue.
         # En recuperant son Pipeline, on recupere sa file d'attente de podcast
         pipeline = PipelineFactory.getPipelineByName(video.pipeline_name)
         if pipeline is None:
           logging.warning("Video sans Pipeline valide !")
           continue
         pipeline.podcaster_queue.put(video)
       elif self.must_die_event.isSet():
         return
     except Queue.Empty, e:
       if self.must_die_event.isSet():
         return
 def startPipelines(self):
   """Demarre tous les pipelines.
   """
   self.rss_feedserver_thread = self.rss_feedserver.start()
   self.threads.append(self.rss_feedserver_thread)
   for pipeline_name in self.pipeline_specs:
     PipelineFactory.getPipelineByName(pipeline_name).start()
   # On ne peut regarder les videos transcodees qu'apres car il faut les
   # orienter vers le bon pipeline
   for video in self.transcoded_files:
     pipeline = PipelineFactory.getPipelineByName(video.pipeline_name)
     if pipeline is not None:
       pipeline.podcaster_queue.put(video)
     else:
       logging.warning("Impossible de trouver le pipeline (%s) de %s"
                       % (video.pipeline_name, str(video)))
   # Si il y a un Pipeline Jabber, on lui passe le controlleur pour qu'il
   # puisse repondre a la commande "status".
   try:
     pipeline = PipelineFactory.getPipelineByName("gtalk_youtube")
     pipeline.jabber_bot_thread.controller = self
   except ValueError, e:
     logging.info("Pas de Pipeline Jabber")
 def do_GET(self):
   # Le header "Host"
   host = self.headers["Host"]
   if ":" in host:
     host = host[:host.rindex(':')]
   # On nettoie un peu le "path"
   path = self.path
   path = path.split('?',1)[0]
   path = path.split('#',1)[0]
   path = urllib.unquote(path)
   # Ensuite, on en prend la derniere partie, qui doit correspondre a un nom
   # de Pipeline (sans le ".xml")
   pipeline_name = path.split('/')[-1]
   pipeline_name = pipeline_name[:pipeline_name.rindex(".")]
   pipeline = None
   from user_config import PipelineFactory
   try:
     pipeline = PipelineFactory.getPipelineByName(pipeline_name)
     logging.info(pipeline_name)
   except ValueError, e:
     logging.warning("Pipeline invalide : " + pipeline_name)
     self.send_error(404, "File Not Found")
     return