I get the following error….
Traceback (most recent call last):
File "deploycommerce.py", line 56, in <module>
if tarfile.is_tarfile(optfile):
File "/usr/lib/python2.7/tarfile.py", line 2587, in is_tarfile
t = open(name)
File "/usr/lib/python2.7/tarfile.py", line 1658, in open
return func(name, "r", fileobj, **kwargs)
File "/usr/lib/python2.7/tarfile.py", line 1720, in gzopen
fileobj = bltn_open(name, mode + "b")
TypeError: coercing to Unicode: need string or buffer, TarFile found
when I try to fun the following…
optfile = tarfile.open(opt_tar_input,"r:gz")
# ERROR THROWN IN FOLLOWING...
if tarfile.is_tarfile(optfile):
# extract all contents
test =""
thanks guys
tarfile.is_tarfiletakes the name of a file, not the file object.If you’ve successfully called
tarfile.openthen the path pointed to a tarfile.Note that the usual Python coding style would be
This is usually summarised in the slogan “it’s easier to ask forgiveness than permission“.