async def reset(request: web.Request) -> web.Response: # noqa(C901) """ Execute a reset of the requested parts of the user configuration. """ data = await request.json() ok, bad_key = _check_reset(data) if not ok: return web.json_response( {'message': '{} is not a valid reset option'.format(bad_key)}, status=400) log.info("Reset requested for {}".format(', '.join(data.keys()))) if data.get('tipProbe'): config = rc.load() if ff.use_protocol_api_v2(): config = config._replace( instrument_offset=rc.build_fallback_instrument_offset({})) else: config.tip_length.clear() rc.save_robot_settings(config) if data.get('labwareCalibration'): labware.clear_calibrations() if not ff.use_protocol_api_v2(): db.reset() if data.get('customLabware'): labware.delete_all_custom_labware() if data.get('bootScripts'): if IS_ROBOT: if os.path.exists('/data/boot.d'): shutil.rmtree('/data/boot.d') else: log.debug('Not on pi, not removing /data/boot.d') return web.json_response({}, status=200)
async def reset(request: web.Request) -> web.Response: # noqa(C901) """ Execute a reset of the requested parts of the user configuration. POST /settings/reset {resetOption: Any} -> 200 OK, {"links": {"restart": uri}} -> 400 Bad Request, {"error": error-shortmessage, "message": str} """ data = await request.json() ok, bad_key = _check_reset(data) if not ok: return web.json_response( { 'error': 'bad-reset-option', 'message': f'{bad_key} is not a valid reset option' }, status=400) log.info("Reset requested for {}".format(', '.join(data.keys()))) if data.get('tipProbe'): config = rc.load() config = config._replace( instrument_offset=rc.build_fallback_instrument_offset({})) config.tip_length.clear() rc.save_robot_settings(config) if data.get('labwareCalibration'): labware.clear_calibrations() db.reset() if data.get('customLabware'): labware.delete_all_custom_labware() if data.get('bootScripts'): if IS_ROBOT: if os.path.exists('/data/boot.d'): shutil.rmtree('/data/boot.d') else: log.debug('Not on pi, not removing /data/boot.d') return web.json_response({}, status=200)
def reset_labware_calibration(): delete.clear_calibrations() db.reset()