Ejemplo n.º 1
0
Archivo: Task.py Proyecto: Val9/jasy
def runTask(project, task, **kwargs):

    header("Running %s of project %s..." % (task, project))

    import subprocess

    # Pauses this session to allow sub process fully accessing the same projects
    session.pause()

    # Build parameter list from optional arguments
    params = ["--%s=%s" % (key, kwargs[key]) for key in kwargs]
    if not "prefix" in kwargs:
        params.append("--prefix=%s" % getPrefix())

    # Full list of args to pass to subprocess
    args = [__jasyCommand, task] + params

    # Change into sub folder and execute jasy task
    oldPath = os.getcwd()
    remote = session.getProjectByName(project)
    if remote is None:
        raise JasyError("Unknown project %s" % project)

    os.chdir(remote.getPath())
    returnValue = subprocess.call(args, shell=sys.platform == "win32")
    os.chdir(oldPath)

    # Resumes this session after sub process was finished
    session.resume()

    # Error handling
    if returnValue != 0:
        raise JasyError("Executing of sub task %s from project %s failed" % (task, project))
Ejemplo n.º 2
0
Archivo: Task.py Proyecto: zynga/jasy
def runTask(project, task, **kwargs):
    """
    Executes the given task of the given projects. 
    
    This happens inside a new sandboxed session during which the 
    current session is paused/resumed automatically.
    """

    remote = session.getProjectByName(project)
    if remote is not None:
        remotePath = remote.getPath()
        remoteName = remote.getName()
    elif os.path.isdir(project):
        remotePath = project
        remoteName = os.path.basename(project)
    else:
        raise UserError("Unknown project or invalid path: %s" % project)

    Console.info("Running %s of project %s...", Console.colorize(task, "bold"),
                 Console.colorize(remoteName, "bold"))

    # Pauses this session to allow sub process fully accessing the same projects
    session.pause()

    # Build parameter list from optional arguments
    params = ["--%s=%s" % (key, kwargs[key]) for key in kwargs]
    if not "prefix" in kwargs:
        params.append("--prefix=%s" % session.getCurrentPrefix())

    # Full list of args to pass to subprocess
    args = [__command, task] + params

    # Change into sub folder and execute jasy task
    oldPath = os.getcwd()
    os.chdir(remotePath)
    returnValue = subprocess.call(args, shell=sys.platform == "win32")
    os.chdir(oldPath)

    # Resumes this session after sub process was finished
    session.resume()

    # Error handling
    if returnValue != 0:
        raise UserError("Executing of sub task %s from project %s failed" %
                        (task, project))
Ejemplo n.º 3
0
def runTask(project, task, **kwargs):
    """
    Executes the given task of the given projects.

    This happens inside a new sandboxed session during which the current session is paused/resumed automatically.

    """

    remote = session.getProjectByName(project)
    if remote is not None:
        remotePath = remote.getPath()
        remoteName = remote.getName()
    elif os.path.isdir(project):
        remotePath = project
        remoteName = os.path.basename(project)
    else:
        raise UserError("Unknown project or invalid path: %s" % project)

    Console.info("Running %s of project %s...", Console.colorize(task, "bold"), Console.colorize(remoteName, "bold"))

    # Pauses this session to allow sub process fully accessing the same projects
    session.pause()

    # Build parameter list from optional arguments
    params = ["--%s=%s" % (key, kwargs[key]) for key in kwargs]
    if not "prefix" in kwargs:
        params.append("--prefix=%s" % session.getCurrentPrefix())

    # Full list of args to pass to subprocess
    args = [__command, task] + params

    # Change into sub folder and execute jasy task
    oldPath = os.getcwd()
    os.chdir(remotePath)
    returnValue = subprocess.call(args, shell=sys.platform == "win32")
    os.chdir(oldPath)

    # Resumes this session after sub process was finished
    session.resume()

    # Error handling
    if returnValue != 0:
        raise UserError("Executing of sub task %s from project %s failed" % (task, project))
Ejemplo n.º 4
0
def build(regenerate, profile):
	""" Build static website """

	if regenerate:
		session.pause()

	app = Konstrukteur()
	app.config = session.getMain().getConfigValue("konstrukteur")

	app.sitename = session.getMain().getConfigValue("konstrukteur.site.name", "Test website")
	app.siteurl = session.getMain().getConfigValue("konstrukteur.site.url", "//localhost")
	app.posturl = session.getMain().getConfigValue("konstrukteur.blog.postUrl", "{{current.lang}}/blog/{{current.slug}}")
	app.pageurl = session.getMain().getConfigValue("konstrukteur.pageUrl", "{{current.lang}}/{{current.slug}}")
	app.feedurl = session.getMain().getConfigValue("konstrukteur.blog.feedUrl", "feed.{{current.lang}}.xml")
	app.extensions = session.getMain().getConfigValue("konstrukteur.extensions", ["markdown", "html"])
	app.theme = session.getMain().getConfigValue("konstrukteur.theme", session.getMain().getName())
	app.defaultLanguage = session.getMain().getConfigValue("konstrukteur.defaultLanguage", "en")

	app.regenerate = not regenerate == False

	app.build(profile)

	if regenerate:
		session.resume()
Ejemplo n.º 5
0
Archivo: Web.py Proyecto: dadicool/jasy
def serve(routes=None, port=8080, host="127.0.0.1"):
    
    header("HTTP Server")
    
    # We need to pause the session to make room for other jasy executions
    session.pause()

    # Shared configuration (global/app)
    config = {
        "global" : {
            "environment" : "production",
            "log.screen" : False,
            "server.socket_port": port,
            "server.socket_host": host,
            "engine.autoreload_on" : False
        },
        
        "/" : {
            "log.screen" : False
        }
    }
    
    # Update global config
    cherrypy.config.update(config)

    # Somehow this screen disabling does not work
    # This hack to disable all access/error logging works
    def empty(*param, **args): pass
    def inspect(*param, **args): 
        if args["severity"] > 20:
            error("Critical error occoured:")
            error(param[0])
    
    cherrypy.log.access = empty
    cherrypy.log.error = inspect
    cherrypy.log.screen = False

    # Initialize routing
    info("Initialize routing...")
    indent()
    root = Static("/", {})
    if routes:
        for key in routes:
            entry = routes[key]
            if "host" in entry:
                node = Proxy(key, entry)
            else:
                node = Static(key, entry)
            
            setattr(root, key, node)
    outdent()
    
    # Finally start the server
    app = cherrypy.tree.mount(root, "", config)
    cherrypy.process.plugins.PIDFile(cherrypy.engine, "jasylock-http-%s" % port).subscribe()
    
    cherrypy.engine.start()
    info("Started HTTP server at port %s... [PID=%s]", port, os.getpid())
    indent()
    cherrypy.engine.block()

    outdent()
    info("Stopped HTTP server at port %s.", port)
    
    # Resume session to continue work on next task (if given)
    session.resume()