| 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 | | |
|---|