Author: duncan
Date: Thu Oct 11 15:17:34 2007
New Revision: 9951

Log:
Small code tidy-up and changed logging to use FREEVO_LOGDIR


Modified:
   branches/rel-1/freevo/src/www/htdocs/config.rpy
   branches/rel-1/freevo/src/www/htdocs/pluginconfig.rpy
   branches/rel-1/freevo/src/www/htdocs/viewlogfile.rpy

Modified: branches/rel-1/freevo/src/www/htdocs/config.rpy
==============================================================================
--- branches/rel-1/freevo/src/www/htdocs/config.rpy     (original)
+++ branches/rel-1/freevo/src/www/htdocs/config.rpy     Thu Oct 11 15:17:34 2007
@@ -34,11 +34,12 @@
 import string
 import types
 import time
+import urllib
 from www.web_types import HTMLResource, FreevoResource
 
 def ReadConfig(cfile):
     lconf = cfile
-    lconf_hld = open(lconf,'r')
+    lconf_hld = open(lconf, 'r')
     fconf = lconf_hld.readlines()
     return fconf
 
@@ -73,7 +74,7 @@
                     ln = ln.split('#')[0]
                     ln = ln.strip()
                     fln += ln
-                fln = fln.replace('\n','')
+                fln = fln.replace('\n', '')
         else:
             fln = ln
         pln = ParseLine(fln)
@@ -88,8 +89,8 @@
 
 def ParseLine(cline):
     lparsed = {'ctrlname': '',
-               'ctrlvalue': '' ,
-               'checked': True ,
+               'ctrlvalue': '',
+               'checked': True,
                'type' : '',
                'comments' : '',
                'level':'',
@@ -100,7 +101,7 @@
                'vartype':''}
 
     tln = cline.strip()
-    tln = tln.replace('\n','')
+    tln = tln.replace('\n', '')
     if tln.startswith('#'):
         lparsed['checked'] = False
         tln = tln.lstrip('#')
@@ -129,7 +130,7 @@
                 lparsed['comments'] = ctrlvalue[1]
             lparsed['ctrlvalue'] = ctrlvalue[0].strip()
     lparsed['vartype'] = VarType(lparsed['ctrlvalue'])
-    lparsed['ctrlvalue'] = lparsed['ctrlvalue'].replace('"',"'")
+    lparsed['ctrlvalue'] = lparsed['ctrlvalue'].replace('"', "'")
 
     if lparsed['ctrlname'].startswith('"'):
         lparsed['type'] = ""
@@ -174,7 +175,7 @@
     return grps
 
 
-def getCtrlType(cname , cvalue, vtype):
+def getCtrlType(cname, cvalue, vtype):
     if vtype == 'boolean':
         return 'boolean'
     if cname == 'TV_CHANNELS':
@@ -198,7 +199,7 @@
 
 
 def FileTypeVarArray(cname):
-    filevars = ['VIDEO_ITEMS','AUDIO_ITEMS','IMAGE_ITEMS','GAME_ITEMS']
+    filevars = ['VIDEO_ITEMS', 'AUDIO_ITEMS', 'IMAGE_ITEMS', 'GAME_ITEMS']
 
     if cname in filevars:
         return True
@@ -207,8 +208,8 @@
 
 def FileTypeVar(cname):
     vtype = cname.split('_')[-1]
-    filetypes = ['PATH','DIR','FILE','DEV','DEVICE']
-    filevars = 
['XMLTV_GRABBER','RSS_AUDIO','RSS_VIDEO','RSS_FEEDS','XMLTV_SORT','LIRCRC']
+    filetypes = ['PATH', 'DIR', 'FILE', 'DEV', 'DEVICE']
+    filevars = ['XMLTV_GRABBER', 'RSS_AUDIO', 'RSS_VIDEO', 'RSS_FEEDS', 
'XMLTV_SORT', 'LIRCRC']
 
     if vtype in filetypes:
         return True
@@ -243,12 +244,12 @@
     return ctrl
 
 
-def CreateTV_Channels_ctrl(cname,cvalue, cenabled):
+def CreateTV_Channels_ctrl(cname, cvalue, cenabled):
     ctrl = '<span class="Tv_Channels">'
     btnUp =  ''
     btnDown = ''
     btnMove =  '<input type="button" value="%s" '
-    btnMove += 'onclick=MoveTVChannel("%s",%i,%i)>'
+    btnMove += 'onclick=MoveTVChannel("%s", %i, %i)>'
     vitems = GetItemsArray(cvalue)
 
     spDisable_open = ''
@@ -260,19 +261,19 @@
     if vitems:
         txtbox =  '<input type="textbox" style={background:00BFFF} '
         txtbox += 'id="%s_item%i"value = "%s" size=30>'
-        for r , e in enumerate(vitems):
+        for r, e in enumerate(vitems):
             ctrl += '<li>%s' % spDisable_open
-            ctrl += btnMove % ('Up',cname,r,-1)
-            ctrl +=  txtbox % (cname,r,e)
+            ctrl += btnMove % ('Up', cname, r, -1)
+            ctrl +=  txtbox % (cname, r, e)
             if r <>  (len(vitems) -1):
