gmyth-stream/server/lib.py
author melunko
Wed Apr 11 22:24:39 2007 +0100 (2007-04-11)
branchtrunk
changeset 527 eebe6df8aa11
parent 511 16312d0021cb
child 533 e55310730feb
permissions -rw-r--r--
[svn r532] Fixed segmentation fault at program_info_print/debug function
     1 import time
     2 import logging
     3 import os
     4 import stat
     5 
     6 global 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.exits(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