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}