Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_nocontent_obj_with_headers():
headers = {'X-Something': 'test'}
return NoContent, 204, headers
def delete_pet(pet_id):
pet = db_session.query(orm.Pet).filter(orm.Pet.id == pet_id).one_or_none()
if pet is not None:
logging.info('Deleting pet %s..', pet_id)
db_session.query(orm.Pet).filter(orm.Pet.id == pet_id).delete()
db_session.commit()
return NoContent, 204
else:
return NoContent, 404
{
'': {'value': 31, 'unit': '%'},
'': {'value': 32, 'unit': '%'},
}
'''
# No data about GPU
assert resource_data
if metric_type is None:
# Put all gathered metric data for each GPU
result = {uuid: gpu_data['metrics'] for uuid, gpu_data in resource_data.items()}
else:
# Put only requested metric data for each GPU
result = {uuid: gpu_data['metrics'][metric_type] for uuid, gpu_data in resource_data.items()}
except (KeyError, AssertionError):
content, status = NoContent, 404
else:
content, status = result, 200
finally:
return content, status
def get_changeset(cset_id):
app = get_app()
csets = app.db.chgsets_find(cid=cset_id, state=None)
if csets:
for c in csets:
return c
else:
return NoContent, 404
def execute_post(pub_key_address):
client = PubKeyClient()
try:
pub_key_data = client.get_status(pub_key_address)
now = time.time()
valid_from = pub_key_data.payload.valid_from
valid_to = pub_key_data.payload.valid_to
return {'revoked': pub_key_data.revoked,
'owner_pub_key': pub_key_data.owner,
'valid': not pub_key_data.revoked and valid_from < now and now < valid_to,
'valid_from': valid_from,
'valid_to': valid_to}
except KeyNotFound:
return NoContent, 404
def find_by_tags(self, tags: list):
if len(tags) <= 0:
return NoContent, 400
return self._db.find_by_tags(tags), 200
def _json_response(response, status=200):
if isinstance(response, web.Response):
return response
if response is NoContent:
return web.Response(status=status)
return web.json_response(response, status=status)
def execute_delete(certificate_address):
client = CertificateClient()
try:
certificate_data = client.get_status(certificate_address)
if certificate_data.revoked:
return {'error': 'The certificate was already revoked'}, 409
return client.revoke_certificate(certificate_address)
except KeyNotFound:
return NoContent, 404
def delete_pet(pet_id: str):
exists = _get_pet(pet_id)
if exists:
logger.info("Deleting pet %s..", pet_id)
r.delete(get_redis_key(pet_id))
return NoContent, 204
else:
return NoContent, 404
def delete(payload):
name = payload['name']
private_key_filename = '{}/{}.priv'.format(KEY_DIR, name)
public_key_filename = '{}/{}.pub'.format(KEY_DIR, name)
if not (os.path.exists(private_key_filename) or os.path.exists(public_key_filename)):
return NoContent, 404
if os.path.exists(private_key_filename):
os.remove(private_key_filename)
if os.path.exists(public_key_filename):
os.remove(public_key_filename)
return NoContent