Skip to content

Commit

Permalink
Fix cli critical issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jrrodri committed Oct 18, 2020
1 parent fe79fc0 commit 1f910ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions abraia/abraia.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def load_user(self):
if resp.status_code != 200:
raise APIError(resp.text, resp.status_code)
return resp.json()['user']
raise APIError('Unauthorized', 401)
return {}

def list_files(self, path=''):
url = '{}/files/{}'.format(config.API_URL, path)
Expand Down Expand Up @@ -154,7 +154,7 @@ def transform_video(self, path, params={}):
class Abraia(Client):
def __init__(self, folder=''):
super(Abraia, self).__init__()
self.userid = self.load_user()['id']
self.userid = self.load_user().get('id')
self.folder = folder
self.params = {}
self.path = ''
Expand Down
11 changes: 6 additions & 5 deletions scripts/abraia
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abraia = Abraia(folder='batch/')


@click.group('abraia')
@click.version_option('0.6.3')
@click.version_option('0.6.4')
def cli():
"""Abraia CLI tool"""
pass
Expand All @@ -41,7 +41,7 @@ def configure():
@cli.command()
def info():
"""Show user account information"""
click.echo('abraia, version 0.6.3')
click.echo('abraia, version 0.6.4')
try:
user = abraia.load_user()
click.echo('Name: %s' % user.get('name'))
Expand All @@ -52,6 +52,8 @@ def info():


def input_files(src):
if isinstance(src, str) and src.startswith('http'):
return [src]
src = os.path.join(src, '**/*') if os.path.isdir(src) else src
return glob(src, recursive=True)

Expand Down Expand Up @@ -161,9 +163,8 @@ def list(path):
# @click.argument('dest', required=False)
def upload(src):
"""Upload a file to abraia"""
files = [src] if isinstance(src, str) and src.startswith('http') else input_files(src)
with click.progressbar(files) as _files:
for file in _files:
with click.progressbar(input_files(src)) as files:
for file in files:
path = abraia.folder
click.echo(abraia.upload(file, path))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='abraia',
version='0.6.3',
version='0.6.4',
description='Abraia Python SDK',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 1f910ad

Please sign in to comment.