Exemplo n.º 1
0
def run(cmd):
    try:
        args = shlex.split(cmd)
        p = subprocess.Popen(args)
        returncode = p.wait()
        if returncode == 0:
            r = pack_result(RS_SUCCESS)
    except Exception, e:
        r = pack_result(RS_FAILURE, message=repr(e))
Exemplo n.º 2
0
def run(cmd):
    try:
        args = shlex.split(cmd)
        p = subprocess.Popen(args)
        returncode = p.wait()
        if returncode == 0:
            r = pack_result(RS_SUCCESS)
    except Exception, e:
        r = pack_result(RS_FAILURE, message=repr(e))
Exemplo n.º 3
0
 def login(self):
     username = request.POST["username"]
     passwd = md5(request.POST["passwd"]).hexdigest()
     q = model.meta.Session.query(model.DKUser)
     user = q.get(username)
     if user.passwd == passwd:
         #cache user in session
         session["user"] = user
         session.save()
         return pack_result(RS_SUCCESS)
     else:
         return pack_result(RS_FAILURE)
Exemplo n.º 4
0
 def login(self):
     username = request.POST["username"]
     passwd = md5(request.POST["passwd"]).hexdigest()
     q = model.meta.Session.query(model.DKUser)
     user = q.get(username)
     if user.passwd == passwd:
         #cache user in session
         session["user"] = user
         session.save()
         return pack_result(RS_SUCCESS)
     else:
         return pack_result(RS_FAILURE)
Exemplo n.º 5
0
def gen_master_key():
    if os.path.exists(os.path.expanduser("~/.cpk/public_params")):
        r = pack_result(RS_FAILURE, "public_params.der already imported!")
        log.info("%s(): => %s" % (FUNC_NAME(), repr(r)))
        return r

    cmd = "%(cpkdir)s/cpk -import-param -in %(cpkdir)s/public_params.der" % config["pylons.paths"]
    return run(cmd)
Exemplo n.º 6
0
def gen_master_key():
    if os.path.exists(os.path.expanduser("~/.cpk/public_params")):
        r = pack_result(RS_FAILURE, "public_params.der already imported!")
        log.info("%s(): => %s" % (FUNC_NAME(), repr(r)))
        return r

    cmd = "%(cpkdir)s/cpk -import-param -in %(cpkdir)s/public_params.der" % config[
        "pylons.paths"]
    return run(cmd)
Exemplo n.º 7
0
    def register(self):
        user = model.DKUser()

        user.username = request.POST["username"]
        user.passwd = md5(request.POST["passwd"]).hexdigest()
        user.master_email = request.POST["email"]
        user.phone_mobile = request.POST["phone_mobile"]
        user.phone_office = request.POST["phone_office"]
        user.phone_home = request.POST["phone_home"]
        user.org = request.POST["org"]
        user.title = request.POST["title"]
        user.addr = request.POST["addr"]
        #roles is stored as ":" seperated string
        user.roles = ":".join((meta.ROLE_USER, ))

        session = model.meta.Session
        session.add(user)
        session.commit()
        return pack_result(RS_SUCCESS)
Exemplo n.º 8
0
    def register(self):
        user = model.DKUser()

        user.username = request.POST["username"]
        user.passwd = md5(request.POST["passwd"]).hexdigest()
        user.master_email = request.POST["email"]
        user.phone_mobile = request.POST["phone_mobile"]
        user.phone_office = request.POST["phone_office"]
        user.phone_home = request.POST["phone_home"]
        user.org = request.POST["org"]
        user.title = request.POST["title"]
        user.addr = request.POST["addr"]
        #roles is stored as ":" seperated string
        user.roles = ":".join((meta.ROLE_USER, ))

        session = model.meta.Session
        session.add(user)
        session.commit()
        return pack_result(RS_SUCCESS)
Exemplo n.º 9
0
 def get_user_count(self):
     count = meta.Session.query(model.DKUser).count()
     return pack_result(RS_SUCCESS, data=count)
Exemplo n.º 10
0
    def get_users(self, id):
        offset, size = map(int, id.split("&", 1)[0].split("-"))
        q = meta.Session.query(model.DKUser).offset(offset).limit(size)
        l = [(u.username, u.master_email) for u in q.all()]

        return pack_result(RS_SUCCESS, data=l)