-                ctrl += btnMove % ('Down',cname,r,1)
+                ctrl += btnMove % ('Down', cname, r, 1)
             ctrl += '%s</li>' % spDisable_close
             btnUp = '<input type="button" value="UP">'
     ctrl += '</span>'
     return ctrl
 
 
-def CreateFileItemList(cname,cvalue,cenabled):
+def CreateFileItemList(cname, cvalue, cenabled):
     ctrl = '<span class="FileList">'
     vitems = GetItemsArray(cvalue)
 
@@ -285,15 +286,15 @@
     maxcols = 1
     if vitems:
         txtops = ''
-        for r , e in enumerate(vitems):
+        for r, e in enumerate(vitems):
 
             ctrl += '<li>'
             if type(e) == types.StringType or type(e) ==  types.IntType:
-                ctrl +=  '%s<input type="textbox" %s 
id="%s_label%i"value="%s">%s' % (spDisable_open, txtops, 
cname,r,e,spDisable_close)
+                ctrl +=  '%s<input type="textbox" %s 
id="%s_label%i"value="%s">%s' % (spDisable_open, txtops, cname, r, e, 
spDisable_close)
             else:
-                txtLabelBox = '%s<input type="textbox" id="%s_label%i" 
"value="%s">%s' % (spDisable_open, cname,r,e[0], spDisable_close)
-                jsCheckFile = 'onchange=CheckValue("%s","fileitemlist","%i")' 
% ( cname ,r )
-                txtFolderBox = '%s<input type="textbox" id="%s_file%i" 
value="%s" %s>%s' % (spDisable_open, cname,r,e[1], jsCheckFile,spDisable_close)
+                txtLabelBox = '%s<input type="textbox" id="%s_label%i" 
"value="%s">%s' % (spDisable_open, cname, r, e[0], spDisable_close)
+                jsCheckFile = 'onchange=CheckValue("%s", "fileitemlist", 
"%i")' % (cname, r)
+                txtFolderBox = '%s<input type="textbox" id="%s_file%i" 
value="%s" %s>%s' % (spDisable_open, cname, r, e[1], jsCheckFile, 
spDisable_close)
                 ctrl += txtLabelBox + txtFolderBox
 
                 filecheck = ''
@@ -301,23 +302,23 @@
                 if not os.path.exists(e[1]):
                     filecheck = 'Missing File'
                     chkClass = 'CheckWarning'
-                ctrl += '%s<span class="%s" id="%s_check_%i">%s</span>%s' % ( 
spDisable_open, chkClass , cname, r , filecheck , spDisable_close)
+                ctrl += '%s<span class="%s" id="%s_check_%i">%s</span>%s' % 
(spDisable_open, chkClass, cname, r, filecheck, spDisable_close)
             ctrl += '</li>'
 
         r += 1;
-        txtLabelBox = '<input type="textbox" id="%s_label%i" "value="%s">' % 
(cname,r,"")
-        jsCheckFile = 'onchange=CheckValue("%s","fileitemlist","%i")' % ( 
cname ,r )
-        txtFolderBox = '<input type="textbox" id="%s_file%i" value="%s" %s>' % 
(cname,r,"", jsCheckFile)
+        txtLabelBox = '<input type="textbox" id="%s_label%i" "value="%s">' % 
(cname, r, "")
+        jsCheckFile = 'onchange=CheckValue("%s", "fileitemlist", "%i")' % 
(cname, r)
+        txtFolderBox = '<input type="textbox" id="%s_file%i" value="%s" %s>' % 
(cname, r, "", jsCheckFile)
         ctrl += '<li>'
         ctrl += txtLabelBox + txtFolderBox
-        ctrl += '<span class="" id="%s_check_%i"></span' % (cname , r)
+        ctrl += '<span class="" id="%s_check_%i"></span' % (cname, r)
         ctrl += '</li>'
 
     ctrl += '</span>\n'
     return ctrl
 
 
-def CreateDictionaryControl(cname,cvalue , cenabled):
+def CreateDictionaryControl(cname, cvalue, cenabled):
     ctrl2type = 'textbox'
     if cname =='WWW_USERS':
         ctrl2type = 'password'
@@ -333,12 +334,12 @@
     ctrl += '<ul class="ItemList">'
     if vitems:
         txtbox = '%s<input type="%s" id="%s_item%i%i" size=10 value="%s">%s'
-        for r , e in enumerate(vitems):
+        for r, e in enumerate(vitems):
             pword =  vitems[e]
-            ctrl += '<li>' +  txtbox % (spDisable_open, 'textbox',cname,r,0,e 
, spDisable_close)
-            ctrl +=  txtbox % ( spDisable_open,  ctrl2type,cname,r,0,vitems[e] 
, spDisable_close ) + '</li>\n'
-        ctrl += '<li>' + txtbox % (spDisable_open, 'textbox',cname,r+1,0,'""'  
, spDisable_close)
-        ctrl += txtbox % (spDisable_open, ctrl2type,cname,r+1,1,'""', 
spDisable_close) + '</li>'
+            ctrl += '<li>' +  txtbox % (spDisable_open, 'textbox', cname, r, 
0, e, spDisable_close)
+            ctrl +=  txtbox % (spDisable_open,  ctrl2type, cname, r, 0, 
vitems[e], spDisable_close) + '</li>\n'
+        ctrl += '<li>' + txtbox % (spDisable_open, 'textbox', cname, r+1, 0, 
'""', spDisable_close)
+        ctrl += txtbox % (spDisable_open, ctrl2type, cname, r+1, 1, '""', 
spDisable_close) + '</li>'
         ctrl += '</ul>'
         ctrl += '}</span>'
 
