-
Notifications
You must be signed in to change notification settings - Fork 5
/
uncompress.py
47 lines (28 loc) · 937 Bytes
/
uncompress.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import sys
import os
import os.path
class Uncompresser(object):
def __init__(self,DEBUG=False):
self.DEBUG = DEBUG
if self.DEBUG:
print "Uncompresser() init successfull."
def uncompress(self,imagename):
if os.path.isfile("./{0}/{0}_B1.TIF".format(imagename)):
if self.DEBUG:
print "Archive already uncompressed, skipping."
return
cmd = "mkdir {0}; tar -zxvf {0}.tar.gz -C ./{0}".format(imagename)
if self.DEBUG:
print "Uncompressing image archive ..."
os.system(cmd)
if self.DEBUG:
print "Done."
if __name__ == '__main__':
if len(sys.argv) != 2:
print "Usage:\n\tpython uncompress.py <imagename>"
else:
imagename = sys.argv[1]
print "Uncompressing archive ..."
u = Uncompresser()
u.uncompress(imagename)
print "All Done."