예제 #1
0
     output_path = os.path.join(output_dir, img_name)
 if args.logpath:
     log_to_file = True
     log_file = args.logpath
 else:
     log_to_file = None
     log_file = None
 if args.block_size:
     block_size = args.block_size
 else:
     block_size = get_peb_size(path)
 perms = args.permissions
 quiet = args.quiet
 if not os.path.exists(output_path):
     os.makedirs(output_path)
 ufile = ubi_file(path, block_size)
 uubi = ubi(ufile)
 for image in uubi.images:
     for volume in image.volumes:
         vol_out_path = os.path.join(output_path, volume)
         if not os.path.exists(vol_out_path):
             os.makedirs(vol_out_path)
         elif os.listdir(vol_out_path):
             parser.error('Volume output directory is not empty. %s' %
                          vol_out_path)
         ufsfile = leb_virtual_file(uubi, image.volumes[volume])
         uubifs = ubifs(ufsfile)
         uubifs.log.log_file = log_file
         uubifs.log.log_to_file = log_to_file
         uubifs.log.quiet = quiet
         print 'Wait almost over ...\nLoading the image to: %s' % vol_out_path
     output_path = os.path.join(output_dir, img_name)
 if args.logpath:
     log_to_file = True
     log_file = args.logpath
 else:
     log_to_file = None
     log_file = None
 if args.block_size:
     block_size = args.block_size
 else:
     block_size = get_peb_size(path)
 perms = args.permissions
 quiet = args.quiet
 if not os.path.exists(output_path):
     os.makedirs(output_path)
 ufile = ubi_file(path, block_size)
 uubi = ubi(ufile)
 for image in uubi.images:
     for volume in image.volumes:
         vol_out_path = os.path.join(output_path, volume)
         if not os.path.exists(vol_out_path):
             os.makedirs(vol_out_path)
         elif os.listdir(vol_out_path):
             parser.error('Volume output directory is not empty. %s' % vol_out_path)
         ufsfile = leb_virtual_file(uubi, image.volumes[volume])
         uubifs = ubifs(ufsfile)
         uubifs.log.log_file = log_file
         uubifs.log.log_to_file = log_to_file
         uubifs.log.quiet = quiet
         print 'Writing to: %s' % vol_out_path
         extract_files(uubifs, vol_out_path, perms)