@@ -349,7 +350,7 @@
 
 
 
-def CreateListControl(cname,cvalue,cenable):
+def CreateListControl(cname, cvalue, cenable):
 
     spDisable_open = ''
     spDisable_close = ''
@@ -369,17 +370,17 @@
     if vitems:
         txtops = ''
 
-        txtbox = '%s<input type="textbox" onchange=CheckValue("' + cname + 
'","itemlist",0)  %s id="%s_item%i%i"value="%s">%s'
-        for r , e in enumerate(vitems):
+        txtbox = '%s<input type="textbox" onchange=CheckValue("' + cname + '", 
"itemlist", 0)  %s id="%s_item%i%i"value="%s">%s'
+        for r, e in enumerate(vitems):
             vtype = type(e)
             if vtype == types.StringType or vtype == types.FloatType or vtype 
== types.IntType:
-                ctrl +=  '<li>' +  txtbox % (spDisable_open, txtops, 
cname,r,0,e, spDisable_close) + '</li>'
+                ctrl +=  '<li>' +  txtbox % (spDisable_open, txtops, cname, r, 
0, e, spDisable_close) + '</li>'
             else:
                 ctrl += '<li>'
                 cols = 0
-                for c , e2 in enumerate(e):
+                for c, e2 in enumerate(e):
                     cols += 1;
-                    ctrl +=  txtbox % 
(spDisable_open,'',cname,r,c,e2,spDisable_close)
+                    ctrl +=  txtbox % (spDisable_open, '', cname, r, c, e2, 
spDisable_close)
 
                 if cols > maxcols:
                     maxcols = cols
@@ -388,40 +389,40 @@
         ctrl += '<li>\n'
 
         r+= 1;
-        for c in range(0,maxcols):
-            ctrl +=  txtbox % (spDisable_open,'',cname,r,c,'',spDisable_close)
+        for c in range(0, maxcols):
+            ctrl +=  txtbox % (spDisable_open, '', cname, r, c, '', 
spDisable_close)
         ctrl += "</li>\n"
         ctrl += '</ul>\n'
         ctrl += "%s]%s</span>\n" % (spDisable_open, spDisable_close)
         return ctrl
 
-    ctrl = CreateTextArea(cname,cvalue)
+    ctrl = CreateTextArea(cname, cvalue)
     return ctrl
 
 
-def CreateTextArea(cname,cvalue):
+def CreateTextArea(cname, cvalue):
     elemsep = ')'
     rows = cvalue.count(elemsep) + 1
     if rows > 5:
         rows = 5
-    cvalue = cvalue.replace(elemsep,elemsep + "\n")
+    cvalue = cvalue.replace(elemsep, elemsep + "\n")
     ctrl = ''
-    ctrl += '<textarea  id= "%s" rows = %s cols=35 wrap="SOFT" name=%s 
onchange=CheckValue("%s","textbox",0) >%s</textarea>'  % (cname, 
str(rows),cname,cname,cvalue)
+    ctrl += '<textarea  id= "%s" rows = %s cols=35 wrap="SOFT" name=%s 
onchange=CheckValue("%s", "textbox", 0) >%s</textarea>'  % (cname, str(rows), 
cname, cname, cvalue)
     return ctrl
 
 
-def CreateListBoxControl(cname,grps,cvalue,opts=""):
+def CreateListBoxControl(cname, grps, cvalue, opts=""):
     ctrl = '\n<select name="%s" value="%s"  id="%s" %s >' % (cname,  cvalue, 
cname, opts)
     for grp in grps:
         if grp == cvalue:
-            ctrl  += '\n    <option value="%s" selected="yes">%s</option>' % 
(grp , grp)
+            ctrl  += '\n    <option value="%s" selected="yes">%s</option>' % 
(grp, grp)
         else:
-            ctrl  += '\n    <option value="%s">%s</option>' % (grp,grp)
+            ctrl  += '\n    <option value="%s">%s</option>' % (grp, grp)
     ctrl += '\n</select>'
     return ctrl
 
 
-def CreateConfigLine(nctrl,expALL,plugin_group):
+def CreateConfigLine(nctrl, expALL, plugin_group):
     htmlctrl = HTMLResource()
 
     cname = nctrl['ctrlname']
@@ -447,7 +448,7 @@
 
     else:
         if FileTypeVar(cname):
-            filename = cvalue.replace("'",'').strip()
+            filename = cvalue.replace("'", '').strip()
             if not os.path.exists(filename):
                 lcheck = '<span class = "CheckWarning">Missing File</span>'
 
@@ -458,44 +459,44 @@
         disable_span_close =  '</span>'
 
 
