1 import ConfigParser
, os
, re
, sys
5 p
= os
.path
.dirname(__file__
)
7 def debug_write(srcMod
, fnAttr
, data
):
8 if config
.getDebug(0).lower() == 'true':
10 modname
=srcMod
.split('.')[-1]
11 debug_out
.append(modname
+'.'+fnAttr
[1]+' ['+fnAttr
[0]+'] ')
13 debug_out
.append(str(x
))
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':
24 fdebug
= open(os
.path
.join(fpath
, '.'.join(fname
)), 'a')
25 fdebug
.write(' '.join(debug_out
)+'\n')
26 print 'DEBUG:'+' '.join(debug_out
)
30 "returns name of calling function and line number"
31 return sys
._getframe
(1).f_code
.co_name
, str(sys
._getframe
(1).f_lineno
)
33 def print_conf(srcMod
, fnAttr
):
34 if config
.getDebug(0).lower() == 'true':
35 debug_write(srcMod
, fnAttr
, ['********************************************************'])
36 debug_write(srcMod
, fnAttr
, ['** Begin pyTivo Session:', datetime
.datetime
.today(), ' **'])
37 debug_write(srcMod
, fnAttr
, ['********************************************************'])
38 debug_write(srcMod
, fnAttr
, ['----- begin pyTivo.conf -----'])
39 conf
= open(os
.path
.join(p
, 'pyTivo.conf'))
40 for line
in conf
.readlines():
41 if line
.strip().startswith('#'):
43 if len(line
.strip()) != 0:
44 debug_write(srcMod
, fnAttr
, [line
.strip()])
46 debug_write(srcMod
, fnAttr
, ['------- end pyTivo.conf -----'])
48 print_conf(__name__
, fn_attr())