示例#1
0
def on_search_plugins(ctx):
    if not xauth.is_admin():
        return
    if not ctx.search_tool:
        return
    if ctx.search_dict:
        return
    name = ctx.key
    results = []
    dirname = xconfig.PLUGINS_DIR
    words = textutil.split_words(name)
    for fname in xutils.listdir(dirname):
        unquote_name = xutils.unquote(fname)
        unquote_name, ext = os.path.splitext(unquote_name)
        plugin_context = xconfig.PLUGINS.get(fname)
        if textutil.contains_all(unquote_name, words) \
                or (plugin_context != None and textutil.contains_all(plugin_context.title, words)):
            result = SearchResult()
            result.category = "plugin"
            result.name = u("[插件] " + unquote_name)
            if plugin_context != None:
                # result.raw = u(plugin_context.title)
                # result.name = u("插件 %s (%s)") % (u(plugin_context.title), unquote_name)
                if plugin_context.title != None:
                    result.name = u("[插件] " + plugin_context.title + "(" +
                                    unquote_name + ")")
            result.url = u("/plugins/" + unquote_name)
            result.edit_link = u("/code/edit?path=" +
                                 os.path.join(dirname, fname))
            results.append(result)
    ctx.tools += results
示例#2
0
文件: fs.py 项目: ydx2099/xnote
    def POST(self):
        dirname = xutils.get_argument("dirname")
        old_name = xutils.get_argument("old_name", "")
        new_name = xutils.get_argument("new_name", "")
        user_name = xauth.current_name()

        if dirname is None or dirname == "":
            return dict(code="fail", message="dirname is blank")
        if old_name is None or old_name == "":
            return dict(code="fail", message="old_name is blank")

        if ".." in new_name:
            return dict(code="fail", message="invalid new name")
        if new_name == "":
            new_name = os.path.basename(old_name)
        if xconfig.USE_URLENCODE:
            old_name = xutils.quote_unicode(old_name)
            new_name = xutils.quote_unicode(new_name)

        old_path = os.path.join(dirname, old_name)
        new_path = os.path.join(dirname, new_name)
        if not xauth.is_admin() and not check_file_auth(old_path, user_name):
            return dict(code="fail", message="unauthorized")
        if not os.path.exists(old_path):
            return dict(code="fail", message="源文件 `%s` 不存在" % old_name)
        if os.path.exists(new_path):
            return dict(code="fail", message="目标文件 `%s` 已存在" % new_name)
        os.rename(old_path, new_path)
        xmanager.fire(
            "fs.rename",
            Storage(user=user_name,
                    path=new_path,
                    new_path=new_path,
                    old_path=old_path))
        return dict(code="success")
示例#3
0
    def handle(self, input):
        self.rows = 0
        user_name = xauth.current_name()
        stat_list = []
        admin_stat_list = []
        stat_list.append(["我的项目", xutils.call("note.count_by_type", user_name, "group")])
        stat_list.append(["我的笔记", dbutil.count_table("note_tiny:%s" % user_name)])
        stat_list.append(["待办事项", dbutil.count_table("message:%s" % user_name)])
        stat_list.append(["搜索记录", dbutil.count_table("search_history:%s" % user_name)])
        stat_list.append(["我的评论", dbutil.count_table("comment_index:%s" % user_name)])
        
        if xauth.is_admin():
            admin_stat_list.append(["note_full", dbutil.count_table("note_full")])
            admin_stat_list.append(["note_tiny", dbutil.count_table("note_tiny")])
            admin_stat_list.append(["note_index", dbutil.count_table("note_index")])
            admin_stat_list.append(["note_history", dbutil.count_table("note_history")])
            admin_stat_list.append(["note_comment", dbutil.count_table("note_comment")])
            admin_stat_list.append(["comment_index", dbutil.count_table("comment_index")])
            admin_stat_list.append(["note_deleted", dbutil.count_table("note_deleted")])
            admin_stat_list.append(["notebook", dbutil.count_table("notebook")])
            admin_stat_list.append(["search_history", dbutil.count_table("search_history")])
            admin_stat_list.append(["message",  dbutil.count_table("message")])
            admin_stat_list.append(["msg_search_history", dbutil.count_table("msg_search_history")])
            admin_stat_list.append(["msg_history", dbutil.count_table("msg_history")])
            admin_stat_list.append(["msg_key", dbutil.count_table("msg_key")])
            admin_stat_list.append(["user_stat", dbutil.count_table("user_stat")])

            admin_stat_list.append(["schedule", dbutil.count_table("schedule")])
            admin_stat_list.append(["user", dbutil.count_table("user")])
            admin_stat_list.append(["record", dbutil.count_table("record")])

        self.writetemplate(HTML, stat_list = stat_list, admin_stat_list = admin_stat_list)
