From 0c555a7c10492047586f1340e60222b9843b03ef Mon Sep 17 00:00:00 2001 From: jake Date: Thu, 28 Jun 2018 16:18:10 -0700 Subject: [PATCH] Fixed bug where task logs could not be retrieved --- internetarchive/catalog.py | 22 ++++++++++------------ internetarchive/cli/ia_tasks.py | 4 ++-- internetarchive/session.py | 8 ++++---- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/internetarchive/catalog.py b/internetarchive/catalog.py index 84d09a9f..259c6320 100644 --- a/internetarchive/catalog.py +++ b/internetarchive/catalog.py @@ -65,7 +65,7 @@ class Catalog(object): def __init__(self, archive_session, identifier=None, - task_ids=None, + task_id=None, params=None, config=None, verbose=None, @@ -78,8 +78,8 @@ def __init__(self, archive_session, :param identifier: (optional) The Archive.org identifier for which to retrieve tasks for. - :type task_ids: int or str - :param task_ids: (optional) The task_ids to retrieve from the Archive.org catalog. + :type task_id: int or str + :param task_id: (optional) The task_id to retrieve from the Archive.org catalog. :type params: dict :param params: (optional) The URL parameters to send with each request sent to the @@ -93,7 +93,7 @@ def __init__(self, archive_session, each catalog task returned. Verbose is set to ``True`` by default. """ - task_ids = [] if not task_ids else task_ids + task_id = [] if not task_id else task_id params = {} if not params else params config = {} if not config else config verbose = '1' if verbose is None or verbose is True else '0' @@ -124,23 +124,21 @@ def __init__(self, archive_session, ) self.params.update(params) # Return user's current tasks as default. - if not identifier and not task_ids and not params: + if not identifier and not task_id and not params: self.params['justme'] = 1 - if task_ids: - if not isinstance(task_ids, (set, list)): - task_ids = [task_ids] - task_ids = [str(t) for t in task_ids] + if task_id: + task_id = str(task_id) self.params.update(dict( - where='task_id in({tasks})'.format(tasks=','.join(task_ids)), + search_task_id=task_id, history=999999999999999999999, # TODO: is there a better way? )) if identifier: self.url = '{0}//archive.org/history/{1}'.format(self.session.protocol, identifier) - elif task_ids: - self.url = '{0}//cat-tracey.archive.org/catalog.php'.format( + elif task_id: + self.url = '{0}//catalogd.archive.org/catalog.php'.format( self.session.protocol) else: self.url = '{0}//archive.org/catalog.php'.format(self.session.protocol) diff --git a/internetarchive/cli/ia_tasks.py b/internetarchive/cli/ia_tasks.py index 33eca400..69cc3990 100644 --- a/internetarchive/cli/ia_tasks.py +++ b/internetarchive/cli/ia_tasks.py @@ -76,7 +76,7 @@ def main(argv, session): task_type=task_type, params=params) elif args['--get-task-log']: - task = session.get_tasks(task_ids=args['--get-task-log'], params=params) + task = session.get_tasks(task_id=args['--get-task-log'], params=params) if task: log = task[0].task_log() sys.exit(print(log)) @@ -85,7 +85,7 @@ def main(argv, session): 'for {0}\n'.format(args['--get-task-log']), file=sys.stderr) sys.exit(1) elif args['--task']: - tasks = session.get_tasks(task_ids=args['--task'], params=params) + tasks = session.get_tasks(task_id=args['--task'], params=params) else: tasks = session.get_tasks(task_type=task_type, params=params) except ValueError as exc: diff --git a/internetarchive/session.py b/internetarchive/session.py index ce367002..3e437c8b 100644 --- a/internetarchive/session.py +++ b/internetarchive/session.py @@ -289,7 +289,7 @@ def search_items(self, query, def get_tasks(self, identifier=None, - task_ids=None, + task_id=None, task_type=None, params=None, config=None, @@ -303,8 +303,8 @@ def get_tasks(self, :param identifier: (optional) The Archive.org identifier for which to retrieve tasks for. - :type task_ids: int or str - :param task_ids: (optional) The task_ids to retrieve from the Archive.org catalog. + :type task_id: int or str + :param task_id: (optional) The task_id to retrieve from the Archive.org catalog. :type task_type: str :param task_type: (optional) The type of tasks to retrieve from the Archive.org @@ -328,7 +328,7 @@ def get_tasks(self, request_kwargs = {} if not request_kwargs else request_kwargs _catalog = Catalog(self, identifier=identifier, - task_ids=task_ids, + task_id=task_id, params=params, config=config, verbose=verbose,