import time
import logging
import os
import stat

def now():
    return time.strftime("%Y-%m-%d %H:%M:%S");

def log(msg):
    logging.log(logging.DEBUG, msg)
    new_msg = "[%s] %s" % (now(), msg)
    return new_msg


bin_path_list = os.environ["PATH"].split(os.pathsep)
def which(prg):
    for d in bin_path_list:
        path = os.path.join(d, prg)
        if os.path.exits(path):
            st = os.stat(path)
            if st[stat.ST_MODE] & 0111:
                return path
    return ""


