Exemple #1
0
def process(args):
    conduit = phlsys_makeconduit.make_conduit(
        args.uri, args.user, args.cert, args.act_as_user)

    # conduit expects PHIDs not plain usernames
    user_phids = phlcon_user.UserPhidCache(conduit)
    user_phids.add_hint_list(
        _combine_lists_if_not_none(args.owners, args.ccs))
    authors = [user_phids.get_phid(user) for user in args.authors]
    owners = [user_phids.get_phid(user) for user in args.owners]
    ccs = [user_phids.get_phid(user) for user in args.ccs]

    # conduit expects PHIDs not plain project names
    projects = None
    if args.projects:
        project_to_phid = phlcon_project.make_project_to_phid_dict(conduit)
        projects = [project_to_phid[p] for p in args.projects]

    filters = phlcon_maniphest.STATUS_FILTERS
    status = filters[args.status] if args.status is not None else None

    orderings = phlcon_maniphest.ORDERS
    order = orderings[args.order] if args.order is not None else None

    results = phlcon_maniphest.query(
        conduit,
        ids=args.ids,
        authors=authors,
        owners=owners,
        ccs=ccs,
        projects=projects,
        status=status,
        limit=args.max_results,
        offset=args.offset_results,
        order=order,
        text=args.text)

    results = [dict(r.__dict__) for r in results]

    for r in results:
        if r['statusName'] is None:
            r['statusName'] = phlcon_maniphest.STATUSES[int(r['status'])]

    # initialise to format for 'args.format_short'
    output_format = "{id} / {statusName} / {priority} / {title}"

    if args.format_ids:
        output_format = "{id}"
    elif args.format_string is not None:
        output_format = args.format_string

    if args.format_python:
        pprint.pprint(results)
    elif args.format_json:
        print(json.dumps(results, sort_keys=True, indent=2))
    else:
        for r in results:
            print(output_format.format(**r))
def process(args):
    if args.title and not args.title.strip():
        print('you must supply a non-empty title', file=sys.stderr)
        return 1

    conduit = phlsys_makeconduit.make_conduit(
        args.uri, args.user, args.cert, args.act_as_user)

    # create_task expects an integer
    priority = None
    if args.priority is not None:
        priority = phlcon_maniphest.PRIORITIES[args.priority]

    # conduit expects PHIDs not plain usernames
    user_phids = phlcon_user.UserPhidCache(conduit)
    if args.owner:
        user_phids.add_hint(args.owner)
    if args.ccs:
        user_phids.add_hint_list(args.ccs)
    owner = user_phids.get_phid(args.owner) if args.owner else None
    ccs = [user_phids.get_phid(u) for u in args.ccs] if args.ccs else None

    # conduit expects PHIDs not plain project names
    projects = None
    if args.projects:
        project_to_phid = phlcon_project.make_project_to_phid_dict(conduit)
        projects = [project_to_phid[p] for p in args.projects]

    result = phlcon_maniphest.update_task(
        conduit,
        args.id,
        args.title,
        args.description,
        priority,
        owner,
        ccs,
        projects,
        args.comment,
        args.status)

    if args.format_id:
        print(result.id)
    elif args.format_url:
        print(result.uri)
    else:  # args.format_summary:
        message = (
            "Updated task '{task_id}', you can view it at this URL:\n"
            "  {url}"
        ).format(
            task_id=result.id,
            url=result.uri)
        print(message)
def process(args):
    if args.title and not args.title.strip():
        print('you must supply a non-empty title', file=sys.stderr)
        return 1

    conduit = phlsys_makeconduit.make_conduit(args.uri, args.user, args.cert,
                                              args.act_as_user)

    # create_task expects an integer
    priority = None
    if args.priority is not None:
        priority = phlcon_maniphest.PRIORITIES[args.priority]

    # conduit expects PHIDs not plain usernames
    user_phids = phlcon_user.UserPhidCache(conduit)
    if args.owner:
        user_phids.add_hint(args.owner)
    if args.ccs:
        user_phids.add_hint_list(args.ccs)
    owner = user_phids.get_phid(args.owner) if args.owner else None
    ccs = [user_phids.get_phid(u) for u in args.ccs] if args.ccs else None

    # conduit expects PHIDs not plain project names
    projects = None
    if args.projects:
        project_to_phid = phlcon_project.make_project_to_phid_dict(conduit)
        projects = [project_to_phid[p] for p in args.projects]

    result = phlcon_maniphest.update_task(conduit, args.id, args.title,
                                          args.description, priority, owner,
                                          ccs, projects, args.comment)

    if args.format_id:
        print(result.id)
    elif args.format_url:
        print(result.uri)
    else:  # args.format_summary:
        message = ("Updated task '{task_id}', you can view it at this URL:\n"
                   "  {url}").format(task_id=result.id, url=result.uri)
        print(message)