import arcpy
arcpy.CheckOutExtension("LocationReferencing")
delete_associated_calibration_points = "DELETE_CALIBRATION_POINTS"
delete_associated_events = "DELETE_EVENTS"
delete_associated_centerlines = "DELETE_CENTERLINES"
arcpy.SignInToPortal('https://yourdomain.com/portal', 'username', 'password')
in_route_layer = arcpy.management.MakeFeatureLayer("https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/1", 'route_layer')
arcpy.management.SelectLayerByAttribute(in_route_layer, "NEW_SELECTION", "RouteID = 'routeid1'")
arcpy.locref.DeleteRoutes( in_route_layer, delete_associated_calibration_points, delete_associated_events, delete_associated_centerlines)
arcpy.CheckInExtension('LocationReferencing')