gmyth-stream/server/0.1/lib.py
author morphbr
Mon Apr 30 18:16:36 2007 +0100 (2007-04-30)
branchtrunk
changeset 605 4dd9bf602c18
permissions -rw-r--r--
[svn r611] * GMyth-Streamer
- updated mencoder plugin

* GMyth
- samples: gmyth_cat code update
     1 import time
     2 import logging
     3 import os
     4 import stat
     5 
     6 ext = ['mpg', 'avi', 'mp4', 'nuv', 'mpeg', 'mov']
     7 
     8 def now():
     9     return time.strftime("%Y-%m-%d %H:%M:%S");
    10 
    11 def log(msg):
    12     logging.log(logging.DEBUG, msg)
    13     new_msg = "[%s] %s" % (now(), msg)
    14     return new_msg
    15 
    16 
    17 bin_path_list = os.environ["PATH"].split(os.pathsep)
    18 def which(prg):
    19     for d in bin_path_list:
    20         path = os.path.join(d, prg)
    21         if os.path.exists(path):
    22             st = os.stat(path)
    23             if st[stat.ST_MODE] & 0111:
    24                 return path
    25     return ""
    26 
    27 def list_media_files(directory, file_list):
    28     for root, dirs, files in os.walk(directory):
    29         for name in files:
    30             if os.path.splitext(name)[1].strip(".") in ext:
    31                 media = os.path.join(root,name)
    32                 if media not in file_list:
    33                     file_list.append(os.path.join(root,name))
    34 
    35     return True
    36