示例#4
0
def search(delay_mins, message):
    if not xauth.is_admin():
        return []
    db = xtables.get_schedule_table()
    url = "/api/alarm/" + message

    millis = time.time() + int(delay_mins) * 60
    tm = time.localtime(millis)
    tm_wday = "no-repeat"
    tm_hour = tm.tm_hour
    tm_min = tm.tm_min

    db.insert(url=url,
              ctime=xutils.format_time(),
              mtime=xutils.format_time(),
              tm_wday=tm_wday,
              tm_hour=tm_hour,
              tm_min=tm_min)

    xmanager.load_tasks()

    result = SearchResult()
    result.name = "提醒"
    result.raw = "提醒创建成功,将于%s提醒 %s" % (xutils.format_time(millis), message)
    return [result]
示例#5
0
def on_search_plugins(ctx):
    if not xauth.is_admin():
        return
    if not ctx.search_tool:
        return
    if ctx.search_dict:
        return
    name = ctx.key
    results = []
    words = textutil.split_words(name)
    for name in xconfig.PLUGINS_DICT:
        plugin = xconfig.PLUGINS_DICT[name]
        unquote_name = xutils.unquote(plugin.fname)
        unquote_name, ext = os.path.splitext(unquote_name)
        plugin_context = plugin
        if textutil.contains_all(unquote_name, words) \
                or (textutil.contains_all(plugin_context.title, words)):
            result = SearchResult()
            result.category = "plugin"
            result.icon = "fa-cube"
            result.name = u(unquote_name)
            if plugin_context != None:
                # result.raw = u(plugin_context.title)
                # result.name = u("插件 %s (%s)") % (u(plugin_context.title), unquote_name)
                if plugin_context.title != None:
                    result.name = u(plugin_context.title + "(" + unquote_name +
                                    ")")
            result.url = u(plugin.url)
            result.edit_link = u("/code/edit?path=" + plugin.fpath)
            results.append(result)
    ctx.tools += results
示例#6
0
    def GET(self):
        category = xutils.get_argument("category", "")
        plugin_categories = []

        if xauth.is_admin():
            recent = list_recent_plugins()
            plugins = list_plugins(category)
            note_plugins = list_plugins("note")
            dev_plugins = list_plugins("develop")
            sys_plugins = list_plugins("system")
            dir_plugins = list_plugins("dir")
            net_plugins = list_plugins("network")
            other_plugins = list(
                filter(
                    lambda x: x.category not in
                    ("inner", "note", "develop", "system", "dir", "network"),
                    plugins))

            plugin_categories.append(["最近", recent])
            plugin_categories.append(["默认工具", build_inner_tools()])
            plugin_categories.append(["笔记", note_plugins])
            plugin_categories.append(["开发工具", dev_plugins])
            plugin_categories.append(["系统", sys_plugins])
            plugin_categories.append(["文件", dir_plugins])
            plugin_categories.append(["网络", net_plugins])
            plugin_categories.append(["其他", other_plugins])
        else:
            plugins = build_inner_tools()
            plugin_categories.append(["默认工具", plugins])

        return xtemplate.render("plugins/plugins.html",
                                category=category,
                                html_title="插件",
                                plugin_categories=plugin_categories)
示例#7
0
文件: plugins.py 项目: driphub/xnote
def on_search_plugins(ctx):
    if not xauth.is_admin():
        return
    if not ctx.search_tool:
        return
    if ctx.search_dict:
        return

    results = []

    for plugin in search_plugins(ctx.key):
        result = SearchResult()
        result.category = "plugin"
        result.icon = "fa-cube"
        result.name = u(plugin.name)
        result.name = u(plugin.title + "(" + plugin.name + ")")
        result.url = u(plugin.url)
        result.edit_link = plugin.edit_link
        results.append(result)

    result_count = len(results)
    if ctx.category != "plugin" and len(results) > 3:
        results = results[:3]
        more = SearchResult()
        more.name = u("查看更多插件(%s)") % result_count
        more.icon = "fa-cube"
        more.url = "/plugins_list?category=plugin&key=" + ctx.key
        results.append(more)
    ctx.tools += results
