renatofilho@484: import time morphbr@511: import logging morphbr@511: import os morphbr@511: import stat renatofilho@484: morphbr@516: global ext = ['mpg', 'avi', 'mp4', 'nuv', 'mpeg', 'mov'] morphbr@516: renatofilho@484: def now(): renatofilho@484: return time.strftime("%Y-%m-%d %H:%M:%S"); renatofilho@484: renatofilho@484: def log(msg): morphbr@511: logging.log(logging.DEBUG, msg) renatofilho@484: new_msg = "[%s] %s" % (now(), msg) renatofilho@484: return new_msg morphbr@511: morphbr@511: morphbr@511: bin_path_list = os.environ["PATH"].split(os.pathsep) morphbr@511: def which(prg): morphbr@511: for d in bin_path_list: morphbr@511: path = os.path.join(d, prg) morphbr@511: if os.path.exits(path): morphbr@511: st = os.stat(path) morphbr@511: if st[stat.ST_MODE] & 0111: morphbr@511: return path morphbr@511: return "" morphbr@511: morphbr@516: def list_media_files(directory, file_list): morphbr@516: for root, dirs, files in os.walk(directory): morphbr@516: for name in files: morphbr@516: if os.path.splitext(name)[1].strip(".") in ext: morphbr@516: media = os.path.join(root,name) morphbr@516: if media not in file_list morphbr@516: file_list.append(os.path.join(root,name)) morphbr@511: morphbr@516: return True morphbr@516: