示例#1
0
def tell(path):
    entries = []

    base = os.path.join(config["juno-base"], "root")

    path = os.path.join(base, safepath(path))

    dirpath, dirnames, filenames = os.walk(path).next()
    for i in sorted(dirnames):
        subpath = "/" + os.path.relpath(os.path.join(path, i), base)
        entries.append({ "text": i,
                         "id": subpath,
                         "can_write_parent": auth.can_write_parent(subpath[1:]),
                         "can_write": auth.can_write(subpath[1:]) })
    for i in sorted(filenames):
        if i[0] == ".": continue

        subpath = "/" + os.path.relpath(os.path.join(path, i), base)
        entries.append({ "text": i,
                         "id": subpath,
                         "can_write_parent": auth.can_write_parent(subpath[1:]),
                         "can_write": auth.can_write(subpath[1:]),
                         "leaf": "true" })

    return json.dumps(entries)
示例#2
0
    def POST(self):
        web.header("Content-Type", "text/html")

        i = web.input(myfile = {})
        (parent, child) = (safepath(i["path"]), i["myfile"].filename)

        if not auth.can_write(parent):
            return json.dumps({"success": False, "msg": "Unauthorized"})

        srcp = common.Mapper.d2s(parent)
        if not srcp.startswith(config["juno-home"] + "/"):
            return json.dumps({"success": False, "msg": "Unauthorized"})

        if not os.path.isdir(srcp) or not child or child[0] == "." \
                or "/" in child:
            return json.dumps({"success": False, "msg": "Unauthorized"})

        srcp = os.path.join(srcp, child)
        if os.path.exists(srcp):
            return json.dumps({"success": False, "msg": "Unauthorized"})
        
        f = open(srcp, "w")
        f.write(i["myfile"].value)
        f.close()
        
        if not odptools.odf.Odp.is_odp(srcp):
            os.unlink(srcp)
            return json.dumps({"success": False, "msg": "Unauthorized"})

        if subprocess.call(("./index.py", "-p", srcp)):
            os.unlink(srcp)
            return json.dumps({"success": False, "msg": "Unauthorized"})

        return json.dumps({"success": True})
示例#3
0
    def POST(self, path):
        path = safepath(path)
        (parent, child) = path.rsplit(os.sep, 1)

        if not auth.can_write(parent):
            return error("Unauthorized")

        srcp = common.Mapper.d2s(parent)
        if not srcp.startswith(config["juno-home"] + "/"):
            return error("Unauthorized")

        if not os.path.isdir(srcp) or not child or child[0] == ".":
            return error("Unauthorized")

        srcp = os.path.join(srcp, child)
        
        base = os.path.join(config["juno-base"], "root")
        dstp = os.path.join(base, common.Mapper.s2d(srcp))
        os.mkdir(srcp)
        os.mkdir(dstp)