Exemple #1
0
def masterReset(request):
    """
    Usage:
        If something goes wrong or if testing, this could be handy

    DELETE:
        Completely reset db
    """
    try:
        response = MasterResetAction(request.GET, request.read(), request.method)
    except Exception as ex:
        print 'Error: {0}'.format(str(ex))
        response = BuildJsonResponse(False, 'An unexpected server error occurred {0}'.format(str(ex)))
    return json_response(response)
Exemple #2
0
def localip(request):
    """
    Usage:
        For symposium, just save the IP of the robot

    POST:
        Save this IP for this robot
    """
    try:
        response = LocalIpAction(request.GET, request.method)
    except Exception as ex:
        print 'Error: {0}'.format(str(ex))
        response = BuildJsonResponse(False, 'An unexpected server error occurred {0}'.format(str(ex)))
    return json_response(response)
Exemple #3
0
def visualMap(request):
    """
    Usage:
        Regenerate visual map based on db data

    GET:
        Build and save map
    """
    try:
        if 'userId' not in request.session:
            request.session['userId'] = str(uuid.uuid1())
        response = VisualMapAction(request.GET, request.read(), request.method, request.session['userId'])
    except Exception as ex:
        print 'Error: {0}'.format(str(ex))
        response = BuildJsonResponse(False, 'An unexpected server error occurred: {0}'.format(str(ex)))
    return json_response(response)
Exemple #4
0
def robot(request):
    """
    Usage:
        Requests that are specific to the robot

    GET:
        Gets all data for specified robot
    POST:
        Create or update robot data and update cells, if any
    DELETE:
        Wipes all data for specified robot
    """
    try:
        response = RobotAction(request.GET, request.read(), request.method)
    except Exception as ex:
        print 'Error: {0}'.format(str(ex))
        response = BuildJsonResponse(False, 'An unexpected server error occurred: {0}'.format(str(ex)))
    return json_response(response)
Exemple #5
0
def userInterface(request):
    """
    Usage:
        Requests that are specific to the UI

    GET:
        Updates map and gets robot information if specified
    POST:
        Updates instruction to send to robot
    DELETE:
        Resets specified aspect of db
        - "map" resets whole map
        - "waypoints" with robot ID resets waypoints
        - "instruction" with robot ID resets instruction
        - "robot" with robot ID resets entire robot
    """
    try:
        response = UserInterfaceAction(request.GET, request.read(), request.method)
    except Exception as ex:
        print 'Error: {0}'.format(str(ex))
        response = BuildJsonResponse(False, 'An unexpected server error occurred: {0}'.format(str(ex)))
    return json_response(response)