gmyth-stream/server/lib.py
author morphbr
Mon Apr 09 16:22:37 2007 +0100 (2007-04-09)
branchtrunk
changeset 514 b5352888e3c2
parent 484 27e83a8f68d7
child 516 f353f0da6f07
permissions -rw-r--r--
[svn r519] Gmyth-Streamer: Mencoder update
renatofilho@484
     1
import time
morphbr@511
     2
import logging
morphbr@511
     3
import os
morphbr@511
     4
import stat
renatofilho@484
     5
renatofilho@484
     6
def now():
renatofilho@484
     7
    return time.strftime("%Y-%m-%d %H:%M:%S");
renatofilho@484
     8
renatofilho@484
     9
def log(msg):
morphbr@511
    10
    logging.log(logging.DEBUG, msg)
renatofilho@484
    11
    new_msg = "[%s] %s" % (now(), msg)
renatofilho@484
    12
    return new_msg
morphbr@511
    13
morphbr@511
    14
morphbr@511
    15
bin_path_list = os.environ["PATH"].split(os.pathsep)
morphbr@511
    16
def which(prg):
morphbr@511
    17
    for d in bin_path_list:
morphbr@511
    18
        path = os.path.join(d, prg)
morphbr@511
    19
        if os.path.exits(path):
morphbr@511
    20
            st = os.stat(path)
morphbr@511
    21
            if st[stat.ST_MODE] & 0111:
morphbr@511
    22
                return path
morphbr@511
    23
    return ""
morphbr@511
    24
morphbr@511
    25