-    htmlctrl.res += '%s<span id="%s_check" class="check">%s</span>%s' % 
(disable_span_open, cname , lcheck, disable_span_close)
-    ctrltype = getCtrlType(cname,cvalue, vtype)
-    jsonChange = 'onchange=CheckValue("%s","%s",0) '  % (cname , ctrltype )
-    chkbox = '%s<input type="checkbox" id = "%s_chk" %s  %s>%s\n' % ( 
disable_span_open, cname ,checked , jsonChange, disable_span_close )
-    delbtn = '%s<input type="button" class="configbutton" 
onclick=DeleteLines("%s",%i,%i) value="Delete">%s\n' % ( disable_span_open, 
cname, sline , eline , disable_span_close)
+    htmlctrl.res += '%s<span id="%s_check" class="check">%s</span>%s' % 
(disable_span_open, cname, lcheck, disable_span_close)
+    ctrltype = getCtrlType(cname, cvalue, vtype)
+    jsonChange = 'onchange=CheckValue("%s", "%s", 0) '  % (cname, ctrltype)
+    chkbox = '%s<input type="checkbox" id = "%s_chk" %s  %s>%s\n' % 
(disable_span_open, cname, checked, jsonChange, disable_span_close)
+    delbtn = '%s<input type="button" class="configbutton" 
onclick=DeleteLines("%s", %i, %i) value="Delete">%s\n' % (disable_span_open, 
cname, sline, eline, disable_span_close)
     htmlctrl.res += delbtn
     htmlctrl.res += chkbox
 
-    htmlctrl.res += '<a onclick=ShowList("%s_list")>%s</a>' % ( cname , cname )
+    htmlctrl.res += '<a onclick=ShowList("%s_list")>%s</a>' % (cname, cname)
     htmlctrl.res += '<ul style= display:%s id="%s_list">' % (displayvars, 
cname)
-    htmlctrl.res += '<input type="hidden" id="%s_startline" value="%i">\n' % ( 
cname , sline )
-    htmlctrl.res += '<input type="hidden" id="%s_endline" value="%i">\n' % ( 
cname, eline)
+    htmlctrl.res += '<input type="hidden" id="%s_startline" value="%i">\n' % 
(cname, sline)
+    htmlctrl.res += '<input type="hidden" id="%s_endline" value="%i">\n' % 
(cname, eline)
 
-    jsSave =  'onclick=SaveValue("%s","%s")' % (cname , ctrltype)
+    jsSave =  'onclick=SaveValue("%s", "%s")' % (cname, ctrltype)
 
-    btnupdate = '<input type="button" style="display:none;" id="%s_btn_update" 
class="button.config" value="Update" %s >\n' % (cname , jsSave )
+    btnupdate = '<input type="button" style="display:none;" id="%s_btn_update" 
class="button.config" value="Update" %s >\n' % (cname, jsSave)
     htmlctrl.res += btnupdate
 
     if nctrl['type'] == 'textbox':
-        inputbox = 
CreateTextBox(cname,cvalue,nctrl['vartype'],plugin_group,nctrl['checked'])
+        inputbox = CreateTextBox(cname, cvalue, nctrl['vartype'], 
plugin_group, nctrl['checked'])
         htmlctrl.res += "<li>%s %s %s</li>"  % (disable_span_open, inputbox, 
disable_span_close)
 
     htmlctrl.res += '</ul>'
     return htmlctrl.res
 
 
-def CreateTextBox(cname, cvalue ,vtype, plugin_group , cenabled):
-    cvalue = cvalue.replace(' ','')
+def CreateTextBox(cname, cvalue, vtype, plugin_group, cenabled):
+    cvalue = cvalue.replace(' ', '')
     cvalue = cvalue.strip()
-    bllist = ['True','False']
+    bllist = ['True', 'False']
 
     ctrl = ""
     if vtype == 'boolean':
-        ctrl = CreateListBoxControl(cname,bllist,cvalue, 
'onchange=CheckValue("%s","textbox",0)')
+        ctrl = CreateListBoxControl(cname, bllist, cvalue, 
'onchange=CheckValue("%s", "textbox", 0)')
         return ctrl
 
     if cname == 'TV_CHANNELS':
-        ctrl = CreateTV_Channels_ctrl(cname,cvalue,cenabled)
+        ctrl = CreateTV_Channels_ctrl(cname, cvalue, cenabled)
         return ctrl
 
     if plugin_group == "Enable":
@@ -503,23 +504,23 @@
             cvalue = "True"
         else :
             cvalue = "False"
-        ctrl = CreateListBoxControl(cname,bllist,cvalue, 
'onchange=CheckValue("%s","textbox",0)')
+        ctrl = CreateListBoxControl(cname, bllist, cvalue, 
'onchange=CheckValue("%s", "textbox", 0)')
         return ctrl
 
     if FileTypeVarArray(cname):
-        ctrl = CreateFileItemList(cname,cvalue,cenabled)
+        ctrl = CreateFileItemList(cname, cvalue, cenabled)
         return ctrl
 
     if cvalue.startswith('{'):
