def _recurse(self, path): """ Get a list of all specified files """ files = {} empty_dirs = [] try: sub_paths = os.listdir(path) except OSError as exc: if exc.errno == errno.ENOENT: # Path does not exist sys.stderr.write("{} does not exist\n".format(path)) sys.exit(42) elif exc.errno in (errno.EINVAL, errno.ENOTDIR): # Path is a file (EINVAL on Windows, ENOTDIR otherwise) files[path] = self._mode(path) else: if not sub_paths: empty_dirs.append(path) for fn_ in sub_paths: files_, empty_dirs_ = self._recurse(os.path.join(path, fn_)) files.update(files_) empty_dirs.extend(empty_dirs_) return files, empty_dirs
def _list_files(self): files = {} empty_dirs = set() for fn_ in self.opts["src"]: files_, empty_dirs_ = self._recurse(fn_) files.update(files_) empty_dirs.update(empty_dirs_) return files, sorted(empty_dirs)
def _load_files(self): """ Parse the files indicated in opts['src'] and load them into a python object for transport """ files = {} for fn_ in self.opts["src"]: if os.path.isfile(fn_): files.update(self._file_dict(fn_)) elif os.path.isdir(fn_): salt.utils.stringutils.print_cli( "{} is a directory, only files are supported " 'in non-chunked mode. Use "--chunked" command ' "line argument.".format(fn_)) sys.exit(1) return files
def _load_files(self): ''' Parse the files indicated in opts['src'] and load them into a python object for transport ''' files = {} for fn_ in self.opts['src']: if os.path.isfile(fn_): files.update(self._file_dict(fn_)) elif os.path.isdir(fn_): salt.utils.print_cli( fn_ + ' is a directory, only files are supported ' 'in non-chunked mode. Use "--chunked" command ' 'line argument.') sys.exit(1) return files