gmyth-stream/server/0.1/lib.py
branchtrunk
changeset 786 a4529d0f8ede
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gmyth-stream/server/0.1/lib.py	Thu Jul 05 13:43:24 2007 +0100
     1.3 @@ -0,0 +1,36 @@
     1.4 +import time
     1.5 +import logging
     1.6 +import os
     1.7 +import stat
     1.8 +
     1.9 +ext = ['mpg', 'avi', 'mp4', 'nuv', 'mpeg', 'mov']
    1.10 +
    1.11 +def now():
    1.12 +    return time.strftime("%Y-%m-%d %H:%M:%S");
    1.13 +
    1.14 +def log(msg):
    1.15 +    logging.log(logging.DEBUG, msg)
    1.16 +    new_msg = "[%s] %s" % (now(), msg)
    1.17 +    return new_msg
    1.18 +
    1.19 +
    1.20 +bin_path_list = os.environ["PATH"].split(os.pathsep)
    1.21 +def which(prg):
    1.22 +    for d in bin_path_list:
    1.23 +        path = os.path.join(d, prg)
    1.24 +        if os.path.exists(path):
    1.25 +            st = os.stat(path)
    1.26 +            if st[stat.ST_MODE] & 0111:
    1.27 +                return path
    1.28 +    return ""
    1.29 +
    1.30 +def list_media_files(directory, file_list):
    1.31 +    for root, dirs, files in os.walk(directory):
    1.32 +        for name in files:
    1.33 +            if os.path.splitext(name)[1].strip(".") in ext:
    1.34 +                media = os.path.join(root,name)
    1.35 +                if media not in file_list:
    1.36 +                    file_list.append(os.path.join(root,name))
    1.37 +
    1.38 +    return True
    1.39 +