Last active
April 29, 2016 07:47
-
-
Save cedricvidal/824e8e409e2dfe5daacec3411c29ed82 to your computer and use it in GitHub Desktop.
Command line idempotent python script which uses a Sqlite LSM key value store as idempotent store
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
| #!/usr/bin/env python | |
| from lsm import LSM | |
| import argparse | |
| import time | |
| import sys | |
| parser = argparse.ArgumentParser(description='Idempotent') | |
| parser.add_argument('store', type=str, | |
| help='path of the LSM database to use as idempotent store') | |
| parser.add_argument('--save', type=bool, default=False, | |
| help='save line in store') | |
| args = parser.parse_args() | |
| progressDb = LSM(args.store) | |
| for line in sys.stdin: | |
| finished = line in progressDb | |
| if(not finished): | |
| sys.stdout.write(line) | |
| if(args.save): | |
| progressDb[line] = str(int(time.time() * 1000)) |
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
| lsm-db |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment