Created
March 6, 2013 08:18
-
-
Save shriphani/5097593 to your computer and use it in GitHub Desktop.
Repackage KBA data (each file is decrypted, decompressed and recompressed with gzip to make it easier to handle)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| We have a bunch of files in the form of social.*.xz.gpg.save | |
| These need to be moved to gzip format. | |
| """ | |
| import argparse | |
| import os | |
| def decrypt(filename): | |
| if filename and not filename.endswith('.gpg.save'): | |
| return None | |
| outfile = filename.replace('.gpg.save', '') | |
| os.system('gpg -o %(outfile)s -d %(filename)s #2> /dev/null' % { 'outfile' : outfile, 'filename' : filename }) | |
| return outfile | |
| def recompress(filename): | |
| if filename and not filename.endswith('.xz'): | |
| return None | |
| outfile = filename.replace('.xz', '.gz') | |
| os.system('/usr/bin/xz -d --stdout %(filename)s | gzip > %(outfile)s' % { 'filename' : filename, 'outfile' : outfile }) | |
| os.system('rm %(filename)s' % { 'filename' : filename }) | |
| return outfile | |
| if __name__ == '__main__': | |
| def parse_cmdline_args(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('files_list', metavar = 'files-list', help = 'list of files we need to decrypt and recompress') | |
| return parser.parse_args() | |
| parsed = parse_cmdline_args() | |
| with open(parsed.files_list, 'r') as files_list_handle: | |
| for new_line in files_list_handle: | |
| filename = new_line.strip() | |
| print recompress(decrypt(filename)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment