Last change
on this file since 6982 was
6642,
checked in by rwilson, 16 years ago
|
Minor(ish) changes to untar tool.
|
File size:
855 bytes
|
Rev | Line | |
---|
[6640] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | '''A program to create tar files from a file or directory.''' |
---|
| 4 | |
---|
| 5 | import sys |
---|
| 6 | import os |
---|
| 7 | from anuga.utilities.system_tools import untar_file |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | # assumed program name - refreshed from command line args |
---|
| 11 | Prog_Name = 'untar_file.py' |
---|
| 12 | |
---|
| 13 | # print usage info. and exit |
---|
| 14 | def usage(): |
---|
[6642] | 15 | print 'usage: %s <tarfile> [<output_directory>]' % Prog_Name |
---|
| 16 | print 'where <tarfile> is the path to the file to untar,' |
---|
| 17 | print ' and <output_directory> is the directory to write the results into.' |
---|
[6640] | 18 | sys.exit(10) |
---|
| 19 | |
---|
| 20 | # get program name |
---|
| 21 | # does this work on Windows? |
---|
| 22 | Prog_Name = os.path.basename(sys.argv[0]) |
---|
| 23 | |
---|
| 24 | # check args |
---|
[6642] | 25 | if len(sys.argv) != 2 and len(sys.argv) != 3: |
---|
[6640] | 26 | usage() |
---|
| 27 | |
---|
| 28 | # create the tarred/compressed file |
---|
[6642] | 29 | if len(sys.argv) == 2: |
---|
| 30 | untar_file(sys.argv[1]) |
---|
| 31 | else: |
---|
| 32 | untar_file(sys.argv[1], sys.argv[2]) |
---|
Note: See
TracBrowser
for help on using the repository browser.