-        ctrl = CreateDictionaryControl(cname,cvalue, cenabled)
+        ctrl = CreateDictionaryControl(cname, cvalue, cenabled)
         return ctrl
 
     if cvalue.startswith('['):
-        ctrl = CreateListControl(cname,cvalue,cenabled)
+        ctrl = CreateListControl(cname, cvalue, cenabled)
         return ctrl
 
     if vtype == 'list':
-        ctrl = CreateListControl(cname,cvalue,cenabled)
+        ctrl = CreateListControl(cname, cvalue, cenabled)
         return ctrl
 
     if vtype == 'number':
@@ -528,19 +529,22 @@
 
     jscheck = '"=makeCheckSyntaxRequest(%s);"' % cname
     ctrl = '<span class="%s">' % jscheck
-    ctrl += '<input type=textbox id="%s" name="%s" value="%s" 
onchange=CheckValue("%s","textbox",0) size="50" >' % (cname , cname , 
cvalue,cname)
+    ctrl += '<input type=textbox id="%s" name="%s" value="%s" 
onchange=CheckValue("%s", "textbox", 0) size="50" >' \
+        % (cname, cname, cvalue, cname)
     ctrl += '</span>'
     return ctrl
 
 
-def CreateNumberControl(cname,cvalue):
+def CreateNumberControl(cname, cvalue):
     tbClass = 'VarInputInt'
     ctrl = '<span class="%s">' % tbClass
-    ctrl += '<input type=textbox  id="%s" name="%s" value="%s" 
onchange=CheckValue("%s","textbox",0) size="50" >' % (cname , cname , 
cvalue,cname)
+    ctrl += '<input type=textbox  id="%s" name="%s" value="%s" 
onchange=CheckValue("%s", "textbox", 0) size="50" >' \
+        % (cname, cname, cvalue, cname)
     ctrl += '</span>'
     return ctrl
 
-def DisplayGroups(fconfig,expALL):
+
+def DisplayGroups(fconfig, expALL):
     fv = HTMLResource()
     groups = GetGroupList(fconfig)
 
@@ -555,11 +559,11 @@
         aopts = ''
 
         fv.res += '<li>'
-        fv.res += '<a %s onclick=ShowList("%s")>%s</a>\n'  % (aopts , grp, grp)
-        fv.res += '   <ul id="%s" style= display:%s>\n' % (grp , displayStyle )
+        fv.res += '<a %s onclick=ShowList("%s")>%s</a>\n'  % (aopts, grp, grp)
+        fv.res += '   <ul id="%s" style= display:%s>\n' % (grp, displayStyle)
         for cctrl in fconfig:
             if cctrl['group'] == grp:
-                lctrl = CreateConfigLine(cctrl,expALL,grp)
+                lctrl = CreateConfigLine(cctrl, expALL, grp)
                 fv.res += '        <li>' + lctrl + '</li>'
         fv.res += '    </ul>\n'
         fv.res += '</li>'
@@ -574,9 +578,9 @@
     def _render(self, request):
         fv = HTMLResource()
         form = request.args
-        fv.printHeader(_('Config'), 
'styles/main.css','scripts/config.js',selected=_('Config'))
+        fv.printHeader(_('Config'), 'styles/main.css', 'scripts/config.js', 
selected=_('Config'))
 
-        configfile = fv.formValue(form,'configfile')
+        configfile = fv.formValue(form, 'configfile')
         if configfile:
             if not os.path.exists(configfile):
                 configfile = None
