-#!/usr/bin/env python3
-
-import argparse
-from os import path, makedirs
-from pathlib import Path
-from shutil import copyfile
-
-def parse_args():
- parser = argparse.ArgumentParser(
- description="Copy file to Wasabi-mounted directory")
- parser.add_argument("input", type=str, nargs=1, help="input file")
- parser.add_argument("output", type=str, nargs="*", help="output path")
- parser.add_argument("-p", "--private", action="store_true",
- help="Copy to private directory")
- parser.add_argument("-m", "--mkdir", action="store_true",
- help="Create parent directories if necesary")
-
- return parser.parse_args()
-
-def outp(args):
- if not args.output:
- out = path.basename(args.input[0])
- else:
- out = args.output[0]
- return out
-
-def main(args):
- out = outp(args)
- inp = args.input[0]
-
- if args.private:
- s3path = priv_path
- s3bin = priv_bin
- else:
- s3path = pub_path
- s3bin = pub_bin
-
- fpath = s3path + out
- if args.mkdir and not path.exists(fpath):
- makedirs(Path(fpath).parent)
-
- copyfile(inp, fpath)
- print(endp + s3bin + "/" + out)
-
-if __name__ == "__main__":
- endp = "https://s3.us-east-2.wasabisys.com/"
- pub_path = "/home/armaa/.local/mnt/public/"
- pub_bin = "armaan-public"
- priv_path = "/home/armaa/.local/mnt/private/"
- priv_bin = "armaan-private"
- main(parse_args())