Changeset 8c4df5d465053fbb8d00ea0a571ec1b3d549b59f
- Timestamp:
- 05/08/07 23:57:05
(2 years ago)
- Author:
- Jason Michalski <armooo@armooo.net>
- git-committer:
- Jason Michalski <armooo@armooo.net> 1178686625 +0000
- git-parent:
[3856dfdf70dfd7a5ca9a39ac20895131f2fb34b2]
- git-author:
- Jason Michalski <armooo@armooo.net> 1178686625 +0000
- Message:
Merged revisions 193 via svnmerge from
http://svn.armooo.net/pyTivo/trunk
This was commited to the trunk when it should have been with the branck with the rest of the files
........
r193 | KRKeegan | 2007-05-08 22:16:35 -0500 (Tue, 08 May 2007) | 4 lines
##MAJOR Code Change
- Huge hack to allow 8.3 to work, affects all four files
- Added hack83 as a server key in config file default true
- Modified config.py to work with linux
........
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r7b144d5 |
r8c4df5d |
|
| 38 | 38 | return False |
|---|
| 39 | 39 | |
|---|
| | 40 | def getHack83(): |
|---|
| | 41 | try: |
|---|
| | 42 | debug = config.get('Server', 'hack83') |
|---|
| | 43 | if debug.lower() == 'true': |
|---|
| | 44 | return True |
|---|
| | 45 | else: |
|---|
| | 46 | return False |
|---|
| | 47 | except NoOptionError: |
|---|
| | 48 | return True |
|---|
| | 49 | |
|---|
| 40 | 50 | def get(section, key): |
|---|
| 41 | 51 | return config.get(section, key) |
|---|
| … | … | |
| 50 | 60 | # if two values are equidistant, return the larger |
|---|
| 51 | 61 | def nearest(x, list): |
|---|
| 52 | | return reduce(lambda a, b: a if abs(x-a) < abs(x-b) or (abs(x-a) == abs(x-b)and a>b) else b, list) |
|---|
| | 62 | return reduce(lambda a, b: closest(x,a,b), list) |
|---|
| | 63 | |
|---|
| | 64 | def closest(x,a, b): |
|---|
| | 65 | if abs(x-a) < abs(x-b) or (abs(x-a) == abs(x-b)and a>b): |
|---|
| | 66 | return a |
|---|
| | 67 | else: |
|---|
| | 68 | return b |
|---|
| | 69 | |
|---|
| 53 | 70 | |
|---|
| 54 | 71 | def nearestTivoWidth(width): |
|---|
| r8874b5b |
r8c4df5d |
|
| 5 | 5 | from Cheetah.Template import Template |
|---|
| 6 | 6 | from plugin import GetPlugin |
|---|
| | 7 | import Config |
|---|
| 7 | 8 | |
|---|
| 8 | 9 | SCRIPTDIR = os.path.dirname(__file__) |
|---|
| | 10 | debug = Config.getDebug() |
|---|
| | 11 | hack83 = Config.getHack83() |
|---|
| | 12 | def debug_write(data): |
|---|
| | 13 | if debug: |
|---|
| | 14 | debug_out = [] |
|---|
| | 15 | debug_out.append('httpserver.py - ') |
|---|
| | 16 | for x in data: |
|---|
| | 17 | debug_out.append(str(x)) |
|---|
| | 18 | fdebug = open('debug.txt', 'a') |
|---|
| | 19 | fdebug.write(' '.join(debug_out)) |
|---|
| | 20 | fdebug.close() |
|---|
| 9 | 21 | |
|---|
| 10 | 22 | class TivoHTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): |
|---|
| … | … | |
| 41 | 53 | self.infopage() |
|---|
| 42 | 54 | return |
|---|
| 43 | | |
|---|
| | 55 | |
|---|
| 44 | 56 | o = urlparse("http://fake.host" + self.path) |
|---|
| 45 | 57 | query = parse_qs(o[4]) |
|---|
| … | … | |
| 57 | 69 | if query.has_key('Container'): |
|---|
| 58 | 70 | #Dispatch to the container plugin |
|---|
| | 71 | foundContainer = False |
|---|
| 59 | 72 | for name, container in self.server.containers.items(): |
|---|
| 60 | 73 | if query['Container'][0].startswith(name): |
|---|
| | 74 | foundContainer = True |
|---|
| 61 | 75 | plugin = GetPlugin(container['type']) |
|---|
| 62 | 76 | if hasattr(plugin,command): |
|---|
| … | … | |
| 66 | 80 | self.unsuported(query) |
|---|
| 67 | 81 | break |
|---|
| | 82 | if not foundContainer: |
|---|
| | 83 | self.unsuported(query) |
|---|
| 68 | 84 | else: |
|---|
| 69 | 85 | self.unsuported(query) |
|---|
| … | … | |
| 87 | 103 | |
|---|
| 88 | 104 | def unsuported(self, query): |
|---|
| 89 | | self.send_response(404) |
|---|
| 90 | | self.send_header('Content-type', 'text/html') |
|---|
| 91 | | self.end_headers() |
|---|
| 92 | | t = Template(file=os.path.join(SCRIPTDIR,'templates','unsuported.tmpl')) |
|---|
| 93 | | t.query = query |
|---|
| 94 | | self.wfile.write(t) |
|---|
| | 105 | if hack83 and 'Command' in query and 'Filter' in query: |
|---|
| | 106 | debug_write(['Unsupported request, checking to see if it is video.', '\n']) |
|---|
| | 107 | command = query['Command'][0] |
|---|
| | 108 | plugin = plugin = GetPlugin('video') |
|---|
| | 109 | if "".join(query['Filter']).find('video') >= 0 and hasattr(plugin,command): |
|---|
| | 110 | debug_write(['Unsupported request, yup it is video send to video plugin for it to sort out.', '\n']) |
|---|
| | 111 | method = getattr(plugin, command) |
|---|
| | 112 | method(self, query) |
|---|
| | 113 | else: |
|---|
| | 114 | self.send_response(404) |
|---|
| | 115 | self.send_header('Content-type', 'text/html') |
|---|
| | 116 | self.end_headers() |
|---|
| | 117 | t = Template(file=os.path.join(SCRIPTDIR,'templates','unsuported.tmpl')) |
|---|
| | 118 | t.query = query |
|---|
| | 119 | self.wfile.write(t) |
|---|
| | 120 | else: |
|---|
| | 121 | self.send_response(404) |
|---|
| | 122 | self.send_header('Content-type', 'text/html') |
|---|
| | 123 | self.end_headers() |
|---|
| | 124 | t = Template(file=os.path.join(SCRIPTDIR,'templates','unsuported.tmpl')) |
|---|
| | 125 | t.query = query |
|---|
| | 126 | self.wfile.write(t) |
|---|
| | 127 | |
|---|
| 95 | 128 | |
|---|
| 96 | 129 | if __name__ == '__main__': |
|---|