status is working

This commit is contained in:
2019-02-21 00:09:28 -05:00
parent ac278f2d18
commit b858e7def0
3 changed files with 21 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ with open('README.md') as file:
setup(
name="tatt",
version="0.958",
version="0.970",
py_modules=['tatt'],
url='https://github.com/zevaverbach/tatt',
install_requires=[

View File

@@ -1,3 +1,5 @@
from typing import Dict, List
from tatt import config, exceptions, vendors
LB = '\n'
@@ -67,7 +69,11 @@ def print_transcription_jobs(jobs):
print()
def get_transcription_jobs(service_name=None, name=None, status=None):
def get_transcription_jobs(
service_name=None,
name=None,
status=None
) -> Dict[str, List[dict]]:
all_jobs = {}
for stt_name in vendors.SERVICES:
if service_name is None or service_name == stt_name:
@@ -77,6 +83,10 @@ def get_transcription_jobs(service_name=None, name=None, status=None):
status=status)
if jobs:
all_jobs[stt_name] = jobs
if name and len(all_jobs) == 0:
raise exceptions.DoesntExistError
return all_jobs

View File

@@ -31,7 +31,7 @@ def get(name, save, pretty):
file = None
if save:
filepath = f'{name}.json', 'w'
filepath = f'{name}.json'
file = open(filepath)
click.echo(transcript, file=file)
@@ -72,10 +72,15 @@ def services(free_only):
@cli.command()
@click.argument('job_name', type=str)
def status(job_name):
jobs = get_transcription_jobs(name=job_name)
if not jobs or not list(jobs.values())[0]:
"""Check the status of a transcription job."""
try:
jobs = get_transcription_jobs(name=job_name)
except exceptions.DoesntExistError:
raise click.ClickException('no job by that name')
click.echo(list(jobs.values())[0][0]['status'])
for job_list in jobs.values():
for job in job_list:
click.echo(job['status'])
break
@cli.command()