I’m trying to create a tar archive from a bunch of files which I’ve got stored in a Python list named archive_list. At the point when this code runs, archive_files contains a list of files to be archived with their full paths.
tarname = tar_path + "/" + client_id + "_" + dt.datetime.now().strftime("%Y%m%d_%H%M%S") + ".tar.gz"
tar = tarfile.open (tarname, "w:gz")
for name in archive_list:
print "Adding %s" % (name)
tar.add(name)
tar.close
When I run this, it creates an archive, but it is unreadable. I’ve searched around but can’t see what’s wrong with this code.
One problem is that you’re missing parentheses after
close: