def tar_file():
#create file path.
file_path = '/tmp/' + image_name
if False == os.path.exists(file_path):
print 'Error, file dir %s not exist'% file_path
full_name = '/tmp/'+image_name+'.tar'
tar_file = tarfile.open(full_name,'w')
for root,dirs,files in os.walk(file_path):
for file in files:
fullpath = os.path.join(root,file)
tar_file.add(fullpath,arcname = file)
tar_file.close()
if False == os.path.isfile(full_name):
print 'Error, tar failed'
评论列表
文章目录