Example #1
0
def is_running():
    """Return True if dmtcp_command reports RUNNING as 'yes'."""
    cmd = ["dmtcp_command", "s"]
    output = fredutil.execute_shell_command(cmd)
    if output != None:
        m = re.search("RUNNING=(\w+)", output, re.MULTILINE)
        if m != None:
            running = m.group(1)
            return running == "yes"
        else:
            return False
    else:
        fredutil.fred_error("ERROR: Can't get RUNNING. " "Did the coordinator die?")
        return False
Example #2
0
def is_running():
    """Return True if dmtcp_command reports RUNNING as 'yes'."""
    cmd = ["dmtcp_command", "s"]
    output = fredutil.execute_shell_command(cmd)
    if output != None:
        m = re.search('RUNNING=(\w+)', output, re.MULTILINE)
        if m != None:
            running = m.group(1)
            return running == 'yes'
        else:
            return False
    else:
        fredutil.fred_error("ERROR: Can't get RUNNING. "
                            "Did the coordinator die?")
        return False
Example #3
0
def get_num_peers():
    """Return NUM_PEERS from 'dmtcp_command s' as an integer."""
    cmd = ["dmtcp_command", "s"]
    output = fredutil.execute_shell_command(cmd)
    if output != None:
        exp = "^NUM_PEERS=(\d+)"
        m = re.search(exp, output, re.MULTILINE)
        if m != None:
            n_peers = m.group(1)
            return int(n_peers)
        else:
            if output == "":
                fredutil.fred_error("Output was NULL string")
            return 0  # Heuristically guessing 0 peers, could be a problem
    else:
        fredutil.fred_error("ERROR: Can't get NUM_PEERS. " "Did the coordinator die?")
        return 0
Example #4
0
def get_num_peers():
    """Return NUM_PEERS from 'dmtcp_command s' as an integer."""
    cmd = ['dmtcp_command', 's']
    output = fredutil.execute_shell_command(cmd)
    if output != None:
        exp = '^NUM_PEERS=(\d+)'
        m = re.search(exp, output, re.MULTILINE)
        if m != None:
            n_peers = m.group(1)
            return int(n_peers)
        else:
            if output == "":
                fredutil.fred_error("Output was NULL string")
            return 0  # Heuristically guessing 0 peers, could be a problem
    else:
        fredutil.fred_error("ERROR: Can't get NUM_PEERS. "
                            "Did the coordinator die?")
        return 0
Example #5
0
def _execute_fred_command(s_cmd, s_arg=None):
    """Execute the given fred_command command and return its output."""
    global g_child_subprocess
    fredutil.fred_assert(s_cmd in ["status", "info", "break", "continue"])
    l_cmd = ["%s/fred_command" % GS_FREDHIJACK_PATH]
    fredutil.fred_assert(get_pid() != -1)
    s_path = "%s/fred-shm.%d" % (os.environ["DMTCP_TMPDIR"], get_pid())
    l_cmd.append("--%s" % s_cmd)
    if s_arg != None:
        l_cmd.append(s_arg)
    l_cmd.append(s_path)
    fredutil.fred_debug("Executing fred_command: %s" % l_cmd)
    if s_cmd == "break":
        fredutil.fred_assert(g_child_subprocess == None)
        g_child_subprocess = fredutil.execute_background_shell_command(l_cmd)
        s_output = ""
    else:
        s_output = fredutil.execute_shell_command(l_cmd)
    return s_output
Example #6
0
def _execute_fred_command(s_cmd, s_arg=None):
    """Execute the given fred_command command and return its output."""
    global g_child_subprocess
    fredutil.fred_assert(s_cmd in ["status", "info", "break", "continue"])
    l_cmd = ["%s/fred_command" % GS_FREDHIJACK_PATH]
    fredutil.fred_assert(get_virtual_inferior_pid() != -1)
    s_path = "%s/fred-shm.%d" % (os.environ["DMTCP_TMPDIR"],
                                 get_virtual_inferior_pid())
    l_cmd.append("--%s" % s_cmd)
    if s_arg != None:
        l_cmd.append(s_arg)
    l_cmd.append(s_path)
    fredutil.fred_debug("Executing fred_command: %s" % l_cmd)
    if s_cmd == "break":
        fredutil.fred_assert(g_child_subprocess == None)
        g_child_subprocess = fredutil.execute_background_shell_command(l_cmd)
        s_output = ""
    else:
        s_output = fredutil.execute_shell_command(l_cmd)
    return s_output