Esempio n. 1
0
 def add_challenge(self, challenge=''):
     if (not challenge is ''):
         pattern = re.compile("^[0-9]{4}$")
         if (pattern.match(challenge) is None):
             return {'challenge': challenge}
         
         boxeeclient = Boxee(self.ip, self.port)
         try:
             boxeeclient.pairResponse(challenge)
         except BoxeeClientAPIException:
             return{'error': 'You probably entered a faulty challenge code. Retry!'}
         
         raise cherrypy.HTTPRedirect('/boxee/add/finish')
     
     return {'challenge': challenge}
Esempio n. 2
0
 def add(self, ip='', port=''):
     if (not ip is '' and not port is ''):
         pattern = re.compile(ValidIpAddressRegex)
         if (pattern.match(ip) is None):
             #Error
             return{'error': 'error', 'ip': ip, 'port': port}
         
         self.ip = ip
         self.port = int(port)
             
         boxeeclient = Boxee(self.ip, self.port)
         try:
             boxeeclient.pairChallenge()
         except BoxeeClientAPIException:
             return{'error': 'Already paired to this ip?', 'ip': ip, 'port': port}
         
         raise cherrypy.HTTPRedirect('/boxee/add/challenge')
         
     return {'ip': ip, 'port': port}