Changeset feebef9b0f45af2e8f35c1370de37b0993fd7279

Show
Ignore:
Timestamp:
03/01/08 16:43:30 (10 months ago)
Author:
KRKeegan <-NOSPAM-kevin@krkeegan.com>
git-committer:
KRKeegan <-NOSPAM-kevin@krkeegan.com> 1204411410 -0800
git-parent:

[dcebed32c117432a45a34303fc336150965dc32d]

git-author:
KRKeegan <-NOSPAM-kevin@krkeegan.com> 1204411410 -0800
Message:

Clean up admin.py. Add settings to known. Fix auto-subshare help

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/admin/admin.py

    r57ad549 rfeebef9  
    5656        t.server_known = ["port", "guid", "ffmpeg", "beacon", "hack83", "debug", \ 
    5757                          "optres", "audio_br", "video_br", "max_video_br", "width",\ 
    58                           "height", "ffmpeg_prams", "bufsize"
     58                          "height", "ffmpeg_prams", "bufsize", "precache"
    5959        t.shares_data = shares_data 
    6060        t.shares_known = ["type", "path", "auto_subshares"] 
    6161        t.tivos_data = [ (section, dict(config.items(section, raw=True))) for section in config.sections() \ 
    6262                         if section.startswith('_tivo_')] 
    63         t.tivos_known = ["aspect169", "audio_br", "video_br", "width", "height", "ffmpeg_prams"
     63        t.tivos_known = ["aspect169", "audio_br", "video_br", "width", "height", "ffmpeg_prams", "shares"
    6464        handler.wfile.write(t) 
    6565        
    66     def QueryContainer(self, handler, query): 
    67         #Read config file new each time in case there was any outside edits 
    68         config = ConfigParser.ConfigParser() 
    69         config.read(config_file_path) 
    70          
    71         def build_inputs(settings, data, section): 
    72             output = '' 
    73             for key in settings: 
    74                 try: 
    75                     output += "<tr><td>" + key + ": </td><td><input type='text' name='" + section + "." + key + "' value='" + data[key] +"'></td></tr>" 
    76                     del data[key] 
    77                 except: 
    78                     output += "<tr><td>" + key + ": </td><td><input type='text' name='" + section + "." + key + "' value=''></td></tr>" 
    79             #print remaining miscellaneous settings 
    80             if len(data) > 0: 
    81                 output += '<tr><td colspan="2" align="center">User Defined Settings</td></tr>' 
    82                 for item in data: 
    83                     output += "<tr><td>" + item + ": </td><td><input type='text' name='" + section + "." + item + "' value='" + data[item] +"'></td></tr>" 
    84             output += '<tr><td colspan="2" align="center">Add a User Defined Setting to this Share</td></tr>' 
    85             output += "<tr><td><input type='text' name='" + section + ".new__setting' value=''></td><td><input type='text' name='" + section + ".new__value' value=''></td></tr>" 
    86             return output 
    87              
    88         server_data = dict(config.items('Server')) 
    89         server = '' 
    90         #build an array with configuration settings to use 
    91         settings = ["port", "guid", "ffmpeg", "beacon", "hack83", "debug", "optres", "audio_br", "video_br", "max_video_br", "width", "height", "ffmpeg_prams", "bufsize"] 
    92         server += build_inputs(settings, server_data, 'Server') 
    93  
    94         #Keep track of the different sections 
    95         section_map = '' 
    96         section_count = 1 
    97          
    98         shares_data = [ (section, dict(config.items(section))) for section in config.sections() if not(section.startswith('_tivo_') or section.startswith('Server')) and (config.has_option(section,'type') and config.get(section,'type').lower() != 'admin')] 
    99         shares ='' 
    100         for name, data in shares_data: 
    101             shares += '<tr><td colspan="2" align="center">----------------------------------</td></tr>' 
    102             shares += '<tr><td colspan="2" align="center">[<input type="text" id="section_' + str(section_count) + '" name="section-' + str(section_count) + '" value="' + name + '">]</td></tr>' 
    103             #build an array with configuration settings to use 
    104             settings = ["type", "path", "auto_subshares"] 
    105             shares += build_inputs(settings, data, "section-" + str(section_count)) 
    106             shares += '<tr><td colspan="2" align="center">Mark this share for deletion <input type="button" value="Delete" onclick="deleteme(\'section_' + str(section_count) + '\')"></td></tr>' 
    107             section_map += "section-" + str(section_count) + "|" + name + "]" 
    108             section_count += 1 
    109  
    110         tivos_data = [ (section, dict(config.items(section))) for section in config.sections() if section.startswith('_tivo_')] 
    111         tivos ='' 
    112         for name, data in tivos_data: 
    113             tivos += '<tr><td colspan="2" align="center">----------------------------------</td></tr>' 
    114             tivos += '<tr><td colspan="2" align="center">[<input type="text" id="section_' + str(section_count) + '" name="section-' + str(section_count) + '" value="' + name + '">]</td></tr>' 
    115             #build an array with configuration settings to use 
    116             settings = ["aspect169", "audio_br", "video_br", "width", "height", "ffmpeg_prams"] 
    117             tivos += build_inputs(settings, data, "section-" + str(section_count)) 
    118             tivos += '<tr><td colspan="2" align="center">Mark this TiVo for deletion <input type="button" value="Delete" onclick="deleteme(\'section_' + str(section_count) + '\')"></td></tr>' 
    119             section_map += "section-" + str(section_count) + "|" + name + "]" 
    120             section_count += 1 
    121  
    122         subcname = query['Container'][0] 
    123         cname = subcname.split('/')[0] 
    124         handler.send_response(200) 
    125         handler.end_headers() 
    126         t = Template(file=os.path.join(SCRIPTDIR,'templates', 'admin.tmpl')) 
    127         t.container = cname 
    128         t.server = server 
    129         t.shares = shares 
    130         t.tivos = tivos 
    131         t.section_map = section_map 
    132         handler.wfile.write(t) 
    133         config.read(config_file_path + '.dist') 
    134  
    13566    def UpdateSettings(self, handler, query): 
    13667        config = ConfigParser.ConfigParser() 
  • plugins/admin/templates/settings.tmpl

    r40e3ec6 rfeebef9  
    825825      </div> 
    826826 
    827       <div id="help-subshares" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"> 
     827      <div id="help-auto_subshares" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"> 
    828828      <p align="center"><strong>auto_subshares</strong> 
    829829      </p>