Skip to content

Instantly share code, notes, and snippets.

@cedricvidal
Last active April 29, 2016 07:47
Show Gist options
  • Select an option

  • Save cedricvidal/824e8e409e2dfe5daacec3411c29ed82 to your computer and use it in GitHub Desktop.

Select an option

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
#!/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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment