Changeset 4dcb0e0db92c780255577d9a91195c64c781d6b8

Show
Ignore:
Timestamp:
03/04/08 20:32:56 (9 months ago)
Author:
wgw <tjm1100@gmail.com>
git-committer:
wgw <tjm1100@gmail.com> 1204684376 -0600
git-parent:

[c1400e9a79720bf1ac91e1bf94e0bd4bcfe04407]

git-author:
wgw <tjm1100@gmail.com> 1204684376 -0600
Message:

User defined debug output path

Usage:
Add the following to pyTivo.conf Server section:
debug = true, path, split
where path is the directory where debug.txt is to be written.
split will cause debug output to be written to separate files
by module name. If either path or split is specified, the
pyTivo folder name is added to the debug.txt file name.

Examples:
debug = true, c:\debug
writes debug.txt to the directory c:\debug, if it exists.

debug = true, c:\debug, split
writes debug.txt to the directory c:\debug, if it exists,
and splits the output to separate files by source module.
For example, debug output would be written to the following files:
c:\debug\debug.pytivo.video.txt
c:\debug\debug.pytivo.transcode.txt

debug = truesplit
splits the debug output to separate files in the pytivo folder.

debug = true
write debug output to file debug.txt in pytivo folder.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • config.py

    rc1400e9 r4dcb0e0  
    8686    return shares 
    8787 
    88 def getDebug(): 
    89     try: 
    90         return config.getboolean('Server', 'debug') 
    91     except NoOptionError, ValueError: 
    92         return False 
     88def getDebug(ref): 
     89    if config.has_option('Server', 'debug'): 
     90        try: 
     91            return str2tuple(config.get('Server', 'debug')+',,')[ref] 
     92        except NoOptionError: 
     93            pass 
     94    return str2tuple('False,,')[ref] 
    9395 
    9496def getHack83(): 
     
    235237    except NoOptionError:  
    236238        return int(448) #default to 448 
     239 
     240def str2tuple(s): 
     241    items = s.split(',') 
     242    L = [x.strip() for x in items] 
     243    return tuple(L) 
    237244 
    238245# Parse a bitrate using the SI/IEEE suffix values as if by ffmpeg 
  • debug.py

    r4cde353 r4dcb0e0  
    66 
    77def debug_write(srcMod, fnAttr, data): 
    8     if config.getDebug()
     8    if config.getDebug(0).lower() == 'true'
    99        debug_out = [] 
    1010        modname=srcMod.split('.')[-1] 
     
    1212        for x in data: 
    1313            debug_out.append(str(x)) 
    14         fdebug = open(os.path.join(p, 'debug.txt'), 'a') 
     14        fpath = p 
     15        fname = [] 
     16        fname.append('debug') 
     17        if not config.getDebug(1) == '' or not config.getDebug(2) == '': 
     18            if os.path.isdir(config.getDebug(1)): 
     19                fpath = config.getDebug(1) 
     20            fname.append(os.path.split(os.path.dirname(__file__))[-1]) 
     21            if config.getDebug(2).lower() == 'split':  
     22                fname.append(modname) 
     23        fname.append('txt') 
     24        fdebug = open(os.path.join(fpath, '.'.join(fname)), 'a') 
    1525        fdebug.write(' '.join(debug_out)+'\n') 
    1626        print '___'+' '.join(debug_out) 
     
    2232 
    2333def print_conf(srcMod, fnAttr): 
    24     if config.getDebug()
     34    if config.getDebug(0).lower() == 'true'
    2535        debug_write(srcMod, fnAttr, ['********************************************************'])  
    2636        debug_write(srcMod, fnAttr, ['**  Begin pyTivo Session:', datetime.datetime.today(), ' **'])