Exemplo n.º 1
0
    def GET(self):
        shell_list = []
        dirname = "scripts"
        if os.path.exists(dirname):
            for fname in os.listdir(dirname):
                fpath = os.path.join(dirname, fname)
                if os.path.isfile(fpath) and fpath.endswith(".bat"):
                    shell_list.append(fpath)

        # 自定义链接
        customized_items = []
        db = xtables.get_storage_table()
        config = db.select_one(
            where=dict(key="tools", user=xauth.get_current_name()))
        if config is not None:
            config_list = xutils.parse_config_text(config.value)
            customized_items = map(
                lambda x: Storage(name=x.get("key"), link=x.get("value")),
                config_list)

        return xtemplate.render("system/system.html",
                                Storage=Storage,
                                os=os,
                                user=xauth.get_current_user(),
                                customized_items=customized_items)
Exemplo n.º 2
0
 def GET(self):
     key  = xutils.get_argument("key")
     db = xtables.get_storage_table()
     config = db.select_first(where=dict(key=key, user=xauth.get_current_name()))
     if config is None:
         config = Storage(key=key, value="")
     return xtemplate.render("system/properties.html", 
         action = "/system/storage",
         show_aside = False,
         config = config)
Exemplo n.º 3
0
 def GET(self):
     type = xutils.get_argument("type", "tool")
     items = []
     customized_items = []
     name = "工具库"
     if type == "tool":
         items = list(filter(tool_filter, _tools))
         db = xtables.get_storage_table()
         config = db.select_one(where=dict(key="tools", user=xauth.get_current_name()))
         if config is not None:
             config_list = xutils.parse_config_text(config.value)
             customized_items = map(lambda x: Storage(name=x.get("key"), link=x.get("value")), config_list)
     return xtemplate.render("grid.html", items=items, name = name, customized_items = customized_items)
Exemplo n.º 4
0
    def POST(self):
        key = xutils.get_argument("key")
        value = xutils.get_argument("value")
        user = xauth.get_current_name()
        db = xtables.get_storage_table()
        config = db.select_first(where=dict(key=key, user=user))
        if config is None:
            db.insert(user = user, key = key, value = value, 
                ctime = xutils.format_datetime(), 
                mtime = xutils.format_datetime())
        else:
            db.update(value=value, mtime = xutils.format_datetime(), where=dict(key=key, user=user))

        config = Storage(key = key, value = value)
        return xtemplate.render("system/properties.html", 
            action = "/system/storage",
            show_aside = False,
            config = config)
Exemplo n.º 5
0
def get_tools_config(user):
    db = xtables.get_storage_table()
    user_config = db.select_first(where=dict(key="tools", user=user))
    return user_config