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}