Esempio n. 1
0
File: shell.py Progetto: kd0kfo/dag
def perform_operation(root_dag, message):
    """
    Parses a messages from a child process and acts on the request,
    generally calling update.modify_dag. Returns a string reply to
    that may be sent to the client.

    @param root_dag: Main DAG object
    @type root_dag: dag.DAG
    @param message: Message sent from client to master
    @type message: str
    @return: Message to be sent to the client
    @rtype: str
    """
    from dag.update_dag import modify_dag
    if not message:
        return
    tokens = message.content.split(" ")
    cmd = tokens[0]
    cmd_args = tokens[1:]

    # Forbidden processes
    if cmd in ["start"]:
        return "Shell command line client cannot run %s" % cmd

    L.debug("Shell Monitor is running %s" % cmd)
    try:
        retval = modify_dag(root_dag, cmd, cmd_args, True)
        root_dag.save()
        return retval
    except Exception as e:
        import traceback
        return "Error running %s: %s\n%s" % (cmd, e, traceback.format_exc())
Esempio n. 2
0
File: shell.py Progetto: kd0kfo/dag
def dump_state(root_dag, message_queue):
    """
    Returns information on the state of the running processes.

    @return: State information for the shell processes
    @rtype: str
    """
    from dag.update_dag import modify_dag
    retval = "Currently running %d processes\n" % len(running_children)
    retval += "Jobs by state:\n%s\n" % modify_dag(root_dag, "state",
                                                  ["all", "--count"], False)
    return retval