Beispiel #1
0
  def ami_command_to_sys_path(self, lock, ami_path):
    """lookup a command on path if it does not contain a relative or absolute path
       otherwise perform normal 'ami_to_sys_path' conversion"""
    sys_path = None
    # is not a command only
    if ami_path.find(':') != -1 or ami_path.find('/') != -1:
      check_path = self.ami_to_sys_path(lock, ami_path)
      # make sure its a file
      if check_path != None and os.path.isfile(check_path):
        sys_path = check_path
    else:
      # try all path
      for path in self.paths:
        # special case: current dir
        if path == '.':
          try_ami_path = ami_path
        else:
          try_ami_path = path + ami_path
        check_path = self.ami_to_sys_path(lock, try_ami_path, mustExist=True)
        log_path.info("ami_command_to_sys_path: try_ami_path='%s' -> sys_path='%s'" % (try_ami_path, check_path))
        # make sure its a file
        if check_path != None and os.path.isfile(check_path):
          sys_path = check_path
          break

    if sys_path != None:
      log_path.info("ami_command_to_sys_path: ami_path=%s -> sys_path=%s" % (ami_path, sys_path))
      return sys_path
    else:
      log_path.warn("ami_command_to_sys_path: ami_path='%s' not found!" % (ami_path))
      return None
Beispiel #2
0
 def ami_to_sys_path(self,
                     lock,
                     ami_path,
                     searchMulti=False,
                     mustExist=False):
     # first get an absolute amiga path
     abs_path = self.ami_abs_path(lock, ami_path)
     # replace assigns
     norm_paths = self.assign_mgr.ami_path_resolve(abs_path)
     if len(norm_paths) == 0 or ami_path == "*":
         log_path.warn(
             "ami_to_sys_path: ami_path='%s' -> abs_path='%s' -> no resolved paths!"
             % (ami_path, abs_path))
         return None
     # now we have paths with volume:abs/path
     sys_path = None
     # search for existing multi assign
     if searchMulti or mustExist:
         for npath in norm_paths:
             # first try to find existing path in all locations
             spath = self.vol_mgr.ami_to_sys_path(npath, mustExist=True)
             if spath != None:
                 sys_path = spath
                 break
     # nothing found -> try first path
     if sys_path == None and not mustExist:
         sys_path = self.vol_mgr.ami_to_sys_path(norm_paths[0],
                                                 mustExist=False)
     log_path.info(
         "ami_to_sys_path: ami_path='%s' -> abs_path='%s' -> norm_path='%s' -> sys_path='%s'"
         % (ami_path, abs_path, norm_paths, sys_path))
     return sys_path
Beispiel #3
0
 def ami_to_sys_path(self, lock, ami_path, searchMulti=False, mustExist=False):
     # first get an absolute amiga path
     abs_path = self.ami_abs_path(lock, ami_path)
     # replace assigns
     norm_paths = self.assign_mgr.ami_path_resolve(abs_path)
     if len(norm_paths) == 0 or ami_path == "*":
         log_path.warn(
             "ami_to_sys_path: ami_path='%s' -> abs_path='%s' -> no resolved paths!" % (ami_path, abs_path)
         )
         return None
     # now we have paths with volume:abs/path
     sys_path = None
     # search for existing multi assign
     if searchMulti or mustExist:
         for npath in norm_paths:
             # first try to find existing path in all locations
             spath = self.vol_mgr.ami_to_sys_path(npath, mustExist=True)
             if spath != None:
                 sys_path = spath
                 break
     # nothing found -> try first path
     if sys_path == None and not mustExist:
         sys_path = self.vol_mgr.ami_to_sys_path(norm_paths[0], mustExist=False)
     log_path.info(
         "ami_to_sys_path: ami_path='%s' -> abs_path='%s' -> norm_path='%s' -> sys_path='%s'"
         % (ami_path, abs_path, norm_paths, sys_path)
     )
     return sys_path
Beispiel #4
0
    def ami_command_to_sys_path(self, lock, ami_path):
        """lookup a command on path if it does not contain a relative or absolute path
       otherwise perform normal 'ami_to_sys_path' conversion"""
        sys_path = None
        # is not a command only
        if ami_path.find(':') != -1 or ami_path.find('/') != -1:
            check_path = self.ami_to_sys_path(lock, ami_path)
            # make sure its a file
            if check_path != None and os.path.isfile(check_path):
                sys_path = check_path
        else:
            # try all path
            for path in self.paths:
                # special case: current dir
                if path == '.':
                    try_ami_path = ami_path
                else:
                    try_ami_path = path + ami_path
                check_path = self.ami_to_sys_path(lock,
                                                  try_ami_path,
                                                  mustExist=True)
                log_path.info(
                    "ami_command_to_sys_path: try_ami_path='%s' -> sys_path='%s'"
                    % (try_ami_path, check_path))
                # make sure its a file
                if check_path != None and os.path.isfile(check_path):
                    sys_path = check_path
                    break

        if sys_path != None:
            log_path.info(
                "ami_command_to_sys_path: ami_path=%s -> sys_path=%s" %
                (ami_path, sys_path))
            return sys_path
        else:
            log_path.warn("ami_command_to_sys_path: ami_path='%s' not found!" %
                          (ami_path))
            return None