|
| 1 | +import os |
| 2 | +import sys |
| 3 | +import argparse |
| 4 | + |
| 5 | +from frameioclient import FrameioClient |
| 6 | + |
| 7 | + |
| 8 | +def main(): |
| 9 | + parser=argparse.ArgumentParser(prog='fioctl', description='Frame.io Python SDK CLI') |
| 10 | + |
| 11 | + ## Define args |
| 12 | + parser.add_argument('--token', action='store', metavar='token', type=str, nargs='+', help='Developer Token') |
| 13 | + parser.add_argument('--op', action='store', metavar='op', type=str, nargs='+', help='Operation: upload, download') |
| 14 | + parser.add_argument('--target', action='store', metavar='target', type=str, nargs='+', help='Target: remote project or folder, or alternatively a local file/folder') |
| 15 | + parser.add_argument('--destination', action='store', metavar='destination', type=str, nargs='+', help='Destination: remote project or folder, or alternatively a local file/folder') |
| 16 | + |
| 17 | + ## Parse args |
| 18 | + args = parser.parse_args() |
| 19 | + |
| 20 | + # ## Handle args |
| 21 | + if args.token: |
| 22 | + client = None |
| 23 | + try: |
| 24 | + client = FrameioClient("fio-u-dVwbtNcxXCxySPRIRadPflefXpV-NgVD4vqR3EGIWg20xIkGd_6rQ7pDNFA5YOCy") |
| 25 | + except Exception as e: |
| 26 | + print("Failed") |
| 27 | + sys.exit(1) |
| 28 | + |
| 29 | + # if args.op == 'upload': |
| 30 | + if args.target: |
| 31 | + if args.destination: |
| 32 | + # Check to see if this is a local target and thus a download |
| 33 | + if os.path.isdir(args.destination[0]): |
| 34 | + return client.assets.download(args.target[0], args.destination[0]) |
| 35 | + else: # This is an upload |
| 36 | + return client.assets.upload(args.destination[0], args.target[0]) |
| 37 | + else: |
| 38 | + print("No destination supplied") |
| 39 | + else: |
| 40 | + print("No target supplied") |
| 41 | + |
0 commit comments