示例#8
0
    def GET(self):
        category = xutils.get_argument("category", "")
        key      = xutils.get_argument("key", "")

        if xauth.is_admin():
            if key != "" and key != None:
                recent  = []
                plugins = search_plugins(key)
            else:
                recent   = list_recent_plugins()
                plugins  = list_plugins(category)
        else:
            recent = []
            if category == "" or category == "all":
                plugins = build_inner_tools()
            else:
                plugins = []

        return xtemplate.render("plugins/plugins_old.html", 
            category = category,
            html_title = "插件",
            show_aside = xconfig.OPTION_STYLE == "aside",
            search_placeholder = "搜索工具",
            search_action = "/plugins_list",
            recent     = recent,
            plugins    = plugins)
示例#9
0
def pre_render(kw):
    """模板引擎预处理过程"""
    kw["math"]          = math
    kw["_is_admin"]     = xauth.is_admin()
    kw["_has_login"]    = xauth.has_login()
    user_name           = xauth.get_current_name() or ""
    kw["_user_name"]    = user_name
    kw["_user_agent"]   = get_user_agent()
    # 处理首页公告
    kw["_top_notice"]   = None
    # 用于渲染其他组件
    kw["_render"]       = render
    kw["Storage"]       = Storage
    kw["xutils"]        = xutils
    kw["xconfig"]       = xconfig
    kw["_notice_count"] = get_message_count(user_name)
    if hasattr(web.ctx, "env"):
        kw["HOST"] = web.ctx.env.get("HTTP_HOST")
    if xutils.sqlite3 is None:
        kw["warn"] = "WARN: sqlite3不可用"

    # render input
    _input = web.ctx.get("_xnote.input")
    if _input is not None:
        kw.update(_input)
示例#10
0
    def GET(self):
        id = xutils.get_argument("id", "")
        name = xutils.get_argument("name", "")
        file = None

        if id != "" and id != None:
            file = NOTE_DAO.get_by_id(id)
        elif name != "":
            file = NOTE_DAO.get_by_name(xauth.current_name(), name)
        else:
            return dict(code="fail", message="id,name至少一个不为空")

        if file is None:
            return dict(code="fail", message="笔记不存在")

        creator = xauth.current_name()
        if not xauth.is_admin() and file.creator != creator:
            return dict(code="fail", message="没有删除权限")

        if file.type == "group":
            children_count = NOTE_DAO.count_by_parent(creator, file.id)
            if children_count > 0:
                return dict(code="fail", message="分组不为空")

        NOTE_DAO.delete(file.id)
        return dict(code="success")
示例#11
0
 def POST(self):
     content = xutils.get_argument("content", "")
     data = xutils.get_argument("data", "")
     id = xutils.get_argument("id", "0", type=int)
     type = xutils.get_argument("type")
     name = xauth.get_current_name()
     db = xtables.get_file_table()
     where = None
     if xauth.is_admin():
         where = dict(id=id)
     else:
         where = dict(id=id, creator=name)
     kw = dict(size=len(content),
               mtime=xutils.format_datetime(),
               where=where)
     if type == "html":
         kw["data"] = data
         kw["content"] = data
         if xutils.bs4 is not None:
             soup = xutils.bs4.BeautifulSoup(data, "html.parser")
             content = soup.get_text(separator=" ")
             kw["content"] = content
         kw["size"] = len(content)
     else:
         kw["content"] = content
         kw["size"] = len(content)
     rowcount = db.update(**kw)
     if rowcount > 0:
         return dict(code="success")
     else:
         return dict(code="fail")
示例#12
0
def pre_render(kw):
    """模板引擎预处理过程"""
    user_name = xauth.current_name() or ""

    kw["math"] = math
    kw["_is_admin"] = xauth.is_admin()
    kw["_has_login"] = xauth.has_login()
    kw["_user_name"] = user_name
    kw["_user_agent"] = get_user_agent()
    # 处理首页公告
    kw["_top_notice"] = None
    # 用于渲染其他组件
    kw["_render"] = render
    kw["Storage"] = Storage
    kw["xutils"] = xutils
    kw["xconfig"] = xconfig
    kw["_user_config"] = get_user_config(user_name)
    kw["_notice_count"] = get_message_count(user_name)
    kw["T"] = T
    kw["HOME_PATH"] = xconfig.get_user_config(user_name, "HOME_PATH")
    if hasattr(web.ctx, "env"):
        kw["HOST"] = web.ctx.env.get("HTTP_HOST")

    if len(xconfig.errors) > 0:
        kw["warn"] = "; ".join(xconfig.errors)

    # render input
    _input = web.ctx.get("_xnote.input")
    if _input is not None:
        kw.update(_input)
