Ejemplo n.º 1
0
    # Mount our config object
    cherrypy.app = appConfig
    # and apply global config back to cherrypy
    cherrypy.config.update(appConfig.get("cherrypy", {}))

    if "--build-only" in sys.argv:
        # Build and exit
        if not tryBuild():
            print("Up to date")
        sys.exit(0)
    elif "--build" in sys.argv:
        # Do we need to compile?
        if not tryBuild():
            cherrypy.log("Build skipped - up to date")

    root = MainRoot()
    # Disable caching - if we don't, then between built and development
    # versions the web browser won't re-send requests.  Note that we could
    # also come up with a scheme where the URL changes when the version
    # changes.
    root._cp_config = {"response.headers.Cache-Control": "No-Cache"}

    if "--build" in sys.argv:
        # Running compiled version, redirect src to built version
        cherrypy.log("Using build/ rather than webapp/")
        root.src = StaticServer(_DIR + "/build")
    else:
        # Add the lib dir, rewrite src/require.js to lib/require.js
        root.lib = StaticServer(_DIR + "/../jsProject/lib")

        def serveRequire():
Ejemplo n.º 2
0
    # Mount our config object
    cherrypy.app = appConfig
    # and apply global config back to cherrypy
    cherrypy.config.update(appConfig.get('cherrypy', {}))

    if '--build-only' in sys.argv:
        # Build and exit
        if not tryBuild():
            print("Up to date")
        sys.exit(0)
    elif '--build' in sys.argv:
        # Do we need to compile?
        if not tryBuild():
            cherrypy.log("Build skipped - up to date")

    root = MainRoot()
    # Disable caching - if we don't, then between built and development
    # versions the web browser won't re-send requests.  Note that we could
    # also come up with a scheme where the URL changes when the version
    # changes.
    root._cp_config = { 'response.headers.Cache-Control': 'No-Cache' }

    if '--build' in sys.argv:
        # Running compiled version, redirect src to built version
        cherrypy.log("Using build/ rather than webapp/")
        root.src = StaticServer(_DIR + '/build')
    else:
        # Add the lib dir, rewrite src/require.js to lib/require.js
        root.lib = StaticServer(_DIR + '/../jsProject/lib')
        def serveRequire():
            return cherrypy.lib.static.serve_file(
    def test_auditActivities(self):
        config = Config()
        config.merge(self.APP_INI)
        config["source"] = dict(type = "graphite")

        cherrypy.app = config
        mr = MainRoot()

        a = mr._activityStorage
        for d in a.find():
            a.delete(d['_id'])

        now = datetime.datetime.utcnow()
        then = now - datetime.timedelta(days = 7.1)
        a.save({ '_id': '10', 'ts': mr.tsFormat(then) })
        a.save({ '_id': '11', 'ts': mr.tsFormat(now) })

        mr._auditActivities()
        remaining = list(a.find())
        self.assertEqual(1, len(remaining))
        self.assertEqual('11', remaining[0]['_id'])

        # Add another and make sure audit doesn't happen because delay hasn't
        # occurred yet.

        a.save({ '_id': '12', 'ts': mr.tsFormat(then) })
        mr._auditActivities()
        remaining = list(a.find())
        self.assertEqual(2, len(remaining))

        mr.AUDIT_INTERVAL = 0.0
        mr._auditActivities()
        remaining = list(a.find())
        self.assertEqual(1, len(remaining))