def get(url, dest): """Get file from <url> and save it to <dest>. Tries to retrieve <url> from cache, otherwise stores it in cache following retrieval. """ url = urllib.unquote(url) if url.endswith("/"): raise Error("illegal url - can't get a directory") if os.path.isdir(dest): dest = os.path.join(dest, os.path.basename(url)) else: if dest.endswith("/"): raise Error("no such directory: " + dest) if os.path.lexists(dest): raise Error("won't overwrite already existing file: " + dest) cache = Cache() cached_path = cache.retrieve(url, dest) if cached_path: print "* get: retrieved file from cache" else: print "* get: retrieving file from network..." system("curl -L -f %s -o %s" % (mkarg(url), mkarg(dest))) cached_path = cache.store(url, dest) return cached_path
def apply_overlay(src, dst, olist_path): orig_cwd = os.getcwd() os.chdir(src) executil.getoutput("tar --create --files-from=%s | tar --extract --directory %s" % (olist_path, executil.mkarg(dst))) os.chdir(orig_cwd)
def _prepare_command(self, *command): env = ['env', '-i'] + [ executil.mkarg(name + "=" + val) for name, val in self.environ.items() ] command = executil.fmt_command(*command) return ("chroot", self.path, 'sh', '-c', " ".join(env) + " " + command)
def apply_overlay(src, dst, olist_path): orig_cwd = os.getcwd() os.chdir(src) executil.getoutput( "tar --create --files-from=%s | tar --extract --directory %s" % (olist_path, executil.mkarg(dst))) os.chdir(orig_cwd)
def _prepare_command(self, *command): env = ['env', '-i' ] + [ executil.mkarg(name + "=" + val) for name, val in self.environ.items() ] command = executil.fmt_command(*command) return ("chroot", self.path, 'sh', '-c', " ".join(env) + " " + command)