Changeset 4dcb0e0db92c780255577d9a91195c64c781d6b8
- 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
| rc1400e9 |
r4dcb0e0 |
|
| 86 | 86 | return shares |
|---|
| 87 | 87 | |
|---|
| 88 | | def getDebug(): |
|---|
| 89 | | try: |
|---|
| 90 | | return config.getboolean('Server', 'debug') |
|---|
| 91 | | except NoOptionError, ValueError: |
|---|
| 92 | | return False |
|---|
| | 88 | def 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] |
|---|
| 93 | 95 | |
|---|
| 94 | 96 | def getHack83(): |
|---|
| … | … | |
| 235 | 237 | except NoOptionError: |
|---|
| 236 | 238 | return int(448) #default to 448 |
|---|
| | 239 | |
|---|
| | 240 | def str2tuple(s): |
|---|
| | 241 | items = s.split(',') |
|---|
| | 242 | L = [x.strip() for x in items] |
|---|
| | 243 | return tuple(L) |
|---|
| 237 | 244 | |
|---|
| 238 | 245 | # Parse a bitrate using the SI/IEEE suffix values as if by ffmpeg |
|---|
| r4cde353 |
r4dcb0e0 |
|
| 6 | 6 | |
|---|
| 7 | 7 | def debug_write(srcMod, fnAttr, data): |
|---|
| 8 | | if config.getDebug(): |
|---|
| | 8 | if config.getDebug(0).lower() == 'true': |
|---|
| 9 | 9 | debug_out = [] |
|---|
| 10 | 10 | modname=srcMod.split('.')[-1] |
|---|
| … | … | |
| 12 | 12 | for x in data: |
|---|
| 13 | 13 | 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') |
|---|
| 15 | 25 | fdebug.write(' '.join(debug_out)+'\n') |
|---|
| 16 | 26 | print '___'+' '.join(debug_out) |
|---|
| … | … | |
| 22 | 32 | |
|---|
| 23 | 33 | def print_conf(srcMod, fnAttr): |
|---|
| 24 | | if config.getDebug(): |
|---|
| | 34 | if config.getDebug(0).lower() == 'true': |
|---|
| 25 | 35 | debug_write(srcMod, fnAttr, ['********************************************************']) |
|---|
| 26 | 36 | debug_write(srcMod, fnAttr, ['** Begin pyTivo Session:', datetime.datetime.today(), ' **']) |
|---|