def track_package(request, pkg):
	action = request.GET["action"]
	cb = request.GET["cb"]
	user = maybe_login(request)
	status = "no_user"
	if user != None:
		if action == "track":
			if not groups.has_group(".tracked", user.id):
				groups.create_group(".tracked", user.id)
			groups.add_to_group(pkg, ".tracked", user.id)
			status = "tracked"
		elif action == "untrack":
			if groups.has_group(".tracked", user.id):
				groups.remove_from_group(pkg, ".tracked", user.id)
			status = "untracked"
		elif action == "is_tracked":
			if groups.in_group(pkg, ".tracked", user.id):
				status = "tracked"
			else:
				status = "untracked"
		else:
			status = "unknown_command"
	response = cb + '({"status":"%s"'%(status) + "})"
	return HttpResponse(response)
# -*- coding: utf-8 -*-
import sys
sys.path.append(".")
from utils.db import groups

if len(sys.argv)==1:
	print sys.argv[0],"<cmd>","[opts]"
	print "list"
	print "list <group>"
	print "create <name>"
	print "delete <name>"
	print "add_to <group> <package>"
elif sys.argv[1]=="list" and len(sys.argv)==2:
	gs = groups.list_groups()
	for group in gs:
		print group
elif sys.argv[1]=="list":
	pkgs = groups.get_group(sys.argv[2])
	for p in pkgs:
		print p
elif sys.argv[1]=="create":
	print "new group id:",groups.create_group(sys.argv[2])
elif sys.argv[1]=="delete":
	groups.delete_group(sys.argv[2])
elif sys.argv[1]=="add_to":
	groups.add_to_group(sys.argv[3], sys.argv[2])
print "done"
# -*- coding: utf-8 -*-
import sys
sys.path.append(".")
from utils.db import groups

if len(sys.argv) == 1:
    print sys.argv[0], "<cmd>", "[opts]"
    print "list"
    print "list <group>"
    print "create <name>"
    print "delete <name>"
    print "add_to <group> <package>"
elif sys.argv[1] == "list" and len(sys.argv) == 2:
    gs = groups.list_groups()
    for group in gs:
        print group
elif sys.argv[1] == "list":
    pkgs = groups.get_group(sys.argv[2])
    for p in pkgs:
        print p
elif sys.argv[1] == "create":
    print "new group id:", groups.create_group(sys.argv[2])
elif sys.argv[1] == "delete":
    groups.delete_group(sys.argv[2])
elif sys.argv[1] == "add_to":
    groups.add_to_group(sys.argv[3], sys.argv[2])
print "done"