Ejemplo n.º 1
0
def reparse_all_users():
	gce = GridControlEngine(
		get_client(),
		line_limit = settings.GRIDCONTROL_LINE_LIMIT,
		const_limit = settings.GRIDCONTROL_CONST_LIMIT,
	)
	gce.reparse_all_users()
Ejemplo n.º 2
0
def use_gist(request):
	if request.method == "POST":
		code = None
		success = False
		msg = ""
		ctx = {}
		computed_max_size = settings.GRIDCONTROL_GIST_MAX_SIZE
		gist_retriever = GistRetriever(request.user.username)
		gist_id = request.POST['gist_id']
		gist_revision = request.POST['gist_revision']
		gist_files = gist_retriever.get_gist_version(gist_id, gist_revision)
		print "# of files found: %d" % len(gist_files)
		for gfile in gist_files:
			print "Filename: %s" % gfile["filename"] #DEBUG
			if _valid_ext(gfile["filename"]):
				ctx["filename"] = gfile["filename"]
				if(int(gfile["size"]) < computed_max_size):
					success, msg = register_code(request.user, gfile["text_url"])
				else:
					success, msg = False, 'file {} too large.  less coad pls'.format(gfile['text_url'])
				break
		print "Success: %s" % str(success) #DEBUG
		print "Message: %s" % msg #DEBUG
		ctx['success'] = success
		ctx['message'] = msg

		user = request.user
		gce = GridControlEngine(get_client())
		gce.activate_user(user.id, user.username)

		return render_to_response("account/use_gist.html", ctx, RequestContext(request))
	else:
		return HttpResponseNotAllowed(['POST'])
Ejemplo n.º 3
0
def account(request):
	user = request.user
	gce = GridControlEngine(get_client())
	ctx = {
		'is_active': gce.is_user_active(user.id),
	}
	return render_to_response("account/home.html", ctx, RequestContext(request))
Ejemplo n.º 4
0
def use_gist(request, gist_id=0):
	gist = (g for g in request.session['gists'] if g['id'] == unicode(gist_id)).next()
	code = None
	success = False
	msg = ""
	ctx = {}
	gist_retriever = GistRetriever(request.user.username)

	computed_max_size = settings.GRIDCONTROL_GIST_MAX_SIZE

	for gist_fname, gist_fdata in gist['files'].items():
		if _valid_ext(gist_fname):
			ctx['filename'] = gist_fname
			if gist_fdata['size'] < computed_max_size:
				success, msg = register_code(request.user, gist_fdata['raw_url'])
			else:
				success, msg = False, 'file {} too large.  less coad pls'.format(gist_fdata['raw_url'])
			break

	ctx['success'] = success
	ctx['message'] = msg

	user = request.user
	gce = GridControlEngine(get_client())
	gce.activate_user(user.id, user.username)

	return render_to_response("account/use_gist.html", ctx, RequestContext(request))
Ejemplo n.º 5
0
def register_code(user, gist_url):
	gce = GridControlEngine(
		get_client(),
		line_limit = settings.GRIDCONTROL_LINE_LIMIT,
		const_limit = settings.GRIDCONTROL_CONST_LIMIT,
	)
	success, msg = gce.register_code(user.id, gist_url)
	return success, msg
Ejemplo n.º 6
0
def view_code(request, userid):
	gce = GridControlEngine(get_client())
	user = get_object_or_404(User, id=userid)
	ctx = {
		'code': gce.get_user_code(userid),
		'botowner': user,
	}
	return render_to_response("view_code.html", ctx, RequestContext(request))
Ejemplo n.º 7
0
def tick_all_users():
	gce = GridControlEngine(
		get_client(),
		data_limit = settings.GRIDCONTROL_DATA_LIMIT,
		exe_limit = settings.GRIDCONTROL_EXE_LIMIT,
		reg_limit = settings.GRIDCONTROL_REG_LIMIT,
	)
	gce.do_tick()
	gce.emit_tick()
Ejemplo n.º 8
0
def bot_debug(request):
	user = request.user
	gce = GridControlEngine(get_client())
	ctx = {
		'code': gce.get_user_code(user.id),
		'stack': gce.get_user_vm(user.id),
	}
	ctx['json'] = json.dumps(ctx, use_decimal=True)
	return render_to_response("account/bot_debug.html", ctx, RequestContext(request))
Ejemplo n.º 9
0
def register_logout(user):
	gce = GridControlEngine(get_client())
	gce.deactivate_user(user.id)
Ejemplo n.º 10
0
def register_login(user):
	gce = GridControlEngine(get_client())
	gce.activate_user(user.id, user.username)