Example #1
0
 def set_cur_path(self, full_path):
   split = self.assign_mgr.ami_path_split_volume(full_path)
   if split == None:
     raise ValueError("set_cur_path needs a path with device name!")
   self.cur_vol = split[0]
   self.cur_path = split[1]
   log_path.info("set current: dev='%s' path='%s'" % (self.cur_vol, self.cur_path))
Example #2
0
 def set_cur_path(self, full_path):
   split = self.assign_mgr.ami_path_split_volume(full_path)
   if split == None:
     raise ValueError("set_cur_path needs a path with device name!")
   self.cur_vol = split[0]
   self.cur_path = split[1]
   log_path.info("set current: dev='%s' path='%s'" % (self.cur_vol, self.cur_path))
Example #3
0
 def ami_command_to_sys_path(self, 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(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(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
Example #4
0
 def ami_command_to_sys_path(self, 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(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(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
Example #5
0
 def _config_done(self):    
   # set current device and path name
   cur_sys = os.getcwd()
   cur_ami = self.vol_mgr.sys_to_ami_path_pair(cur_sys)
   if cur_ami == None:
     raise VamosConfigError("Can't map current directory to amiga path: '%s'" % cur_sys)
   self.cur_vol  = cur_ami[0]
   self.cur_path = cur_ami[1]
   self.org_cur_vol = cur_ami[0]
   self.org_cur_path = cur_ami[1]
   log_path.info("current amiga dir: '%s:%s'" % (self.cur_vol, self.cur_path))
   # ensure path
   if len(self.paths)==0:
     self.paths = ['.','c:']
   log_path.info("path: %s" % map(str, self.paths))
Example #6
0
 def _config_done(self):    
   # set current device and path name
   cur_sys = os.getcwd()
   cur_ami = self.vol_mgr.sys_to_ami_path_pair(cur_sys)
   if cur_ami == None:
     raise VamosConfigError("Can't map current directory to amiga path: '%s'" % cur_sys)
   self.cur_vol  = cur_ami[0]
   self.cur_path = cur_ami[1]
   self.org_cur_vol = cur_ami[0]
   self.org_cur_path = cur_ami[1]
   log_path.info("current amiga dir: '%s:%s'" % (self.cur_vol, self.cur_path))
   # ensure path
   if len(self.paths)==0:
     self.paths = ['.','c:']
   log_path.info("path: %s" % map(str, self.paths))
Example #7
0
 def ami_to_sys_path(self, ami_path, searchMulti=False, mustExist=False):
   # first get an absolute amiga path
   abs_path = self.ami_abs_path(ami_path)
   # replace assigns
   norm_paths = self.assign_mgr.ami_path_resolve(abs_path)
   if len(norm_paths) == 0:
     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
Example #8
0
 def ami_to_sys_path(self, ami_path, searchMulti=False, mustExist=False):
   # first get an absolute amiga path
   abs_path = self.ami_abs_path(ami_path)
   # replace assigns
   norm_paths = self.assign_mgr.ami_path_resolve(abs_path)
   if len(norm_paths) == 0:
     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
Example #9
0
 def set_default_cur_path(self):
   self.cur_vol  = self.org_cur_vol
   self.cur_path = self.org_cur_path
   log_path.info("reset current: dev='%s' path='%s'" % (self.cur_vol, self.cur_path))
Example #10
0
 def sys_to_ami_path(self, sys_path):
   abs_path = os.path.abspath(sys_path)
   ami_path = self.vol_mgr.sys_to_ami_path(abs_path)
   log_path.info("sys_to_ami_path: sys_path='%s' -> abs_path='%s' -> ami_path='%s'" % (sys_path, abs_path, ami_path))
   return ami_path
Example #11
0
 def set_default_cur_path(self):
   self.cur_vol  = self.org_cur_vol
   self.cur_path = self.org_cur_path
   log_path.info("reset current: dev='%s' path='%s'" % (self.cur_vol, self.cur_path))
Example #12
0
 def sys_to_ami_path(self, sys_path):
   abs_path = os.path.abspath(sys_path)
   ami_path = self.vol_mgr.sys_to_ami_path(abs_path)
   log_path.info("sys_to_ami_path: sys_path='%s' -> abs_path='%s' -> ami_path='%s'" % (sys_path, abs_path, ami_path))
   return ami_path