示例#13
0
文件: stats.py 项目: zenistzw/xnote
    def GET(self):
        # X-Forwarded-For是RFC 7239(Forwarded HTTP Extension)定义的扩展首部,大部分代理支持
        # 格式如下:
        # X-Forwarded-For: client, proxy1, proxy2
        # 而X-Real-IP目前不属于任何标准
        # See https://imququ.com/post/x-forwarded-for-header-in-http.html
        # save_ip(web.ctx.env.get("HTTP_X_FORWARDED_FOR"))
        # save_ip(web.ctx.env.get("REMOTE_ADDR"))

        # web.header("Cache-Control", "max-age=600")
        environ = web.ctx.environ
        content = "/* empty */"

        web.header("Content-Type", "application/javascript")
        client_etag = environ.get('HTTP_IF_NONE_MATCH')

        if client_etag == None or client_etag == "":
            client_etag_val = 0
        else:
            client_etag_val = float(client_etag)

        if time.time() - client_etag_val > 600:
            # 采集数据时间区间
            save_ip(web.ctx.env.get("HTTP_X_FORWARDED_FOR"))
            save_ip(web.ctx.env.get("REMOTE_ADDR"))
            if xconfig.RECORD_LOCATION:
                content = SCRIPT

        if not xauth.is_admin():
            content = "/* empty */"
        web.header("Etag", time.time())
        return content
示例#14
0
    def GET(self):
        id = xutils.get_argument("id", "")
        name = xutils.get_argument("name", "")
        file = None

        if id == "" and name == "":
            return dict(code="fail", message="id,name至少一个不为空")

        db = xtables.get_file_table()
        if id != "":
            file = db.select_one(where=dict(id=int(id), is_deleted=0))
        elif name != "":
            file = get_by_name(db, name)
        if file is None:
            return dict(code="fail", message="文件不存在")
        id = file.id

        if not xauth.is_admin() and file.creator != xauth.get_current_name():
            return dict(code="fail", message="没有删除权限")

        if file.type == "group":
            children_count = db.count(where="parent_id=%s AND is_deleted=0"%id)
            if children_count > 0:
                return dict(code="fail", message="分组不为空")

        db.update(is_deleted=1, mtime=dateutil.format_time(), where=dict(id=int(id)))
        db.delete(where="is_deleted=1 AND mtime < $date", vars=dict(date=dateutil.before(days=30,format=True)))
        xmanager.fire("note.remove", dict(id=id))
        return dict(code="success")
示例#15
0
文件: edit.py 项目: arong-me/xnote
    def GET(self):
        id = xutils.get_argument("id", "")
        name = xutils.get_argument("name", "")
        file = None

        print("remove", id, name)

        if id == "" and name == "":
            return dict(code="fail", message="id,name至少一个不为空")

        if id != "":
            file = xutils.call("note.get_by_id", id)
        elif name != "":
            file = xutils.call("note.get_by_name", name)
        if file is None:
            return dict(code="fail", message="文件不存在")

        creator = xauth.current_name()
        if not xauth.is_admin() and file.creator != creator:
            return dict(code="fail", message="没有删除权限")

        if file.type == "group":
            children_count = xutils.call("note.count", creator, file.id)
            if children_count > 0:
                return dict(code="fail", message="分组不为空")

        xutils.call("note.delete", id)
        return dict(code="success")
示例#16
0
    def handle(self, input):
        self.rows = 0
        user_name = xauth.current_name()
        stat_list = []
        admin_stat_list = []
        stat_list.append(
            ["我的笔记", dbutil.count_table("note_tiny:%s" % user_name)])
        stat_list.append(
            ["笔记本",
             xutils.call("note.count_by_type", user_name, "group")])
        stat_list.append(
            ["备忘总数", dbutil.count_table("message:%s" % user_name)])
        if xauth.is_admin():
            admin_stat_list.append(
                ["note_full", dbutil.count_table("note_full")])
            admin_stat_list.append(
                ["note_tiny", dbutil.count_table("note_tiny")])
            admin_stat_list.append(
                ["note_index", dbutil.count_table("note_index")])
            admin_stat_list.append(
                ["note_history",
                 dbutil.count_table("note_history")])
            admin_stat_list.append(
                ["note_comment",
                 dbutil.count_table("note_comment")])
            admin_stat_list.append(
                ["notebook", dbutil.count_table("notebook")])
            admin_stat_list.append(["message", dbutil.count_table("message")])
            admin_stat_list.append(
                ["schedule", dbutil.count_table("schedule")])
            admin_stat_list.append(["user", dbutil.count_table("user")])

        self.writetemplate(HTML,
                           stat_list=stat_list,
                           admin_stat_list=admin_stat_list)
