def add(self, match_rule=None, response_status=200, response_body=b'', response_headers={}, times=1, after=0): """ Add a new preset to the boss server. """ try: new_preset = Preset( headers=response_headers, body=binary_to_ascii(response_body), status=response_status, rule=match_rule, times=times, after=after ) print (self.path) print (new_preset.as_json()) response, data = self.http('POST', url=self.path, body=new_preset.as_json()) print (response.status) print (response.read()) print (data) if response.status != 200: raise ConfigurationError(data.decode()) except: traceback.print_exc(file=sys.stdout) return response