Beispiel #1
0
def handle_command(request, guy_id, command):
    try:
        guy = Guy.objects.get(pk=guy_id)
    except Guy.DoesNotExist:
        raise Http404

    try:
        c = Command(action=command, 
                    guy=guy,
                    issued_by=request.user)
        c.save()
    except:
        raise
    
    if command in TURN_INCR.keys():
        try:
            guy.turn(command)
        except:
            raise
    
    if command in MOVE_INCR.keys():
        try:
            guy.move(command)
        except:
            raise
    
    """
    c = Command()
    c_opts = [k for k, v in c.COMMANDS]
    if command not in c_opts:
        raise Http404
    """
        
    return redirect('guy:display', guy_id=guy_id)
Beispiel #2
0
def command(request):
        if request.method == 'POST':
		_command=request.POST.get('command', 'boo')
		_parameter=request.POST.get('parameter',0)
		_quantity=request.POST.get('quantity',0)
		myCommand = Command(command=_command, statusTimeStamp=timezone.now(), parameter=_parameter, quantity=_quantity, status='queued', commandTimeStamp=timezone.now())
		myCommand.json=jsonTranslation(myCommand)
		if myCommand.command=="placePanel":
			myCommand.description=buildDescription(myCommand)
                myCommand.save()
                return HttpResponse("yo")
	else:
		return HttpResponse("bite me")
Beispiel #3
0
def command(request):
        if request.method == 'POST':
		_command=request.POST.get('command', 'boo')
		_parameter=request.POST.get('parameter',0)
		_quantity=request.POST.get('quantity',0)
		myCommand = Command(command=_command, statusTimeStamp=timezone.now(), parameter=_parameter, quantity=_quantity, status='queued', commandTimeStamp=timezone.now())
		myCommand.json=jsonTranslation(myCommand)
		if myCommand.command.lower().find("panel")!=-1:
			return HttpResponse(addPanel(myCommand.json))
		else:
			myCommand.save()
			return HttpResponse(myCommand.command.lower())
	else:
		return HttpResponse("bite me")
Beispiel #4
0
def tinyGParameter(request):
        if request.method == 'POST':
		_command=request.POST.get('command', 'boo')
		_parameter=request.POST.get('parameter',0)
		factoryState=FactoryState.objects.get(id=1)
		if _command.find('var_')!=-1:
			setattr(factoryState, _command, _parameter)
			_command=_command[4:]
			factoryState.save()
		myCommand = Command(command=_command, statusTimeStamp=timezone.now(), quantity=0,parameter=_parameter, status='queued', commandTimeStamp=timezone.now())
		myCommand.json=render_to_string("parameter.html", {'command': myCommand})
                myCommand.save()
                return HttpResponse("parameter set")
	else:
		return HttpResponse("poo")
Beispiel #5
0
def command(request):
    if request.method == 'POST':
        _command = request.POST.get('command', 'boo')
        _parameter = request.POST.get('parameter', 0)
        _quantity = request.POST.get('quantity', 0)
        myCommand = Command(command=_command,
                            statusTimeStamp=timezone.now(),
                            parameter=_parameter,
                            quantity=_quantity,
                            status='queued',
                            commandTimeStamp=timezone.now())
        myCommand.json = jsonTranslation(myCommand)
        if myCommand.command == "placePanel":
            myCommand.description = buildDescription(myCommand)
        myCommand.save()
        return HttpResponse("yo")
    else:
        return HttpResponse("bite me")
Beispiel #6
0
def command(request):
    if request.method == "POST":
        _command = request.POST.get("command", "boo")
        _parameter = request.POST.get("parameter", 0)
        _quantity = request.POST.get("quantity", 0)
        myCommand = Command(
            command=_command,
            statusTimeStamp=timezone.now(),
            parameter=_parameter,
            quantity=_quantity,
            status="queued",
            commandTimeStamp=timezone.now(),
        )
        myCommand.json = jsonTranslation(myCommand)
        if myCommand.command == "placePanel":
            myCommand.description = buildDescription(myCommand)
        myCommand.save()
        return HttpResponse("yo")
    else:
        return HttpResponse("bite me")
Beispiel #7
0
def tinyGParameter(request):
    if request.method == 'POST':
        _command = request.POST.get('command', 'boo')
        _parameter = request.POST.get('parameter', 0)
        factoryState = FactoryState.objects.get(id=1)
        if _command.find('var_') != -1:
            setattr(factoryState, _command, _parameter)
            _command = _command[4:]
            factoryState.save()
        myCommand = Command(command=_command,
                            statusTimeStamp=timezone.now(),
                            quantity=0,
                            parameter=_parameter,
                            status='queued',
                            commandTimeStamp=timezone.now())
        myCommand.json = render_to_string("parameter.html",
                                          {'command': myCommand})
        myCommand.save()
        return HttpResponse("parameter set")
    else:
        return HttpResponse("poo")
Beispiel #8
0
def tinyGParameter(request):
    if request.method == "POST":
        _command = request.POST.get("command", "boo")
        _parameter = request.POST.get("parameter", 0)
        factoryState = FactoryState.objects.get(id=1)
        if _command.find("var_") != -1:
            setattr(factoryState, _command, _parameter)
            _command = _command[4:]
            factoryState.save()
        myCommand = Command(
            command=_command,
            statusTimeStamp=timezone.now(),
            quantity=0,
            parameter=_parameter,
            status="queued",
            commandTimeStamp=timezone.now(),
        )
        myCommand.json = render_to_string("parameter.html", {"command": myCommand})
        myCommand.save()
        return HttpResponse("parameter set")
    else:
        return HttpResponse("poo")