示例#17
0
def search(ctx, name):
    if not xauth.is_admin():
        return None
    if not ctx.search_tool:
        return
    results = search_plugins(name)
    results += search_scripts(name)
    return results
示例#18
0
文件: scripts.py 项目: dudefu/xnote
def on_search_scripts(ctx):
    if not xauth.is_admin():
        return None
    if not ctx.search_tool:
        return
    if ctx.search_dict:
        return
    name    = ctx.key
    ctx.tools += search_scripts(name)
示例#19
0
def search_menu(files, name):
    for category in xconfig.MENU_LIST:
        if category.need_login and not xauth.has_login():
            continue
        if category.need_admin and not xauth.is_admin():
            continue
        for child in category.children:
            if text_contains(u(child.name), u(name)):
                files.append(Storage(name='菜单 - ' + child.name, url=child.url))
示例#20
0
def check_get_note(id):
    if xauth.is_admin():
        note = NOTE_DAO.get_by_id(id)
    else:
        note = NOTE_DAO.get_by_id_creator(id, xauth.current_name())

    if note is None:
        raise NoteException("404", "笔记不存在")
    return note
示例#21
0
def on_search_scripts(ctx):
    if not xauth.is_admin():
        return None
    if not ctx.search_tool:
        return
    name = ctx.key
    results = search_plugins(name)
    results += search_scripts(name)
    ctx.tools += results
示例#22
0
def search(ctx):
    """搜索Python文档"""
    if not xauth.is_admin():
        return
    name = ctx.groups[0]
    if name in sys.modules:
        item = SearchResult()
        item.name = T("Python Document") + " - %s" % name
        item.url = "/system/document?name=%s" % name
        item.content = ""
        ctx.tools.append(item)
示例#23
0
def search(ctx, name):
    """搜索Python文档"""
    if not xauth.is_admin():
        return
    if name in sys.modules:
        item = SearchResult()
        item.name = "Python Document - %s" % name
        item.url = "/system/document?name=%s" % name
        item.content = ""
        return [item]
    return []
示例#24
0
文件: scripts.py 项目: dudefu/xnote
def on_search_books(ctx):
    if not xauth.is_admin():
        return
    if not ctx.category == "book":
        return
    name = ctx.input_text
    # 图书搜索结果
    bookspath = os.path.join(xconfig.DATA_DIR, "books")
    pathlist = xutils.search_path(bookspath, "*" + name + "*")
    if len(pathlist) > 0:
        url = "/fs_find?path=%s&find_key=%s"%(bookspath,name)
        ctx.tools.append(SearchResult("图书搜索结果(%s) - %s" % (len(pathlist), name), url))
