Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def stop_responding(self, server_name, challenge, response):
from twisted.internet import reactor
full_name = challenge.validation_domain_name(server_name)
subdomain = _split_zone(full_name, self._zone_name)
url = (
'https://dns.api.gandi.net/api/v5/domains/'
'{zone}/records/{subdomain}/{type}'
).format(
zone=self._zone_name, subdomain=subdomain, type='TXT',
)
if subdomain == '':
subdomain = '@'
response = yield treq.delete(url, headers=self._headers())
print((yield response.text()))
yield deferLater(reactor, self._settle_delay, lambda: None)
print("stop settled")
def clean_es(reactor):
"""
Drops everythin from elasticsearch
"""
return treq.delete('http://localhost:9200/_all')
def clean(response):
if response.code == 200:
print('deleting and recreating index')
return treq.delete('http://localhost:9200/history')
def delete(url, **kwargs):
"""
Wrapper around :meth:`treq.delete` that logs the request.
See :py:func:`treq.delete`
"""
return _log_request(treq.delete, url, **kwargs)
timeout=timeout,
headers=self.REST_GET_REQUEST_HEADER)
elif method.upper() == 'POST' or method.upper() == 'PUT':
response = yield treq.post(url,
data=data,
auth=(self._username, self._password),
timeout=timeout,
headers=self.REST_POST_REQUEST_HEADER)
elif method.upper() == 'PATCH':
response = yield treq.patch(url,
data=data,
auth=(self._username, self._password),
timeout=timeout,
headers=self.REST_PATCH_REQUEST_HEADER)
elif method.upper() == 'DELETE':
response = yield treq.delete(url,
auth=(self._username, self._password),
timeout=timeout,
headers=self.REST_DELETE_REQUEST_HEADER)
except NotImplementedError:
raise
except (ConnectionDone, ConnectionLost):
if is_retry:
raise
returnValue(self.request(method, uri, data=data, name=name,
timeout=timeout, is_retry=True))
except ConnectionClosed:
returnValue(ConnectionClosed)