(self, host_src_dir, cont_dst_dir, files_list, force=False)
return True
copy or link file to destination creating directories as needed
copy or link file to destination creating directories as needed
copy or link file to destination creating directories as needed
def _copy_files(self, host_src_dir, cont_dst_dir, files_list, force=False):
        """copy or link file to destination creating directories as needed"""
        Msg().out("Source (host) dir ", host_src_dir, l=Msg.DBG)
        Msg().out("Destination (container) dir ", cont_dst_dir, l=Msg.DBG)
        for fname in files_list:
            srcname = host_src_dir + '/' + fname
            dstname = self.container_root + '/' + cont_dst_dir + '/' + fname
            if os.path.isfile(dstname) or os.path.islink(dstname):
                if force:
                    try:
                        os.remove(dstname)
                    except OSError:
                        Msg().err("Error: deleting nvidia file", dstname)
                else:
                    Msg().out("Info: nvidia file already exists", dstname,
                              ", use --force to overwrite", l=Msg.INF)
                    return False

            srcdir = os.path.dirname(srcname)
            dstdir = os.path.dirname(dstname)
            if not os.path.isdir(dstdir):
                try:
                    os.makedirs(dstdir)
                    os.chmod(dstdir, stat.S_IMODE(os.stat(srcdir).st_mode) |
                             stat.S_IRWXU)
                except OSError:
                    Msg().err("Error: creating nvidia dir", dstdir)

            if os.path.islink(srcname):
                linkto = os.readlink(srcname)
                os.symlink(linkto, dstname)
                Msg().out("Info: is link", srcname, "to", dstname, l=Msg.DBG)
            elif os.path.isfile(srcname):
                shutil.copy2(srcname, dstname)
                Msg().out("Info: is file", srcname, "to", dstname, l=Msg.DBG)
                try:
                    mask = stat.S_IMODE(os.stat(srcname).st_mode) | \
                                        stat.S_IWUSR | stat.S_IRUSR
                    if os.access(srcname, os.X_OK):
                        mask = mask | stat.S_IXUSR
                    os.chmod(dstname, mask)
                except (IOError, OSError) as error:
                    Msg().err("Error: change mask of nvidia file", error)
            else:
                Msg().err("Warn: nvidia file in config not found", srcname)

        Msg().out("Info: nvidia copied", srcname, "to", dstname, l=Msg.DBG)
        return True
def _copy_files ( self , host_src_dir , cont_dst_dir , files_list , force = False ) : Msg ( ) . out ( "Source (host) dir " , host_src_dir , l = Msg . DBG ) Msg ( ) . out ( "Destination (container) dir " , cont_dst_dir , l = Msg . DBG ) for fname in files_list : srcname = host_src_dir + '/' + fname dstname = self . container_root + '/' + cont_dst_dir + '/' + fname if os . path . isfile ( dstname ) or os . path . islink ( dstname ) : if force : try : os . remove ( dstname ) except OSError : Msg ( ) . err ( "Error: deleting nvidia file" , dstname ) else : Msg ( ) . out ( "Info: nvidia file already exists" , dstname , ", use --force to overwrite" , l = Msg . INF ) return False srcdir = os . path . dirname ( srcname ) dstdir = os . path . dirname ( dstname ) if not os . path . isdir ( dstdir ) : try : os . makedirs ( dstdir ) os . chmod ( dstdir , stat . S_IMODE ( os . stat ( srcdir ) . st_mode ) | stat . S_IRWXU ) except OSError : Msg ( ) . err ( "Error: creating nvidia dir" , dstdir ) if os . path . islink ( srcname ) : linkto = os . readlink ( srcname ) os . symlink ( linkto , dstname ) Msg ( ) . out ( "Info: is link" , srcname , "to" , dstname , l = Msg . DBG ) elif os . path . isfile ( srcname ) : shutil . copy2 ( srcname , dstname ) Msg ( ) . out ( "Info: is file" , srcname , "to" , dstname , l = Msg . DBG ) try : mask = stat . S_IMODE ( os . stat ( srcname ) . st_mode ) | stat . S_IWUSR | stat . S_IRUSR if os . access ( srcname , os . X_OK ) : mask = mask | stat . S_IXUSR os . chmod ( dstname , mask ) except ( IOError , OSError ) as error : Msg ( ) . err ( "Error: change mask of nvidia file" , error ) else : Msg ( ) . err ( "Warn: nvidia file in config not found" , srcname ) Msg ( ) . out ( "Info: nvidia copied" , srcname , "to" , dstname , l = Msg . DBG ) return True