@@ -584,18 +588,18 @@
         if not configfile:
             if (not config.__dict__.has_key('CONFIG_EDIT_FILE')):
                 fv.printMessages(['Unable to find local_conf.py setting 
CONFIG_EDIT_FILE'])
-                return String ( fv.res )
+                return String (fv.res)
             else:
                 configfile = config.CONFIG_EDIT_FILE
 
         if not os.path.exists(configfile):
             fv.printMessages(['Unable to find file - ' + configfile])
-            return String ( fv.res )
+            return String (fv.res)
 
         rconf = ReadConfig(configfile)
         fconfig = ParseConfigFile(rconf)
 
-        expAll = fv.formValue(form,'expAll')
+        expAll = fv.formValue(form, 'expAll')
         expandAll = False
         if expAll:
             expandAll = True
@@ -603,11 +607,10 @@
         fv.res += '<link rel="stylesheet" href="styles/config.css" 
type="text/css" />\n'
         fv.res += '<input type="hidden" id="configfile" value="%s"\n>' % 
configfile
         fv.res += '<div class="VarGroups">\n'
-        fv.res  += '\n<form id="config" class="searchform" action="config.rpy" 
method="get">\n'
-
-        fv.res += DisplayGroups(fconfig,expandAll)
+        fv.res += '\n<form id="config" class="searchform" action="config.rpy" 
method="get">\n'
+        fv.res += DisplayGroups(str(fconfig), expandAll)
         fv.res + '</div>\n'
         fv.res += '\n</form><br>\n'
-        return String( fv.res )
+        return String(fv.res)
 
 resource = ConfigResource()

Modified: branches/rel-1/freevo/src/www/htdocs/pluginconfig.rpy
==============================================================================
--- branches/rel-1/freevo/src/www/htdocs/pluginconfig.rpy       (original)
+++ branches/rel-1/freevo/src/www/htdocs/pluginconfig.rpy       Thu Oct 11 
15:17:34 2007
@@ -29,6 +29,7 @@
 # -----------------------------------------------------------------------
 
 import sys, time
+import urllib
 from www.web_types import HTMLResource, FreevoResource
 import util, config
 from plugin import is_active
@@ -42,14 +43,14 @@
 
 def ReadConfig(cfile):
     lconf = cfile
-    lconf_hld = open(lconf,'r')
+    lconf_hld = open(lconf, 'r')
     fconf = lconf_hld.readlines()
     lconf_hld.close
     return fconf
 
 
 def ParsePluginName(line):
-    sline = line.replace('"',"'")
+    sline = line.replace('"', "'")
     sline = sline.split("'")
     if len(sline) > 2:
         pname = sline[1]
@@ -58,7 +59,7 @@
     return pname
 
 
-def GetConfigSetting(cfile , vname):
+def GetConfigSetting(cfile, vname):
 
     lconf = ReadConfig(cfile)
     ret = ''
@@ -77,7 +78,7 @@
     pluginlines = []
     cnt = 0
     while cnt < len(rconf):
-        pline = 
{'name':'','lineno':0,'orgline':'','enabled':False,'removed':False}
+        pline = {'name':'', 'lineno':0, 'orgline':'', 'enabled':False, 
'removed':False}
         ln = rconf[cnt].strip()
         pline['enabled'] = True
 
@@ -107,17 +108,17 @@
     return config_list
 
 
-def SortPlugins(pluginlist,plugin_grps):
+def SortPlugins(pluginlist, plugin_grps):
     sorted = []
     for plugin in pluginlist:
         pgrp = plugin[0].split('.')[0]
         if not pgrp  in plugin_grps:
             pgrp = 'Global'
-        sorted.append([pgrp , plugin])
+        sorted.append([pgrp, plugin])
     return sorted
 
-def CreateListBox(cname,grps,cvalue,opts):
-    ctrl = '\n<select name="%s" value=""  id="%s" %s>' % ( cname , cname, opts 
)
+def CreateListBox(cname, grps, cvalue, opts):
+    ctrl = '\n<select name="%s" value=""  id="%s" %s>' % (cname, cname, opts)
     for grp in grps:
         if grp == cvalue:
             ctrl  += '\n    <option value="' + grp + '" selected="yes">' + grp 
+ '</option>'
@@ -127,41 +128,41 @@
     return ctrl
 
 
-def get_config_setting(lconf, plugin_name ) :
+def get_config_setting(lconf, plugin_name) :
     conf_line = 'None'
     confentry = False
     linenumber = -1
-    for lnum , lcline in enumerate(lconf):
+    for lnum, lcline in enumerate(lconf):
 
         if  lcline['name'] == plugin_name:
 
             conf_line = lcline['orgline']
             linenumber = lcline['lineno']
             confentry = True
-    return conf_line , linenumber
+    return conf_line, linenumber
 
 def plugin_level_control(lconf_line, plugin) :
     # check to see if the plugin supports levels.
-    lconf_line = lconf_line.replace(' ','')
+    lconf_line = lconf_line.replace(' ', '')
     if lconf_line.find('level=') == -1:
-        plugin_info = plugin[4].replace(' ','')
+        plugin_info = plugin[4].replace(' ', '')
         if plugin_info.find('level=') == -1:
             level = 'none'
         else:
             level = 45
     else:
         level = lconf_line.split('level=')[1]
-        level = level.replace(')','')
+        level = level.replace(')', '')
 
 
     level_ctrl = ''
     if level <> "none":
-        level_ctrl = 'Level :<input  id="%s_level" name="newname" size="2" 
value="%s">' % ( plugin[0], level )
+        level_ctrl = 'Level :<input  id="%s_level" name="newname" size="2" 
value="%s">' % (plugin[0], level)
 
     return level_ctrl
 
 
-def get_plugin_status(plugin_name ,  lconfline  )    :
+def get_plugin_status(plugin_name,  lconfline)    :
     status = 'Deactive'
 
     if is_active(plugin_name):
@@ -185,18 +186,18 @@
     return plugin_args
 
 
-def displayplugin(cfile , plugin,lconf,expAll):
-    ctrlopts = ['Active','Deactive','Remove']
+def displayplugin(cfile, plugin, lconf, expAll):
+    ctrlopts = ['Active', 'Deactive', 'Remove']
     html = HTMLResource()
 
     # check tos ee fi the plugin has a line in localconf
-    lconfline , linenumber = get_config_setting(lconf,plugin[0])
+    lconfline, linenumber = get_config_setting(lconf, plugin[0])
 
     plugin_args = get_plugin_args(lconfline)
 
     level = 'N/A'
     pluginname = plugin[0]
-    status = get_plugin_status(pluginname , lconfline)
+    status = get_plugin_status(pluginname, lconfline)
     pc_opts = 'onchange=UpdatePlugin("%s")' % pluginname
 
     spDisable_open = ''
@@ -209,27 +210,28 @@
     if expAll:
         dstyle = ''
 
-    html.res += '<li>%s<span class="PluginStatus%s">%s</span>%s' % ( 
spDisable_open , status ,status, spDisable_close )
+    html.res += '<li>%s<span class="PluginStatus%s">%s</span>%s' % 
(spDisable_open, status, status, spDisable_close)
     html.res += spDisable_open
-    html.res += CreateListBox(pluginname + '_cmd',ctrlopts,status,pc_opts)
-    html.res +=  '<input type="hidden" id="%s_lineno" value="%i">\n' % ( 
pluginname , linenumber )
-    html.res += '<a  onclick=DisplayList("%s_info")>%s</a></li>\n' % ( 
pluginname,   pluginname )
+    html.res += CreateListBox(pluginname + '_cmd', ctrlopts, status, pc_opts)
+    html.res +=  '<input type="hidden" id="%s_lineno" value="%i">\n' % 
(pluginname, linenumber)
+    html.res += '<a  onclick=DisplayList("%s_info")>%s</a></li>\n' % 
(pluginname,   pluginname)
     html.res += spDisable_close
     html.res += '<span id=%s_updateinfo></span>' % pluginname
 
-    html.res += '<ul id="%s_info" style="display:%s;")>\n' %  (pluginname , 
dstyle)
-    html.res += '<li><span id="%s_config_line" class="config_line">%i - 
%s</span></li>'  %  ( pluginname  ,linenumber, lconfline  )
+    html.res += '<ul id="%s_info" style="display:%s;")>\n' %  (pluginname, 
dstyle)
+    html.res += '<li><span id="%s_config_line" class="config_line">%i - 
%s</span></li>'  %  (pluginname, linenumber, lconfline)
 
     html.res += '<li>' + plugin_level_control(lconfline, plugin) + '</li>'
-    html.res += '<li> Plugin Args :<input  id="%s_args" name="newname" 
size="20" value="%s">%s</li>' % ( pluginname , plugin_args ,plugin_args )
+    html.res += '<li> Plugin Args :<input  id="%s_args" name="newname" 
size="20" value="%s">%s</li>' % \
+        (pluginname, plugin_args, plugin_args)
 
 
-    html.res += dispay_vars(plugin , cfile)
-    html.res += '<li><div class="plugin_info">%s</div></li>' % 
plugin[4].replace('\n','<br>\n')
+    html.res += dispay_vars(plugin, cfile)
+    html.res += '<li><div class="plugin_info">%s</div></li>' % 
plugin[4].replace('\n', '<br>\n')
     html.res += '</ul>'
     return html.res
 
-def dispay_vars(plugin,cfile) :
+def dispay_vars(plugin, cfile) :
 
     clist = GetPlugConfig(plugin)
     dsp_vars = '<ul class="plugin_vars">'
@@ -244,16 +246,16 @@
 
     return dsp_vars
 
-def display_group(dsp_group, splugins, configfile,lcplugins,expandAll):
+def display_group(dsp_group, splugins, configfile, lcplugins, expandAll):
 
     grpheader = ''
     grpheader += '<li><a onclick=DisplayList("%s_list")>%s</a>\n'
-    grouplist = grpheader  % (dsp_group , dsp_group)
+    grouplist = grpheader  % (dsp_group, dsp_group)
     grouplist+= '    <ul id="%s_list" class="GroupHeader" >\n' % dsp_group
     for plugin in splugins:
         if dsp_group == plugin[0]:
             pluginname = plugin[1][0]
-            pluginctrl = displayplugin(configfile, 
plugin[1],lcplugins,expandAll)
+            pluginctrl = displayplugin(configfile, plugin[1], lcplugins, 
expandAll)
             grouplist += pluginctrl
     grouplist += '</ul>\n'
     grouplist += '</li>\n'
@@ -267,34 +269,34 @@
 
         fv = HTMLResource()
         form = request.args
-        fv.printHeader(_('configplugins'), 
'styles/main.css','scripts/pluginconfig.js',selected=_('Config Plugins'))
+        fv.printHeader(_('configplugins'), 'styles/main.css', 
'scripts/pluginconfig.js', selected=_('Config Plugins'))
 
         if not hasattr(config, 'all_plugins'):
             config.all_plugins = parse_plugins()
 
-        configfile = fv.formValue(form,'configfile')
+        configfile = fv.formValue(form, 'configfile')
         if configfile:
             if not os.path.exists(configfile):
                 configfile = None
         if not configfile:
             if (not config.__dict__.has_key('CONFIG_EDIT_FILE')):
                 fv.printMessages(["Unable to find local_conf.py setting 
CONFIG_EDIT_FILE"])
-                return String ( fv.res )
+                return String (fv.res)
             else:
                 configfile = config.CONFIG_EDIT_FILE
 
         if not os.path.exists(configfile):
             fv.res += "Error unable to find File - %s" % configfile
-            return String ( fv.res )
+            return String (fv.res)
 
         all_plugins = config.all_plugins
         group_list = ['Global', 'tv', 'video', 'audio', 'image', 'idlebar']
-        splugins = SortPlugins(all_plugins,group_list)
+        splugins = SortPlugins(all_plugins, group_list)
 
         # Read the settings from localconf for plugins.
         lcplugins = ReadConfigPlugins(configfile)
 
-        expAll = fv.formValue(form,'expAll')
+        expAll = fv.formValue(form, 'expAll')
         expandAll = False
         if expAll:
             expandAll = True
@@ -305,12 +307,12 @@
         fv.res += '<ul class="GroupHeader">\n'
 
         for grp in group_list:
-            fv.res += display_group(grp , splugins, 
configfile,lcplugins,expandAll)
+            fv.res += display_group(grp, splugins, configfile, lcplugins, 
expandAll)
 
         fv.res += '</ul>\n'
         fv.res += '</div>\n'
         fv.res += '</form>\n'
 
-        return String( fv.res )
+        return String(fv.res)
 
 resource = ConfigurePluginsResource()

Modified: branches/rel-1/freevo/src/www/htdocs/viewlogfile.rpy
==============================================================================
--- branches/rel-1/freevo/src/www/htdocs/viewlogfile.rpy        (original)
+++ branches/rel-1/freevo/src/www/htdocs/viewlogfile.rpy        Thu Oct 11 
15:17:34 2007
@@ -30,17 +30,17 @@
 # -----------------------------------------------------------------------
 
 import sys, time
+import os
 
 from www.web_types import HTMLResource, FreevoResource
 import util, config
-import os
 
 TRUE = 1
 FALSE = 0
 
 
-def ReadFile(file,number_lines = 40):
-    lconf_hld = open(file,'r')
+def ReadFile(file, number_lines = 40):
+    lconf_hld = open(file, 'r')
     retlines = lconf_hld.readlines()[number_lines * -1:]
 
     rlines = ''
@@ -51,8 +51,8 @@
     return rlines
 
 
-def CreateListBox(cname,grps,cvalue,opts):
-    ctrl = '\n<select name="%s" value=""  id="%s" %s>' % ( cname , cname, opts 
)
+def CreateListBox(cname, grps, cvalue, opts):
+    ctrl = '\n<select name="%s" value=""  id="%s" %s>' % (cname, cname, opts)
 
     for grp in grps:
         if grp == cvalue:
@@ -64,7 +64,7 @@
 
 
 def GetLogFiles():
-    filelist = os.listdir( config.LOGDIR)
+    filelist = os.listdir(config.FREEVO_LOGDIR)
     for l in filelist:
         if not l.endswith('.log'):
             filelist.remove(l)
@@ -83,27 +83,27 @@
 
         fv = HTMLResource()
         form = request.args
-        dfile = fv.formValue(form,'displayfile')
+        dfile = fv.formValue(form, 'displayfile')
         if not dfile:
             dfile = 'webserver-0.log'
 
-        dfile = config.LOGDIR + "/" + dfile
-        update = fv.formValue(form,'update')
+        dfile = os.path.join(config.FREEVO_LOGDIR, dfile)
+        update = fv.formValue(form, 'update')
 
-        rows = fv.formValue(form,'rows')
+        rows = fv.formValue(form, 'rows')
         if not rows:
             rows = '20'
         rows = int(rows)
 
         if update:
-            fv.res = ReadFile(dfile,rows)
-            return String( fv.res )
+            fv.res = ReadFile(dfile, rows)
+            return String(fv.res)
 
-        delayamount = fv.formValue(form,'delayamount')
+        delayamount = fv.formValue(form, 'delayamount')
         if not delayamount:
             delayamount = 9999
 
-        fv.printHeader(_('viewlog'), 
'styles/main.css','scripts/viewlogfile.js',selected=_('View Logs'))
+        fv.printHeader(_('viewlog'), 'styles/main.css', 
'scripts/viewlogfile.js', selected=_('View Logs'))
 
         fv.res += '\n<link rel="stylesheet" href="styles/viewlogfile.css" 
type="text/css" />\n'
         fv.res  += '\n<br><div class="viewlog">'
@@ -117,19 +117,19 @@
         js_delay = 'onchange = "UpdateDelay()"'
         txt_name = '"delayamount"'
         txt_ctrl = '<input type="textbox" name=%s id=%s value="%s" size="3" %s 
>'
-        fv.res += txt_ctrl  % (txt_name, txt_name , delayamount  ,  js_delay)
+        fv.res += txt_ctrl % (txt_name, txt_name, delayamount, js_delay)
         fv.res += ' Refresh Delay '
 
-        fv.res += txt_ctrl % ( "rows", "rows", rows , js_update )
+        fv.res += txt_ctrl % ("rows", "rows", rows, js_update)
         fv.res += 'Rows'
         fv.res += addPageRefresh()
         fv.res += "</form>"
 
         ta_name = '"loglines"'
-        fv.res +=  '<textarea  id=%s name=%s  wrap="OFF" READONLY 
></textarea>'  %  ( ta_name, ta_name )
+        fv.res +=  '<textarea  id=%s name=%s  wrap="OFF" READONLY 
></textarea>' % (ta_name, ta_name)
         fv.res += '</div>\n'
 
         fv.printFooter()
-        return String( fv.res )
+        return String(fv.res)
 
 resource = ViewLogFileResource()

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to