Changeset 8e8d602c906884018d6e745f70dbabb243b50060

Show
Ignore:
Timestamp:
05/09/07 00:03:37 (2 years ago)
Author:
Jason Michalski <armooo@armooo.net>
git-committer:
Jason Michalski <armooo@armooo.net> 1178687017 +0000
git-parent:

[43630c5b9c2b2772e5096c34dbce33ae9a33e1ba]

git-author:
Jason Michalski <armooo@armooo.net> 1178687017 +0000
Message:

-pyTivo

  • Undoing change set 193 on the trunk
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Config.py

    r43630c5 r8e8d602  
    3838        return False 
    3939 
    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  
    5040def get(section, key): 
    5141    return config.get(section, key) 
     
    6050# if two values are equidistant, return the larger 
    6151def nearest(x, 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  
     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) 
    7053 
    7154def nearestTivoWidth(width): 
  • httpserver.py

    r43630c5 r8e8d602  
    55from Cheetah.Template import Template 
    66from plugin import GetPlugin 
    7 import Config 
    87 
    98SCRIPTDIR = 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() 
    219 
    2210class TivoHTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): 
     
    5341            self.infopage() 
    5442            return 
    55  
     43         
    5644        o = urlparse("http://fake.host" + self.path) 
    5745        query = parse_qs(o[4]) 
     
    6957            if query.has_key('Container'): 
    7058                #Dispatch to the container plugin 
    71                 foundContainer = False 
    7259                for name, container in self.server.containers.items(): 
    7360                    if query['Container'][0].startswith(name): 
    74                         foundContainer = True 
    7561                        plugin = GetPlugin(container['type']) 
    7662                        if hasattr(plugin,command): 
     
    8066                            self.unsuported(query) 
    8167                        break 
    82                 if not foundContainer: 
    83                     self.unsuported(query) 
    8468        else: 
    8569            self.unsuported(query) 
     
    10387 
    10488    def unsuported(self, query): 
    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              
     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) 
    12895        
    12996if __name__ == '__main__':