Skip to content

Instantly share code, notes, and snippets.

@cheungpat
Created April 19, 2014 21:33
Show Gist options
  • Save cheungpat/11098136 to your computer and use it in GitHub Desktop.
Save cheungpat/11098136 to your computer and use it in GitHub Desktop.
Pass mount options to yas3fs
#!/usr/bin/python¬
¬
import argparse¬
import subprocess¬
¬
if __name__ == '__main__':¬
parser = argparse.ArgumentParser()¬
parser.add_argument('-o', dest='options')¬
parser.add_argument('s3path')¬
parser.add_argument('localpath')¬
¬
args = parser.parse_args()¬
¬
options = args.options.split(',') if args.options else []¬
¬
accepted = [¬
'h', 'region', 'topic', 'new-queue', 'queue', 'queue-wait', 'queue-polling',¬
'hostname', 'use-ec2-hostname', 'port', 'cache-entries', 'cache-mem-size',¬
'cache-disk-size', 'cache-path', 'cache-on-disk', 'cache-check',¬
'download-num', 'prefetch-num', 'buffer-size', 'buffer-prefetch',¬
'no-metadata', 'prefetch', 'mp-size', 'mp-num', 'mp-retries', 'id', 'mkdir',¬
'uid', 'gid', 'umask', 'l', 'f', 'd', 'V'¬
¬
new_args = []¬
for opt in [x.split('=', 1) for x in options]:¬
name, val = opt[0], opt[1] if len(opt) > 1 else None¬
if name not in accepted:¬
continue¬
if len(name) == 1:¬
new_args.append('-%s' % (name, ))¬
else:¬
new_args.append('--%s' % (name, ))¬
if val:¬
new_args.append(val)¬
cmd = ['/usr/local/bin/yas3fs'] + new_args + [args.s3path, args.localpath]¬
subprocess.call(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment