gmyth-stream/server/lib.py
author morphbr
Tue Apr 17 15:48:40 2007 +0100 (2007-04-17)
branchtrunk
changeset 560 4a18d3961be9
parent 516 f353f0da6f07
permissions -rw-r--r--
[svn r565] - Bug fixes in gmyth-streamer (0.1)
     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