Exemplo n.º 1
0
		def decorate_file(filename_list):
			  file_list = []
			  for filename in filename_list:
				if not os.path.isfile(filename):
					print "Error:file %s not found or is a directory!" % filename
					sys.exit()
				else:
					file_list.append( filename )
			  print_output('compressing file......', 'success')
			  if len(file_list) >1: 
			  	tar_file = compress.tar(file_list,'temp/%s.tar' % file_list[0] )
			  	compressed_file = '%s.z' % tar_file
			  	compress.compress(tar_file, compressed_file)
				os.remove(tar_file)
			  	return compressed_file,os.path.getsize(compressed_file),'tarAndCompressed'
			  else:
				source_file = file_list[0].split('/')[-1]
				compressed_file = 'temp/%s.z'  % source_file
				compress.compress(file_list[0], compressed_file)
			  	return compressed_file,os.path.getsize(compressed_file),'compressed'
Exemplo n.º 2
0
 def decorate_file(filename_list):
     file_list = []
     for filename in filename_list:
         if not os.path.isfile(filename):
             print "Error:file %s not found or is a directory!" % filename
             sys.exit()
         else:
             file_list.append(filename)
     print_output('compressing file......', 'success')
     if len(file_list) > 1:
         tar_file = compress.tar(file_list,
                                 'temp/%s.tar' % file_list[0])
         compressed_file = '%s.z' % tar_file
         compress.compress(tar_file, compressed_file)
         os.remove(tar_file)
         return compressed_file, os.path.getsize(
             compressed_file), 'tarAndCompressed'
     else:
         source_file = file_list[0].split('/')[-1]
         compressed_file = 'temp/%s.z' % source_file
         compress.compress(file_list[0], compressed_file)
         return compressed_file, os.path.getsize(
             compressed_file), 'compressed'
Exemplo n.º 3
0
Arquivo: pyarch.py Projeto: rubik/arch
parser.add_argument('-x', '--extract', default=None, dest='x')
parser.add_argument('-c', '--compress', default=None, dest='c', nargs='+')
parser.add_argument('-d', '--destination-path', default=None, dest='destination')
parser.add_argument('-v', '--verbose', default=False, action='store_true')
args = parser.parse_args()

D_FUNCS = {'.zip': decompress.zip,
           '.tar': decompress.tar(),
           '.tar.gz': decompress.tar(':gz'),
           '.tar.bz2': decompress.tar(':bz2'),
           '.bz2': decompress.bz2_,
           '.gz': decompress.gz,
          }

C_FUNCS = {'.zip': compress.zip,
           '.tar': compress.tar(),
           '.tar.gz': compress.tar(':gz'),
           '.tar.bz2': compress.tar(':bz2'),
           '.bz2': compress.bz2_,
           '.gz': compress.gz,
          }

verbose = args.verbose
dest = args.destination

if args.x is not None:
    path = args.x
    d1, ext = os.path.splitext(path)
    if dest is None:
        dest = d1
    else: