def find_exec(ignoreT, argT, cmdArg, argA, *n, **kw):
  """
  Walk the command line and first walk over the command line options.

  @param ignoreT: Table of names to ignore.
  @param argT:    Table of command line args. Keys are the name of the argument, values are the number of arguments it takes (> 0).
  @param cmdArg:  command (like in ibrun.symm) that points to a user program.
  @param argA:    The command line split into an array.
  @param kw:      If dot=True then add "." to the end of PATH.
  """
  N   = len(argA)

  if ('dot' in kw):
    os.environ['PATH'] = os.environ.get('PATH',"") + ":."

  i   = 0
  while (i < N):
    arg = argA[i]
    if (arg == cmdArg):
      return which(find_cmd(ignoreT, 0, argA[i+1].split()))
    
    n   = argT.get(arg,-1)
    if (n > 0):
      i += n + 1
      continue
    if (arg[0:1] == "-"):
      i  = i + 1
      continue
    break

  path = which(find_cmd(ignoreT, i, argA)) or "unknown"
  return path
def find_exec(ignoreT, argT, npT, cmdArg, argA, *n, **kw):
    """
  Walk the command line and first walk over the command line options.

  @param ignoreT: Table of names to ignore.
  @param argT:    Table of command line args. Keys are the name of the argument, values are the number of arguments it takes (> 0).
  @param npT:     Options for the number of tasks.
  @param cmdArg:  command (like in ibrun.symm) that points to a user program.
  @param argA:    The command line split into an array.
  @param kw:      If dot=True then add "." to the end of PATH.
  """
    N = len(argA)

    compute_ntasks = kw.get("compute_ntasks", default_compute_ntasks)

    if ('dot' in kw):
        os.environ['PATH'] = os.environ.get('PATH', "") + ":."

    i = 0
    done = False
    resultA = []

    path = None
    while (not done):
        t = {}
        while (i < N):
            arg = argA[i]

            i = parse_ntasks(npT, arg, i, argA, t)

            if (arg == cmdArg):
                path = which(find_cmd(ignoreT, 0, argA[i + 1].split()))
                break

            n = argT.get(arg, -1)
            if (n > 0):
                i += n + 1
                continue
            if (arg[0:1] == "-"):
                i = i + 1
                continue
            break
        if (not path):
            path = which(find_cmd(ignoreT, i, argA)) or "unknown"
        ntasks = compute_ntasks(t)
        uuid = capture("@uuidgen@").rstrip('\n')
        resultA.append({'exec_prog': path, 'ntasks': ntasks, 'uuid': uuid})

        # Loop for colons
        done = True
        while (i < N):
            arg = argA[i]
            i = i + 1
            if (arg == ":"):
                done = False
                path = None
                break

    return json.dumps(resultA)
def find_exec(ignoreT, argT, npT, cmdArg, argA, *n, **kw):
  """
  Walk the command line and first walk over the command line options.

  @param ignoreT: Table of names to ignore.
  @param argT:    Table of command line args. Keys are the name of the argument, values are the number of arguments it takes (> 0).
  @param npT:     Options for the number of tasks.
  @param cmdArg:  command (like in ibrun.symm) that points to a user program.
  @param argA:    The command line split into an array.
  @param kw:      If dot=True then add "." to the end of PATH.
  """
  N   = len(argA)

  compute_ntasks=kw.get("compute_ntasks",default_compute_ntasks)

  if ('dot' in kw):
    os.environ['PATH'] = os.environ.get('PATH',"") + ":."

  i    = 0
  done = False
  resultA = []

  path = None
  while (not done):
    t = {}
    while (i < N):
      arg = argA[i]

      i = parse_ntasks(npT, arg, i, argA, t)

      if (arg == cmdArg):
        path = which(find_cmd(ignoreT, 0, argA[i+1].split()))
        break
      
      n   = argT.get(arg,-1)
      if (n > 0):
        i += n + 1
        continue
      if (arg[0:1] == "-"):
        i  = i + 1
        continue
      break
    if (not path):
      path    = which(find_cmd(ignoreT, i, argA)) or "unknown"
    ntasks  = compute_ntasks(t)
    uuid    = capture("@uuidgen@").rstrip('\n')
    resultA.append({'exec_prog':path, 'ntasks':ntasks, 'uuid': uuid})

    # Loop for colons
    done = True
    while (i < N):
      arg = argA[i]
      i   = i + 1
      if (arg == ":"):
        done = False
        path = None
        break
      
  return json.dumps(resultA)
Beispiel #4
0
  def __init__(self, cmd):
    """
    Find the full path to the executable.  Then find the shared
    libraries if there and get the hash time.

    @param exec_progA: the command line after the mpirun type
    arguments have been removed.
    """

    self.__execType = None
    self.__execName = which(cmd)
    self.__libA     = []
    if (self.__execName):
      outStr = capture(["@file@", self.__execName])
      if (outStr.find("script") > 0 or outStr.find("text") > 0):
        self.__execType = "script"
      else:
        self.__execType = "binary"
        # ldd is a shell script so it must do path resolution!
        os.environ['PATH'] = '/usr/bin:/bin'
        ldd             = capture(["@ldd@", self.__execName])
        self.__libA     = self.__parseLDD(ldd)

      info = os.stat(self.__execName)
      self.__modify = info.st_mtime
      self.__hash   = self.__computeHash(self.__execName)
