From ff7b39ded504288b9d052150991f2937d8b390f1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 28 Aug 2018 17:34:45 -0400 Subject: [PATCH] add tool to assign tasks The storyboard UI isn't working well for the python3 first goal story because it has so many comments, so write a command line tool to do the task assignment. Change-Id: I845608b7c0c0c95db4c3ad7bd00e609664c28e2b Signed-off-by: Doug Hellmann --- goal_tools/assign_task.py | 84 +++++++++++++++++++++++++++++++++++++++ setup.cfg | 1 + 2 files changed, 85 insertions(+) create mode 100644 goal_tools/assign_task.py diff --git a/goal_tools/assign_task.py b/goal_tools/assign_task.py new file mode 100644 index 0000000..43ab9f7 --- /dev/null +++ b/goal_tools/assign_task.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python3 + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import argparse +import logging +import os.path +import warnings + +import appdirs + +from goal_tools import storyboard + +LOG = logging.getLogger() + + +def main(): + parser = argparse.ArgumentParser() + config_dir = appdirs.user_config_dir('OSGoalTools', 'OpenStack') + config_file = os.path.join(config_dir, 'storyboard.ini') + parser.add_argument( + '--config-file', + default=config_file, + help='configuration file (%(default)s)', + ) + group = parser.add_mutually_exclusive_group() + group.add_argument( + '-v', + help='verbose mode', + dest='log_level', + default=logging.WARNING, + action='store_const', + const=logging.INFO, + ) + group.add_argument( + '-q', + help='quiet mode', + dest='log_level', + action='store_const', + const=logging.WARNING, + ) + parser.add_argument( + 'story_id', + help='ID of the story to update', + ) + parser.add_argument( + 'task_id', + help='ID of the task to update', + ) + parser.add_argument( + 'owner', + type=int, + help='owner of the task', + ) + args = parser.parse_args() + + warnings.filterwarnings( + 'ignore', + '.*Unverified HTTPS request is being made.*', + ) + + logging.basicConfig(level=args.log_level, format='%(message)s') + + config = storyboard.get_config(args.config_file) + + try: + sbc = storyboard.get_client(config) + except Exception as err: + parser.error(err) + + story = sbc.stories.get(id=args.story_id) + task = story.tasks.get(id=args.task_id) + LOG.info('Updating owner of task %s (%s)', task.id, task.title) + story.tasks.update(id=task.id, assignee_id=args.owner) diff --git a/setup.cfg b/setup.cfg index 40f6c3b..bea2c68 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,6 +30,7 @@ console_scripts = python3-first = goal_tools.python3_first.main:main find-story = goal_tools.find_story:main update-tasks = goal_tools.update_tasks:main + assign-task = goal_tools.assign_task:main who_helped = contributions list = goal_tools.who_helped.contributions:ListContributions