Skip to content

Commit 5b628a9

Browse files
committed
Add CLI
1 parent 9fbd37c commit 5b628a9

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

frameioclient/fioctl.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+

frameioclient/service/assets.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import mimetypes
33

44
from .service import Service
5-
from .projects import Project
65

76
from ..lib import FrameioUploader, FrameioDownloader
87

@@ -217,7 +216,7 @@ def upload(self, destination_id, filepath, asset=None):
217216
folder_id = self.get(destination_id)['id']
218217
except Exception as e:
219218
# Then try to grab it as a project
220-
folder_id = Project(self.client).get_project(destination_id)['root_asset_id']
219+
folder_id = self.client.projects.get(destination_id)['root_asset_id']
221220
finally:
222221
file_info = self._build_asset_info(filepath)
223222

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from setuptools.command.install import install
66

7-
version='1.1.0'
7+
version='1.3.0'
88

99
with open("README.md", "r") as f:
1010
long_description = f.read()
@@ -41,6 +41,12 @@ def run(self):
4141
'bump2version',
4242
]
4343
},
44+
# packages = setuptools.find_packages(),
45+
entry_points ={
46+
'console_scripts': [
47+
'fioctl = frameioclient.fioctl:main'
48+
]
49+
},
4450
classifiers=[
4551
'Development Status :: 5 - Production/Stable',
4652
'Intended Audience :: Developers',

0 commit comments

Comments
 (0)