Beispiel #5
0
    def __init__(self, cmd):
        """
    Find the full path to the executable.  Then find the shared
    libraries if there and get the hash time.

    @param exec_progA: the command line after the mpirun type
    arguments have been removed.
    """

        self.__execType = None
        self.__execName = which(cmd)
        self.__libA = []
        if (self.__execName):
            outStr = capture(["@file@", self.__execName])
            if (outStr.find("script") > 0 or outStr.find("text") > 0):
                self.__execType = "script"
            else:
                self.__execType = "binary"
                # ldd is a shell script so it must do path resolution!
                os.environ['PATH'] = '/usr/bin:/bin'
                ldd = capture(["@ldd@", self.__execName])
                self.__libA = self.__parseLDD(ldd)

            info = os.stat(self.__execName)
            self.__modify = info.st_mtime
            self.__hash = self.__computeHash(self.__execName)
  def __init__(self, exec_progA):

    ignoreT = {
      'env'              : True,
      'time'             : True,
    }
    cmd = None
    for prog in exec_progA:
      bare = os.path.basename(prog)
      if (not (bare in ignoreT)):
        cmd = prog
        break

    self.__execType = None
    self.__execName = which(cmd)
    self.__libA     = []
    if (self.__execName):
      outStr = capture(["file", self.__execName])
      if (outStr.find("script") > 0 or outStr.find("text") > 0):
        self.__execType = "script"
      else:
        self.__execType = "binary"
        ldd             = capture(["ldd", self.__execName])
        self.__libA     = self.__parseLDD(ldd)

      info = os.stat(self.__execName)
      self.__modify = info.st_mtime
      self.__hash   = self.__computeHash(self.__execName)
def find_exec(ignoreT, argT, cmdArg, argA, *n, **kw):
  N   = len(argA)

  if ('dot' in kw):
    os.environ['PATH'] = os.environ['PATH'] + ":."

  i   = 0
  while (i < N):
    arg = argA[i]
    if (arg == cmdArg):
      return which(find_cmd(ignoreT, 0, argA[i+1].split()))
    
    n   = argT.get(arg,-1)
    if (n > 0):
      i += n + 1
      continue
    if (arg[0:1] == "-"):
      i  = i + 1
      continue
    break

  path = which(find_cmd(ignoreT, i, argA)) or "unknown"
  return path
  def __init__(self, cmd):
    """
    Find the full path to the executable.  Then find the shared
    libraries if there and get the hash time.

    @param exec_progA: the command line after the mpirun type
    arguments have been removed.
    """

    self.__execType = None
    self.__execName = which(cmd)
    self.__libA     = []
    if (self.__execName):
      outStr = capture(["file", self.__execName])
      if (outStr.find("script") > 0 or outStr.find("text") > 0):
        self.__execType = "script"
      else:
        self.__execType = "binary"
        ldd             = capture(["ldd", self.__execName])
        self.__libA     = self.__parseLDD(ldd)

      info = os.stat(self.__execName)
      self.__modify = info.st_mtime
      self.__hash   = self.__computeHash(self.__execName)
    def __init__(self, cmd):
        """
    Find the full path to the executable.  Then find the shared
    libraries if there and get the hash time.

    @param exec_progA: the command line after the mpirun type
    arguments have been removed.
    """

        self.__execType = None
        self.__execName = which(cmd)
        self.__libA = []
        if (self.__execName):
            outStr = capture(["file", self.__execName])
            if (outStr.find("script") > 0 or outStr.find("text") > 0):
                self.__execType = "script"
            else:
                self.__execType = "binary"
                ldd = capture(["ldd", self.__execName])
                self.__libA = self.__parseLDD(ldd)

            info = os.stat(self.__execName)
            self.__modify = info.st_mtime
            self.__hash = self.__computeHash(self.__execName)
Beispiel #10
0
  def __init__(self, exec_progA):
    """
    Find the user's executable by walking the command line
    and skipping the executables name in ignoreT.  Then find
    the full path to the executable.  Finally find the shared
    libraries if there and get the hash time.

    @param exec_progA: the command line after the mpirun type
    arguments have been removed.
    """
    ignoreT = {
      'env'              : True,
      'time'             : True,
    }
    cmd = None
    for prog in exec_progA:
      bare = os.path.basename(prog)
      if (not (bare in ignoreT)):
        cmd = prog
        break

    self.__execType = None
    self.__execName = which(cmd)
    self.__libA     = []
    if (self.__execName):
      outStr = capture(["file", self.__execName])
      if (outStr.find("script") > 0 or outStr.find("text") > 0):
        self.__execType = "script"
      else:
        self.__execType = "binary"
        ldd             = capture(["ldd", self.__execName])
        self.__libA     = self.__parseLDD(ldd)

      info = os.stat(self.__execName)
      self.__modify = info.st_mtime
      self.__hash   = self.__computeHash(self.__execName)