Beispiel #1
0
def log_plugin_visit(name):
    try:
        fname = xutils.unquote(name)
        cacheutil.zadd("plugins.history", time.time(), fname)
    except TypeError:
        cacheutil.delete("plugins.history")
        cacheutil.zadd("plugins.history", time.time(), fname)
Beispiel #2
0
 def GET(self, name=""):
     display_name = xutils.unquote(name)
     name = xutils.get_real_path(display_name)
     if not name.endswith(".py"):
         name += ".py"
     script_name = "plugins/" + name
     if not os.path.exists(os.path.join(xconfig.PLUGINS_DIR, name)):
         error = "file `%s` not found" % script_name
         return xtemplate.render("error.html", error=error)
     try:
         try:
             cacheutil.zadd("plugins.history", time.time(),
                            os.path.splitext(display_name)[0])
         except TypeError:
             cacheutil.delete("plugins.history")
             cacheutil.zadd("plugins.history", time.time(),
                            os.path.splitext(display_name)[0])
         vars = dict()
         vars["script_name"] = script_name
         xutils.load_script(script_name, vars)
         main_class = vars.get("Main")
         if main_class != None:
             return main_class().render()
         else:
             return xtemplate.render("error.html",
                                     error="class `Main` not found!")
     except:
         error = xutils.print_exc()
         return xtemplate.render("error.html", error=error)