python version 2.6.6 I'm trying to tar/gzip a directory, the directory is defined as an variable
I want to tar and gzip the directory archive in the example below: import tarfile dirarchive = /a/b/c/archive Test 1 tar.add(dirarchive) Error: name 'tar' not defined Test 2 tarfile.add(dirarchive) Error: 'module' object has no attribute add Test 3 archive = tarfile.open(dirachive, "a:gz") archive.add=(dirarchive) archive.close() Error: IOError [Errono 21] Is a directory: /a/b/c/archive Test 4 archive = tarfile.open("test.tgz", "a:gz") archive.add=(dirarchive, arcname="test") archive.close() Create a gzip file called test.tgz in the current directory, which is close but no cigar What I would like is the following gzip file: /a/b/c/archive.tgz _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor