Author: duncan
Date: Tue Sep 25 14:04:41 2007
New Revision: 9903
Log:
Run through reindent
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
branches/rel-1/freevo/src/www/htdocs/youtube.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 Tue Sep 25 14:04:41 2007
@@ -83,14 +83,14 @@
status = "RELOAD PAGE"
if blOK:
- WriteConfigFile(config.CONFIG_EDIT_FILE,fconf)
+ WriteConfigFile(config.CONFIG_EDIT_FILE,fconf)
results = '<font color="%s">%s</font>' % (color , status)
return results
def DeleteLines(startline,endline):
rconf = ReadConfig()
-
+
dellines = "<ul>"
for dline in range(startline, endline+1):
rline = rconf.pop(startline)
@@ -117,13 +117,13 @@
if CheckSyntax(cmd):
exec cmd
return itemlist
-
+
def GetGroupList(cfgvars):
grps = ['Other']
agrps = []
for vrs in cfgvars:
grp = vrs['group']
- agrps.append(grp)
+ agrps.append(grp)
if not grp in grps:
grps.append(grp)
@@ -155,9 +155,9 @@
rows = 5
cvalue = cvalue.replace(elemsep,elemsep + "\n")
ctrl = '<textarea id= "%s_tb" rows = %s cols=55 wrap="SOFT"
name=%s_tb>%s</textarea>' % (cname, str(rows),cname,cvalue)
- return ctrl
+ return ctrl
+
-
def CreateFilterControl(grps,cvalue):
ctrl = '\n<select name="filterlist" value="%s" id="filterlist"
onchange="FilterList(\'filterlist\')">' % cvalue
ctrl += '\n <option value="All">All</option>'
@@ -170,50 +170,50 @@
return ctrl
def ParseConfigFile(rconf):
- cnt = 0
- fconfig = []
- while cnt < len(rconf):
- startline = cnt
- ln = rconf[cnt]
- if ln.find("[") <> -1:
- if ln.find("]") <> -1:
- fln = ln
- else:
- fln = ln
- while ln.find("]") == -1:
- cnt += 1
- ln = rconf[cnt]
- ln = ln.strip("#")
- ln = ln.strip()
- fln += ln
-
- elif ln.find("{") <> -1:
- if ln.find("}") <> -1:
- fln = ln
- else:
- fln = ln
- while ln.find("}") == -1:
- cnt += 1
- ln = rconf[cnt]
- ln = ln.strip("#")
- ln = ln.strip()
- fln += ln
- fln = fln.replace("\n","")
- else:
- fln = ln
- pln = ParseLine(fln)
- if pln['type']:
- pln['startline'] = startline
- pln['endline'] = cnt
- fconfig.append(pln)
- cnt += 1
- fconfig.sort()
- return fconfig
+ cnt = 0
+ fconfig = []
+ while cnt < len(rconf):
+ startline = cnt
+ ln = rconf[cnt]
+ if ln.find("[") <> -1:
+ if ln.find("]") <> -1:
+ fln = ln
+ else:
+ fln = ln
+ while ln.find("]") == -1:
+ cnt += 1
+ ln = rconf[cnt]
+ ln = ln.strip("#")
+ ln = ln.strip()
+ fln += ln
+
+ elif ln.find("{") <> -1:
+ if ln.find("}") <> -1:
+ fln = ln
+ else:
+ fln = ln
+ while ln.find("}") == -1:
+ cnt += 1
+ ln = rconf[cnt]
+ ln = ln.strip("#")
+ ln = ln.strip()
+ fln += ln
+ fln = fln.replace("\n","")
+ else:
+ fln = ln
+ pln = ParseLine(fln)
+ if pln['type']:
+ pln['startline'] = startline
+ pln['endline'] = cnt
+ fconfig.append(pln)
+ cnt += 1
+ fconfig.sort()
+ return fconfig
def CreateControl(nctrl):
htmlctrl = HTMLResource()
htmlctrl.tableRowOpen('class="chanrow"')
-
+
checked = ""
if nctrl['checked']:
checked = "checked"
@@ -230,13 +230,13 @@
htmlctrl.tableCell(chkbox,'')
htmlctrl.tableCell(nctrl['ctrlname'],'align="right"')
-
+
if nctrl['type'] == "textbox":
- inputbox =
CreateTextBox(nctrl['ctrlvalue'],nctrl['ctrlname'],nctrl['vartype'])
- htmlctrl.tableCell(inputbox,'colspan="1" align="left"')
+ inputbox =
CreateTextBox(nctrl['ctrlvalue'],nctrl['ctrlname'],nctrl['vartype'])
+ htmlctrl.tableCell(inputbox,'colspan="1" align="left"')
chkline = nctrl['ctrlname'] + " = " + nctrl['ctrlvalue']
-
+
lcheck = '<font color="#00FF00">OK</font>'
if not CheckSyntax(chkline):
lcheck = '<font color="#FF0000">Error</font>'
@@ -246,7 +246,7 @@
filename = nctrl['ctrlvalue'].replace("'","").strip()
if not os.path.exists(filename):
lcheck = '<font color="#FF0000">Missing File - ' + filename +
'</font>'
-
+
check = '<div id="%s_check">%s</div>' % (nctrl['ctrlname'],lcheck)
opts = 'align="left" id="' + nctrl['ctrlname'] + '_check"'
htmlctrl.tableCell(lcheck,opts)
@@ -258,11 +258,11 @@
def CreateBooleanControl(cname,cvalue):
ctrl = '<select id = "%s_tb" name="%s_tb" value="">' % ( cname , cname )
if cvalue.startswith("True"):
- ctrl += '\n <option value="True" selected="yes">True</option>'
- ctrl += '\n <option value="False">False</option>'
+ ctrl += '\n <option value="True" selected="yes">True</option>'
+ ctrl += '\n <option value="False">False</option>'
else:
- ctrl += '\n <option value="True" >True</option>'
- ctrl += '\n <option value="False" selected="yes">False</option>'
+ ctrl += '\n <option value="True" >True</option>'
+ ctrl += '\n <option value="False" selected="yes">False</option>'
ctrl += '</select>'
return ctrl
@@ -273,9 +273,9 @@
cid = cname + "_tb"
ctrl = "ERROR!!!"
if vtype == "boolean":
- ctrl = CreateBooleanControl(cname,cvalue)
+ ctrl = CreateBooleanControl(cname,cvalue)
elif vtype == "list":
- ctrl = ParseList(cname,cvalue)
+ ctrl = ParseList(cname,cvalue)
else:
tbsize = "45"
if vtype == "number":
@@ -285,29 +285,29 @@
def isNumber(s):
try:
- i = int(s)
- return True
+ i = int(s)
+ return True
except ValueError:
- return False
+ return False
+
-
def FileTypeVarArray(cname):
filevars = ['VIDEO_ITEMS','AUDIO_ITEMS','IMAGE_ITEMS','GAME_ITEMS']
-
+
if cname in filevars:
- return True
+ return True
return False
-
+
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']
-
+
if vtype in filetypes:
- return True
+ return True
if cname in filevars:
- return True
- return False
+ return True
+ return False
def VarType(cvalue):
if cvalue.startswith("'") and cvalue.endswith("'"):
@@ -320,11 +320,11 @@
return "list"
if cvalue.startswith("{") and cvalue.endswith("}"):
return "list"
- if cvalue.startswith("True") or cvalue.startswith("False"):
+ if cvalue.startswith("True") or cvalue.startswith("False"):
return 'boolean'
return "Unknow"
-
-
+
+
def ParseLine(cline):
lparsed = {'ctrlname': '',
'ctrlvalue': '' ,
@@ -337,14 +337,14 @@
'endline':'',
'fileline':cline,
'vartype':''}
-
+
tln = cline.strip()
tln = tln.replace("\n","")
if tln.startswith("#"):
lparsed['checked'] = False
tln = tln.lstrip("#")
tln = tln.lstrip()
-
+
if len(tln) > 1:
fsplit = tln.split("=")
if len(fsplit) == 2:
@@ -354,16 +354,16 @@
if lparsed['ctrlname'].endswith("_VOLUME"):
lparsed['group'] = "Volume"
if not lparsed['ctrlname'].isupper():
- lparsed['type'] = ''
+ lparsed['type'] = ''
if (not config.__dict__.has_key(lparsed['ctrlname'])):
- try:
- fvvalue = eval('config.' + lparsed['ctrlname'])
- except Exception, e:
- fvvalue = ""
-
+ try:
+ fvvalue = eval('config.' + lparsed['ctrlname'])
+ except Exception, e:
+ fvvalue = ""
+
ctrlvalue = fsplit[1].split("#")
if len(ctrlvalue) == 2:
- lparsed['comments'] = ctrlvalue[1]
+ lparsed['comments'] = ctrlvalue[1]
lparsed['ctrlvalue'] = ctrlvalue[0].strip()
lparsed['vartype'] = VarType(lparsed['ctrlvalue'])
@@ -372,76 +372,75 @@
return lparsed
def DisplaySettings(fconfig,filterlist):
- fv = HTMLResource()
+ fv = HTMLResource()
- groups = GetGroupList(fconfig)
- fv.tableOpen('class="library" id="filelist"')
- fv.tableRowOpen('class="chanrow"')
- fv.tableCell(CreateFilterControl(groups,filterlist),'class ="guidehead"
colspan="2"')
- fv.tableCell('Enable','class ="guidehead" colspan="1"')
- fv.tableCell('Name','class ="guidehead" colspan="1"')
- fv.tableCell('Value','class ="guidehead" colspan="1"')
- fv.tableCell('Comments','class ="guidehead" colspan="1"')
- fv.tableRowClose()
-
- for cctrl in fconfig:
- if cctrl['type'] == "textbox":
- if filterlist and filterlist <> "All":
- if cctrl['group'] == filterlist:
- fv.res += CreateControl(cctrl)
- else:
- fv.res += CreateControl(cctrl)
+ groups = GetGroupList(fconfig)
+ fv.tableOpen('class="library" id="filelist"')
+ fv.tableRowOpen('class="chanrow"')
+ fv.tableCell(CreateFilterControl(groups,filterlist),'class ="guidehead"
colspan="2"')
+ fv.tableCell('Enable','class ="guidehead" colspan="1"')
+ fv.tableCell('Name','class ="guidehead" colspan="1"')
+ fv.tableCell('Value','class ="guidehead" colspan="1"')
+ fv.tableCell('Comments','class ="guidehead" colspan="1"')
+ fv.tableRowClose()
+
+ for cctrl in fconfig:
+ if cctrl['type'] == "textbox":
+ if filterlist and filterlist <> "All":
+ if cctrl['group'] == filterlist:
+ fv.res += CreateControl(cctrl)
+ else:
+ fv.res += CreateControl(cctrl)
- fv.tableClose()
- return fv.res
+ fv.tableClose()
+ return fv.res
class ConfigResource(FreevoResource):
-
+
def _render(self, request):
- fv = HTMLResource()
- form = request.args
- fv.printHeader(_('Config'),
'styles/main.css','scripts/config.js',selected=_('Config'))
-
- 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 )
-
- if not os.path.exists(config.CONFIG_EDIT_FILE):
- fv.printMessages(["Unable to find file - " +
config.CONFIG_EDIT_FILE])
- return String ( fv.res )
-
- update = fv.formValue(form,"update")
- if update:
- udname = fv.formValue(form,"udname")
- udenable = fv.formValue(form,"udenable")
- udvalue = fv.formValue(form,"udvalue")
- startline = fv.formValue(form,"startline")
- endline = fv.formValue(form,"endline")
- fv.res =
UpdateConfig(udname,udvalue,udenable,int(startline),int(endline))
- return String( fv.res )
-
- delete = fv.formValue(form,"delete")
- startline = fv.formValue(form,"startline")
- endline = fv.formValue(form,"endline")
- if delete == "TRUE" and startline and endline:
- dlines = DeleteLines(int(startline),int(endline))
- fv.res += "<br><h4>The following Lines were deleted :</h4>" +
dlines
-
- rconf = ReadConfig()
- fconfig = ParseConfigFile(rconf)
-
- filterlist = fv.formValue(form,"filterlist")
- fv.res += '\n<br><form id="Url Download" action="config.rpy"
method="get">'
- fv.res += '\n <div class="searchform" align="left"><br>'
- fv.res += '<div align="left">'
+ fv = HTMLResource()
+ form = request.args
+ fv.printHeader(_('Config'),
'styles/main.css','scripts/config.js',selected=_('Config'))
+
+ 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 )
+
+ if not os.path.exists(config.CONFIG_EDIT_FILE):
+ fv.printMessages(["Unable to find file - " +
config.CONFIG_EDIT_FILE])
+ return String ( fv.res )
+
+ update = fv.formValue(form,"update")
+ if update:
+ udname = fv.formValue(form,"udname")
+ udenable = fv.formValue(form,"udenable")
+ udvalue = fv.formValue(form,"udvalue")
+ startline = fv.formValue(form,"startline")
+ endline = fv.formValue(form,"endline")
+ fv.res =
UpdateConfig(udname,udvalue,udenable,int(startline),int(endline))
+ return String( fv.res )
+
+ delete = fv.formValue(form,"delete")
+ startline = fv.formValue(form,"startline")
+ endline = fv.formValue(form,"endline")
+ if delete == "TRUE" and startline and endline:
+ dlines = DeleteLines(int(startline),int(endline))
+ fv.res += "<br><h4>The following Lines were deleted :</h4>" +
dlines
+
+ rconf = ReadConfig()
+ fconfig = ParseConfigFile(rconf)
+
+ filterlist = fv.formValue(form,"filterlist")
+ fv.res += '\n<br><form id="Url Download" action="config.rpy"
method="get">'
+ fv.res += '\n <div class="searchform" align="left"><br>'
+ fv.res += '<div align="left">'
# fv.res += NewLineControl()
- fv.res += '</div>'
+ fv.res += '</div>'
- fv.res += DisplaySettings(fconfig,filterlist)
- fv.res += '\n </div>'
- fv.res += '\n</form><br>\n'
-
- return String( fv.res )
+ fv.res += DisplaySettings(fconfig,filterlist)
+ fv.res += '\n </div>'
+ fv.res += '\n</form><br>\n'
-resource = ConfigResource()
+ 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 Tue Sep 25
14:04:41 2007
@@ -65,30 +65,30 @@
pline = len(lconf) - 1
if pline <> -1:
- lcline = lconf[pline]
- if pcmd == "Disabled":
- nline = "# plugin.activate('%s') \n" % pname
- status = "DISABLE Plugin " + pname + "\n" + nline
- lconf[pline] = nline
- WriteConfigFile(config.CONFIG_EDIT_FILE,lconf)
-
- elif pcmd == "REMOVE":
- nline = "plugin.remove('%s')\n" % pname
- status = "REMOVE Plugin " + pname + "\n" + nline
- lconf[pline] = nline
- WriteConfigFile(config.CONFIG_EDIT_FILE,lconf)
-
- elif pcmd == "Enabled":
- nline = "plugin.activate('%s')\n" % pname
- status = "ACTIVATE Plugin " + pname + "\n" + nline
- lconf[pline] = nline
- WriteConfigFile(config.CONFIG_EDIT_FILE,lconf)
+ lcline = lconf[pline]
+ if pcmd == "Disabled":
+ nline = "# plugin.activate('%s') \n" % pname
+ status = "DISABLE Plugin " + pname + "\n" + nline
+ lconf[pline] = nline
+ WriteConfigFile(config.CONFIG_EDIT_FILE,lconf)
+
+ elif pcmd == "REMOVE":
+ nline = "plugin.remove('%s')\n" % pname
+ status = "REMOVE Plugin " + pname + "\n" + nline
+ lconf[pline] = nline
+ WriteConfigFile(config.CONFIG_EDIT_FILE,lconf)
+
+ elif pcmd == "Enabled":
+ nline = "plugin.activate('%s')\n" % pname
+ status = "ACTIVATE Plugin " + pname + "\n" + nline
+ lconf[pline] = nline
+ WriteConfigFile(config.CONFIG_EDIT_FILE,lconf)
- elif pcmd == "DELETE":
- status = "ACTIVATE Plugin " + pname
+ elif pcmd == "DELETE":
+ status = "ACTIVATE Plugin " + pname
return status
-
+
def ParsePluginName(line):
sline = line.split("'")
if len(sline) > 2:
@@ -105,13 +105,13 @@
ln = ln.strip("#")
ln = ln.strip()
if ln.startswith(vname):
- print "LINE FOUND"
- sln = ln.split("=")
- print sln
- if len(sln) > 1:
- ret = sln[1].split("#")[0]
+ print "LINE FOUND"
+ sln = ln.split("=")
+ print sln
+ if len(sln) > 1:
+ ret = sln[1].split("#")[0]
return ret
-
+
def ReadConfigPlugins():
rconf = ReadConfig()
pluginlines = []
@@ -125,27 +125,27 @@
pline['enabled'] = False
ln = ln.strip('#')
ln = ln.strip()
-
+
if ln.startswith('plugin'):
pline['name'] = ParsePluginName(ln)
pline['lineno'] = cnt
pline['orgline'] = rconf[cnt]
pluginlines.append(pline)
-
+
cnt += 1
-
+
return pluginlines
def GetPlugConfig(pname,all_plugins):
config_list = []
for p in all_plugins:
if p[0] == pname:
- if p[5].find('config') > 0:
- exec (p[5])
- config_list = return_config()
+ if p[5].find('config') > 0:
+ exec (p[5])
+ config_list = return_config()
return config_list
-
+
def CreateListBox(cname,grps,cvalue,opts):
ctrl = '\n<select name="%s" value="" id="%s" %s>' % ( cname , cname, opts
)
for grp in grps:
@@ -158,11 +158,11 @@
def displayplugin(plugin,group,pfilter,lconf,plugins_all):
html = HTMLResource()
-
+
pluginname = plugin[0]
for e in plugin:
if e.find("level") <> -1:
- level = "30"
+ level = "30"
status = "Deactive"
btnlabel = "Disabled"
@@ -171,7 +171,7 @@
status = "Active"
btnlabel = "Enabled"
jscmd = "DisablePlugin"
-
+
# check tos ee fi the plugin has a line in localconf
lconfline = "No local_conf.py entry"
confentry = False
@@ -182,17 +182,17 @@
linenumber = lcline['lineno']
confentry = True
level = "N/A"
-
+
if is_active(plugin[0]) and not confentry:
- status = "Active"
- btnlabel = "Enabled"
- jscmd = "RemovePlugin"
+ status = "Active"
+ btnlabel = "Enabled"
+ jscmd = "RemovePlugin"
if lconfline.startswith("plugin.remove"):
- status = "Removed"
- btnlabel = "Removed"
- jscmd = "EnablePlugin"
-
+ status = "Removed"
+ btnlabel = "Removed"
+ jscmd = "EnablePlugin"
+
cmds = ["Enabled","Disabled","Removed"]
jsupdate = 'onchange="UpdatePlugin(\'%s\')"' % pluginname
btns = CreateListBox(pluginname + "_cmd",cmds,btnlabel,jsupdate)
@@ -220,7 +220,7 @@
html.tableRowClose()
return html.res
-
+
class ConfigurePluginsResource(FreevoResource):
def _render(self, request):
@@ -247,22 +247,22 @@
fv.res += '\n<div class="searchform" align="left"><br>'
fv.res += '\n<br><form id="Url Download" action="pluginconfig.rpy"
method="get">'
fv.res += '<br>'
-
+
filterlist = special_plugins
filterlist.insert(0,"Global")
filterlist.insert(0,"(All)")
-
+
# Read the settings from localconf for plugins.
lcplugins = ReadConfigPlugins()
pluginfilter = fv.formValue(form, 'pluginfilter')
if not pluginfilter:
pluginfilter = "(All)"
-
+
filter = fv.formValue(form, 'filterlist')
if not filter:
filter = "(All)"
-
+
fv.tableOpen()
fv.tableRowOpen('class="chanrow"')
jsfilter = 'onchange="FilterListPlugin()"'
@@ -290,13 +290,13 @@
if p[0][:p[0].find('.')] == type:
fv.res +=
displayplugin(p,grp,pluginfilter,lcplugins,all_plugins)
grp = ""
-
+
else:
grp = filter
- for p in all_plugins:
- if p[0][:p[0].find('.')] == filter:
- fv.res +=
displayplugin(p,grp,pluginfilter,lcplugins,all_plugins)
- grp = ""
+ for p in all_plugins:
+ if p[0][:p[0].find('.')] == filter:
+ fv.res +=
displayplugin(p,grp,pluginfilter,lcplugins,all_plugins)
+ grp = ""
fv.tableClose()
fv.res += '</form>'
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 Tue Sep 25
14:04:41 2007
@@ -32,7 +32,7 @@
from www.web_types import HTMLResource, FreevoResource
import util, config
-import os
+import os
from plugin import is_active
from helpers.plugins import parse_plugins
from helpers.plugins import info_html
@@ -44,12 +44,12 @@
# print "READING FILE = %s Number lines = %i" % ( file , numberlines )
lconf_hld = open(file,"r")
retlines = lconf_hld.readlines()[numberlines * -1:]
-
+
rlines = ""
retlines.reverse()
for ln in retlines:
- rlines += ln
-
+ rlines += ln
+
return rlines
def CreateListBox(cname,grps,cvalue,opts):
@@ -67,17 +67,17 @@
filelist = os.listdir( config.LOGDIR)
for l in filelist:
if not l.endswith(".log"):
- filelist.remove(l)
+ filelist.remove(l)
return filelist
-
+
def addPageRefresh():
style = 'style="z-index:100; position:absolute; top:150px; a"'
style = ""
prhtml = '<script
type="text/JavaScript">window.onload=beginrefresh</script>'
prhtml += '\n<div class="searchform" id="refresh" %s
align="Center">Refresh In : ??</div>' % style
return prhtml
-
-
+
+
class ViewLogFileResource(FreevoResource):
def _render(self, request):
@@ -88,7 +88,7 @@
# print "LOG FILE = %s " % dfile
if not dfile:
dfile = 'webserver-0.log'
-
+
dfile = config.LOGDIR + "/" + dfile
update = fv.formValue(form,"update")
rows = fv.formValue(form,"rows")
@@ -96,31 +96,31 @@
if not rows:
rows = '20'
rows = int(rows)
-
+
if update:
fv.res = ReadFile(dfile,rows)
- return String( fv.res )
-
+ return String( fv.res )
+
autorefresh = fv.formValue(form,"autorefresh")
if not autorefresh:
autorefresh = ""
autorefresh = "checked"
-
+
numlines = fv.formValue(form,"numlines")
if not numlines:
numlines = 20
-
+
delayamount = fv.formValue(form,"delayamount")
if not delayamount:
delayamount = 9999
-
+
fv.printHeader(_('viewlog'),
'styles/main.css','scripts/viewlogfile.js',selected=_('View Logs'))
fv.res += '\n<div class="searchform" align="left"><br>'
fv.res += '\n<div align="left">'
fv.res += '\n<form id="form1" name="form1" action="viewlogfile.rpy"
method="get">'
fv.res += '<br>'
-
+
logfiles = GetLogFiles()
opts = 'onchange="UpdateDisplay()"'
fv.res += "Log File : " +
CreateListBox("logfile",logfiles,dfile,opts)
@@ -130,16 +130,16 @@
# fv.res += '<input type=checkbox name="autorefresh" id="autorefresh"
%s> Auto Refresh' % autorefresh
fv.res += addPageRefresh()
fv.res += "</form>"
-
+
style = 'style="z-index:100; left:1%; width: 95%; height: 50%;
position:absolute; top:220px; bottom:2%; padding: 2px;"'
fv.res += '<br><textarea id="loglines" name="loglines" rows = %i
cols=120 wrap="OFF" READONLY %s ></textarea>' % ( rows , style )
-
+
# fv.res += '</form>'
fv.res += '</div>\n'
fv.res += '</div>\n'
fv.res += '<br><br>'
fv.printFooter()
-
+
return String( fv.res )
resource = ViewLogFileResource()
Modified: branches/rel-1/freevo/src/www/htdocs/youtube.rpy
==============================================================================
--- branches/rel-1/freevo/src/www/htdocs/youtube.rpy (original)
+++ branches/rel-1/freevo/src/www/htdocs/youtube.rpy Tue Sep 25 14:04:41 2007
@@ -35,7 +35,7 @@
from stat import *
def xmlStatus(fstatus):
- xmlstatus = ""
+ xmlstatus = ""
xmlstatus += "<PERCENT>" + fstatus['percent'] + "</PERCENT>"
xmlstatus += "<DOWNLOADED>" + fstatus['downloaded'] + "</DOWNLOADED>"
xmlstatus += "<FILESIZE>" + fstatus['filesize'] + "</FILESIZE>"
@@ -45,23 +45,23 @@
# Get optimum 1k exponent to represent a number of bytes
def optimum_k_exp(num_bytes):
- const_1k = 1024
- if num_bytes == 0:
- return 0
- return long(math.log(num_bytes, const_1k))
+ const_1k = 1024
+ if num_bytes == 0:
+ return 0
+ return long(math.log(num_bytes, const_1k))
# Get optimum representation of number of bytes
def format_bytes(num_bytes):
- const_1k = 1024
- try:
- exp = optimum_k_exp(num_bytes)
- suffix = 'bkMGTPEZY'[exp]
- if exp == 0:
- return '%s%s' % (num_bytes, suffix)
- converted = float(num_bytes) / float(const_1k**exp)
- return '%.2f%s' % (converted, suffix)
- except IndexError:
- return "Error"
+ const_1k = 1024
+ try:
+ exp = optimum_k_exp(num_bytes)
+ suffix = 'bkMGTPEZY'[exp]
+ if exp == 0:
+ return '%s%s' % (num_bytes, suffix)
+ converted = float(num_bytes) / float(const_1k**exp)
+ return '%.2f%s' % (converted, suffix)
+ except IndexError:
+ return "Error"
def getStatus(ytfile):
fileStatus = {'percent': '-', 'downloaded': 'done' , 'filesize': 'done'
,'speed' : '--', 'eta' : '--:--'}
@@ -83,7 +83,7 @@
fileStatus['percent'] = "NA"
fileStatus['downloaded'] = "NA"
fileStatus['speed'] = "NA"
- fileStatus['eta'] = "Unknown"
+ fileStatus['eta'] = "Unknown"
except Exception, e:
fileStatus['percent'] = "NA"
fileStatus['downloaded'] = "NA"
@@ -92,7 +92,7 @@
return fileStatus
-def getXML():
+def getXML():
filesXML = '<?xml version="1.0" encoding="ISO-8859-1" ?>'
filesXML += '<FILELIST>'
@@ -111,7 +111,7 @@
filesXML += "</FILELIST>"
return filesXML
-def displaytableheader():
+def displaytableheader():
fvhtml = HTMLResource()
fvhtml.tableOpen('class="library" id="filelist"')
@@ -144,14 +144,14 @@
def download_youtube(yt_url):
logfile = config.YOUTUBE_DIR + ".tmp/" + yt_url.split("=")[-1] + ".log"
startdownload((config.YOUTUBE_DL,"-t",yt_url),logfile)
-
+
def download_url(dl_url):
# get the file name from the url.
logfile = config.YOUTUBE_DIR + ".tmp/partfile" + dl_url.split("/")[-1]
logfile = os.path.splitext(logfile)[0] + ".log"
startdownload((config.DOWNLOAD_DL,dl_url),logfile)
-
+
def addPageRefresh():
prhtml = '<script type="text/JavaScript"
src="scripts/youtube.js">window.onload=beginrefresh</script>'
prhtml += '\n<div class="searchform" id="refresh">Refresh In : ??</div>'
@@ -162,8 +162,8 @@
if (not config.__dict__.has_key('YOUTUBE_DIR')):
yterrors.append('Unable to Find YOUTUDE_DIR setting in local_conf.py')
yterrors.append('Add YOUTUBE_DIR = "Directory to Save Downloads." to
your local_conf.py')
- config.YOUTUBE_DIR = "MISSING"
-
+ config.YOUTUBE_DIR = "MISSING"
+
if (not config.__dict__.has_key('YOUTUBE_DL')):
yterrors.append('Unable to Find YOUTUDE_DL setting in local_conf.py')
yterrors.append('Add YOUTUBE_DL = "Path to youtube-dl script" to your
local_conf.py')
@@ -195,79 +195,78 @@
class YouTubeResource(FreevoResource):
def _render(self, request):
- fv = HTMLResource()
- form = request.args
+ fv = HTMLResource()
+ form = request.args
- blxml = fv.formValue(form,"xml")
- if blxml :
+ blxml = fv.formValue(form,"xml")
+ if blxml :
fv.res = getXML()
#fv.res += fdisplay[0]
- return String( fv.res )
+ return String( fv.res )
- fv.printHeader(_('YouTube'), 'styles/main.css',selected=_('YouTube'))
- yterrors = envCheck()
-
- playfile = fv.formValue(form,"playfile")
- if playfile:
- fv.res += doFlowPlayer(playfile)
-
- if config.YOUTUBE_DIR == "MISSING" or ((config.YOUTUBE_DL ==
"MISSING") and (config.DOWNLOAD_DL == "MISSING")):
- fv.printMessages(yterrors)
- return String( fv.res )
-
- if not os.path.exists(config.YOUTUBE_DIR):
- fv.res += '<br><b>Unable to locate youtube download location "' +
config.YOUTUBE_DIR + '" </b><br>'
- fv.res += 'Add YOUTUBE_DIR = "download directory" to your
local_conf.py'
-
- if not os.path.exists(config.YOUTUBE_DL):
- fv.res += '<br><br><br><b>Unable to locate youtube-dl script "' +
config.YOUTUBE_DL + '" </b><br>'
- fv.res += 'Download scripts from <a
href="http://www.arrakis.es/~rggi3/youtube-dl/">http://www.arrakis.es/~rggi3/youtube-dl/</a>'
- fv.res += '<br>Add YOUTUBE_DL = "path and file name to youtube_dl
script"<br>'
-
- if not os.path.exists(config.DOWNLOAD_DL):
- fv.res += '<br><b>Unable to locate downloadurl.py script "' +
config.YOUTUBE_DL + '" </b><br>'
- fv.res += 'Download scripts from <a
href="http://www.arrakis.es/~rggi3/youtube-dl/">http://www.arrakis.es/~rggi3/youtube-dl/</a>'
- fv.res += '<br>Add YOUTUBE_DL = "path and file name to youtube_dl
script"<br><br>'
-
- if os.path.exists(config.YOUTUBE_DIR):
- if not os.path.exists(config.YOUTUBE_DIR + ".tmp"):
- os.mkdir(config.YOUTUBE_DIR + ".tmp")
-
- fldelete = fv.formValue(form,'Delete')
- if fldelete:
- filename = fv.formValue(form,'file')
+ fv.printHeader(_('YouTube'), 'styles/main.css',selected=_('YouTube'))
+ yterrors = envCheck()
+
+ playfile = fv.formValue(form,"playfile")
+ if playfile:
+ fv.res += doFlowPlayer(playfile)
+
+ if config.YOUTUBE_DIR == "MISSING" or ((config.YOUTUBE_DL ==
"MISSING") and (config.DOWNLOAD_DL == "MISSING")):
+ fv.printMessages(yterrors)
+ return String( fv.res )
+
+ if not os.path.exists(config.YOUTUBE_DIR):
+ fv.res += '<br><b>Unable to locate youtube download location "' +
config.YOUTUBE_DIR + '" </b><br>'
+ fv.res += 'Add YOUTUBE_DIR = "download directory" to your
local_conf.py'
+
+ if not os.path.exists(config.YOUTUBE_DL):
+ fv.res += '<br><br><br><b>Unable to locate youtube-dl script "' +
config.YOUTUBE_DL + '" </b><br>'
+ fv.res += 'Download scripts from <a
href="http://www.arrakis.es/~rggi3/youtube-dl/">http://www.arrakis.es/~rggi3/youtube-dl/</a>'
+ fv.res += '<br>Add YOUTUBE_DL = "path and file name to youtube_dl
script"<br>'
+
+ if not os.path.exists(config.DOWNLOAD_DL):
+ fv.res += '<br><b>Unable to locate downloadurl.py script "' +
config.YOUTUBE_DL + '" </b><br>'
+ fv.res += 'Download scripts from <a
href="http://www.arrakis.es/~rggi3/youtube-dl/">http://www.arrakis.es/~rggi3/youtube-dl/</a>'
+ fv.res += '<br>Add YOUTUBE_DL = "path and file name to youtube_dl
script"<br><br>'
+
+ if os.path.exists(config.YOUTUBE_DIR):
+ if not os.path.exists(config.YOUTUBE_DIR + ".tmp"):
+ os.mkdir(config.YOUTUBE_DIR + ".tmp")
+
+ fldelete = fv.formValue(form,'Delete')
+ if fldelete:
+ filename = fv.formValue(form,'file')
if filename:
filename = config.YOUTUBE_DIR + filename
if os.path.exists(filename):
- os.remove(filename)
- fv.res += "DELETED FILE - " + filename
+ os.remove(filename)
+ fv.res += "DELETED FILE - " + filename
- dlurl = ""
- fv.res += '\n<br><form id="Url Download" action="youtube.rpy"
method="get">'
- fv.res += '\n <div class="searchform"><br><b>Download URL :</b>'
- fv.res += '\n <input type="text" name="dl_url" size="40"
value="' + dlurl + '" />'
- fv.res += '\n <select name="dlscript" value="downloadurl">'
- fv.res += '\n <option value="youtube">Youtube</option>'
- fv.res += '\n <option value="downloadurl">Donwload
Url</option>'
- fv.res += '\ </select>'
- fv.res += '\n <input type="submit" value=" Download! " />'
- fv.res += '\n </div>'
- fv.res += '\n</form><br>\n'
-
- dltype = fv.formValue(form,'dlscript')
- dlurl = fv.formValue(form,'dl_url')
- if dltype and dlurl:
- if dltype == "youtube":
- download_youtube(dlurl)
- if dltype == "downloadurl":
- download_url(dlurl)
+ dlurl = ""
+ fv.res += '\n<br><form id="Url Download" action="youtube.rpy"
method="get">'
+ fv.res += '\n <div class="searchform"><br><b>Download URL :</b>'
+ fv.res += '\n <input type="text" name="dl_url" size="40"
value="' + dlurl + '" />'
+ fv.res += '\n <select name="dlscript" value="downloadurl">'
+ fv.res += '\n <option value="youtube">Youtube</option>'
+ fv.res += '\n <option value="downloadurl">Donwload
Url</option>'
+ fv.res += '\ </select>'
+ fv.res += '\n <input type="submit" value=" Download! " />'
+ fv.res += '\n </div>'
+ fv.res += '\n</form><br>\n'
+
+ dltype = fv.formValue(form,'dlscript')
+ dlurl = fv.formValue(form,'dl_url')
+ if dltype and dlurl:
+ if dltype == "youtube":
+ download_youtube(dlurl)
+ if dltype == "downloadurl":
+ download_url(dlurl)
- fv.res += displaytableheader()
- fv.res += addPageRefresh()
+ fv.res += displaytableheader()
+ fv.res += addPageRefresh()
# fv.res += '<object width="425" height="350"><param name="movie"
value="http://www.youtube.com/v/grCTXGW3sxQ"></param><param name="wmode"
value="transparent"></param><embed src="http://www.youtube.com/v/grCTXGW3sxQ"
type="application/x-shockwave-flash" wmode="transparent" width="425"
height="350"></embed></object>'
- return String( fv.res )
+ return String( fv.res )
resource = YouTubeResource()
-
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog