Example #1
0
 def handle_appconfig(session, querydict):
     statuscode, mimetype, body = 200, "text/json", "{}"
     if querydict.has_key("type") and len(querydict["type"]) > 0:
         p = os.path.join(module_path(), "app_configs", "configs", "%s.json" % querydict["type"])
         if os.path.exists(p):
             with open(p, "r") as f:
                 f1 = gevent.fileobject.FileObjectThread(f, "r")
                 body = f1.read()
     return statuscode, mimetype, body
Example #2
0
    def handle_patches(session, querydict):
        # statuscode, mimetype, body = 200, 'application/octet-stream',  ''
        statuscode, mimetype, body = 200, "application/zip", ""
        patchdir = os.path.join(module_path(), "app_configs", "patches")

        files = filter(os.path.isfile, glob.glob(os.path.join(patchdir, "*.zip")))
        files.sort(key=lambda x: os.path.getmtime(x))
        files.reverse()
        if len(files) > 0:
            p = files[0]
            if os.path.exists(p):
                with open(p, "rb") as f:
                    f1 = gevent.fileobject.FileObjectThread(f, "rb")
                    body = f1.read()
        return statuscode, mimetype, body