示例#25
0
    def handle(self, input):
        self.rows = 0
        user_name = xauth.current_name()
        stat_list = []
        admin_stat_list = []
        stat_list.append(
            ["我的项目",
             xutils.call("note.count_by_type", user_name, "group")])
        stat_list.append(
            ["我的笔记", dbutil.count_table("note_tiny:%s" % user_name)])
        stat_list.append(
            ["待办事项", dbutil.count_table("message:%s" % user_name)])
        stat_list.append(
            ["搜索记录",
             dbutil.count_table("search_history:%s" % user_name)])
        stat_list.append(
            ["我的评论",
             dbutil.count_table("comment_index:%s" % user_name)])

        if xauth.is_admin():
            table_names = sorted(dbutil.TABLES.keys())
            for name in table_names:
                admin_stat_list.append(
                    [name, dbutil.TABLES[name],
                     dbutil.count_table(name)])

            # admin_stat_list.append(["note_full", dbutil.count_table("note_full")])
            # admin_stat_list.append(["note_tiny", dbutil.count_table("note_tiny")])
            # admin_stat_list.append(["note_index", dbutil.count_table("note_index")])
            # admin_stat_list.append(["note_public", dbutil.count_table("note_public")])
            # admin_stat_list.append(["note_edit_log", dbutil.count_table("note_edit_log")])
            # admin_stat_list.append(["note_visit_log", dbutil.count_table("note_visit_log")])
            # admin_stat_list.append(["note_history", dbutil.count_table("note_history")])
            # admin_stat_list.append(["note_comment", dbutil.count_table("note_comment")])
            # admin_stat_list.append(["comment_index", dbutil.count_table("comment_index")])
            # admin_stat_list.append(["notebook", dbutil.count_table("notebook")])
            # admin_stat_list.append(["search_history", dbutil.count_table("search_history")])
            # admin_stat_list.append(["message",  dbutil.count_table("message")])
            # admin_stat_list.append(["msg_search_history", dbutil.count_table("msg_search_history")])
            # admin_stat_list.append(["msg_history", dbutil.count_table("msg_history")])
            # admin_stat_list.append(["msg_key", dbutil.count_table("msg_key")])
            # admin_stat_list.append(["user_stat", dbutil.count_table("user_stat")])

            # admin_stat_list.append(["schedule", dbutil.count_table("schedule")])
            # admin_stat_list.append(["user", dbutil.count_table("user")])
            # admin_stat_list.append(["record", dbutil.count_table("record")])
            # admin_stat_list.append(["plugin_visit_log", dbutil.count_table("plugin_visit_log")])

        self.writetemplate(HTML,
                           stat_list=stat_list,
                           admin_stat_list=admin_stat_list)
示例#26
0
def search(name):
    if not xauth.is_admin():
        return None
    results = []
    for fname in xutils.listdir(xconfig.SCRIPTS_DIR):
        if name in fname:
            result = xutils.SearchResult()
            result.name = xutils.u("脚本 - ") + fname
            result.raw = xutils.u("搜索到可执行脚本 - ") + fname
            result.url = xutils.u(
                "/system/script_admin?op=edit&name=%s") % fname
            result.command = xutils.u(
                "/system/script_admin/execute?name=%s") % fname
            results.append(result)
    return results
示例#27
0
文件: fs.py 项目: ydx2099/xnote
 def POST(self):
     path = xutils.get_argument("path")
     user_name = xauth.current_name()
     if not xauth.is_admin() and not check_file_auth(path, user_name):
         return dict(code="fail", message="unauthorized")
     try:
         if not os.path.exists(path):
             basename = os.path.basename(path)
             return dict(code="fail", message="源文件`%s`不存在" % basename)
         xutils.remove(path)
         xmanager.fire("fs.remove", Storage(user=user_name, path=path))
         return dict(code="success")
     except Exception as e:
         xutils.print_exc()
         return dict(code="fail", message=str(e))
示例#28
0
 def POST(self):
     content = xutils.get_argument("content", "")
     id = xutils.get_argument("id", "0", type=int)
     name = xauth.get_current_name()
     db = xtables.get_file_table()
     where = None
     if xauth.is_admin():
         where=dict(id=id)
     else:
         where=dict(id=id, creator=name)
     rowcount = db.update(content=content, size=len(content), smtime=xutils.format_datetime(), 
         where=where)
     if rowcount > 0:
         return dict(code="success")
     else:
         return dict(code="fail")
示例#29
0
def search(ctx, name):
    global _api_name_dict
    if not xauth.is_admin():
        return
    results = []
    for task_name in _api_name_dict:
        task_command = _api_name_dict[task_name]
        # task_name = six.u(task_name)
        task_name = xutils.u(task_name)
        # print(name, task_name)
        if name in task_name:
            result = SearchResult()
            result.name = xutils.u("系统接口 - ") + task_name
            result.command = "/api/%s" % task_command
            result.url = result.command
            results.append(result)
    return results
示例#30
0
def search(ctx, delay_mins_str, message):
    if not xauth.is_admin():
        return []

    delay_mins = parse_int(delay_mins_str)
    millis = time.time() + int(delay_mins) * 60
    tm = time.localtime(millis)
    tm_hour = tm.tm_hour
    tm_min = tm.tm_min
    add_alarm(tm_hour, tm_min, message)

    result = SearchResult()
    result.name = "提醒"
    result.raw = "提醒创建成功,将于%s点%s分提醒 %s" % (tm_hour, tm_min, message)
    result.url = "/system/crontab"
    xutils.say(result.raw)
    return [result]