Changeset 8c4df5d465053fbb8d00ea0a571ec1b3d549b59f

Show
Ignore:
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
  • Config.py

    r7b144d5 r8c4df5d  
    3838        return False 
    3939 
     40def 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 
    4050def get(section, key): 
    4151    return config.get(section, key) 
     
    5060# if two values are equidistant, return the larger 
    5161def 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 
     64def 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 
    5370 
    5471def nearestTivoWidth(width): 
  • httpserver.py

    r8874b5b r8c4df5d  
    55from Cheetah.Template import Template 
    66from plugin import GetPlugin 
     7import Config 
    78 
    89SCRIPTDIR = os.path.dirname(__file__) 
     10debug = Config.getDebug() 
     11hack83 = Config.getHack83() 
     12def 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() 
    921 
    1022class TivoHTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): 
     
    4153            self.infopage() 
    4254            return 
    43          
     55 
    4456        o = urlparse("http://fake.host" + self.path) 
    4557        query = parse_qs(o[4]) 
     
    5769            if query.has_key('Container'): 
    5870                #Dispatch to the container plugin 
     71                foundContainer = False 
    5972                for name, container in self.server.containers.items(): 
    6073                    if query['Container'][0].startswith(name): 
     74                        foundContainer = True 
    6175                        plugin = GetPlugin(container['type']) 
    6276                        if hasattr(plugin,command): 
     
    6680                            self.unsuported(query) 
    6781                        break 
     82                if not foundContainer: 
     83                    self.unsuported(query) 
    6884        else: 
    6985            self.unsuported(query) 
     
    87103 
    88104    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             
    95128        
    96129if __name__ == '__main__':