Merge ~pieq/bugit/+git/qabro:fix1840746-project-and-tags-arguments into bugit:master

Proposed by Pierre Equoy
Status: Merged
Approved by: Pierre Equoy
Approved revision: e20e917da5a073947bf52ea610f0db80ef0ecbbc
Merged at revision: 7be6eb1dea3eff7b2acb90d04e31702992af3bf3
Proposed branch: ~pieq/bugit/+git/qabro:fix1840746-project-and-tags-arguments
Merge into: bugit:master
Diff against target: 83 lines (+15/-10)
3 files modified
README (+6/-0)
qabro/__init__.py (+6/-7)
qabro/ui.py (+3/-3)
Reviewer Review Type Date Requested Status
Maciej Kisielewski (community) Approve
Pierre Equoy Needs Resubmitting
Review via email: mp+373070@code.launchpad.net

Description of the change

See lp:1840746 for more information.

Tested by creating a snap and launching:

$ APPORT_LAUNCHPAD_INSTANCE=staging qabro
$ APPORT_LAUNCHPAD_INSTANCE=staging qabro --fwts -p somerville -t test1
$ APPORT_LAUNCHPAD_INSTANCE=staging qabro --project qabro --tags "one two three"

To post a comment you must log in.
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

One big code simplification idea below.

Revision history for this message
Pierre Equoy (pieq) wrote :

Thanks for the feedback! Great idea indeed. This let me experiment with something I hadn't thought about before:

>>> def blabla(arg1='', arg2=''):
... print(arg1.lower(), arg2.upper())
...
>>> blabla()

>>> blabla('BLAAAA!', 'blaaAaaA')
blaaaa! BLAAAAAA
>>> blabla(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in blabla
AttributeError: 'NoneType' object has no attribute 'lower'

Passing "None" is actually passing something! :)

Anyway, I went with using argparse's argument_default, it should be alright.

review: Needs Resubmitting
Revision history for this message
Pierre Equoy (pieq) wrote :

@Maciek: Do you think this can be landed now?

Revision history for this message
Maciej Kisielewski (kissiel) wrote :

@Pierre: yessir!
+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/README b/README
2index 6757ba7..e981bec 100644
3--- a/README
4+++ b/README
5@@ -38,3 +38,9 @@ You can also use QABRO to automatically file Launchpad issues for the HWE team
6 regarding FWTS-related issues. To do so:
7
8 $ qabro --fwts -p <project> -t <platform-tag>
9+
10+It is also possible to pre-fill the Project and Tags sections when calling
11+qabro; for instance, to open an issue in project "checkbox-ng" with tags
12+"ce-qa-concern", "audio" and "hdmi":
13+
14+$ qabro -p checkbox-ng -t "ce-qa-concern audio hdmi"
15diff --git a/qabro/__init__.py b/qabro/__init__.py
16index 9c72446..85920c0 100644
17--- a/qabro/__init__.py
18+++ b/qabro/__init__.py
19@@ -39,27 +39,26 @@ def main():
20 epilog = ("Example: `qabro --fwts -p somerville -t platform-tag-3` will "
21 "automatically open a Launchpad issue in the somerville project "
22 "for the FWTS team.")
23- parser = argparse.ArgumentParser(epilog=epilog)
24+ parser = argparse.ArgumentParser(epilog=epilog, argument_default='')
25 parser.add_argument("--fwts", help=("Automatically files an issue in "
26 "Launchpad for the firmware team"),
27 action="store_true")
28 parser.add_argument("-p", "--project", help="Project name")
29- parser.add_argument("-t", "--tags", help="Tags (such as Platform tag)")
30+ parser.add_argument("-t", "--tags",
31+ help="Tags (such as Platform tag) separated by spaces")
32 args = parser.parse_args()
33 if args.fwts:
34 if not args.project:
35 sys.exit("You must specify a project name, e.g -p somerville")
36 if not args.tags:
37 sys.exit("You must specify a platform tag, e.g. -t platform-tag-3")
38- project = args.project.lower()
39- tags = args.tags.lower()
40 auto_submit_fwts_report(project, tags)
41 else:
42- start_ui()
43+ start_ui(project=args.project, tags=args.tags)
44
45
46-def start_ui():
47- ui = ReportScreen()
48+def start_ui(project='', tags=''):
49+ ui = ReportScreen(project=project.lower(), tags=tags.lower())
50 ui.run()
51 ba = BugAssistant(ui.report())
52 while True:
53diff --git a/qabro/ui.py b/qabro/ui.py
54index 9303cc9..930a1e3 100644
55--- a/qabro/ui.py
56+++ b/qabro/ui.py
57@@ -52,7 +52,7 @@ class ReportScreen:
58 "[Actual result]\n\n"
59 "[Failure rate]\n\n")
60
61- def __init__(self):
62+ def __init__(self, project='', tags=''):
63 # Adding standard info (CPU, BIOS, GPU, etc.) to the description
64 std_info = AttachmentAssistant.get_standard_info()
65 std_info_str = '\n'.join(['{}: {}'.format(elt, std_info[elt]) for elt in std_info])
66@@ -62,7 +62,7 @@ class ReportScreen:
67 self._description = urwid.LineBox(urwid.Edit(edit_text=self.default_description,
68 multiline=True),
69 "Description (including steps to reproduce)")
70- self._project = urwid.LineBox(urwid.Edit(), 'Project')
71+ self._project = urwid.LineBox(urwid.Edit(edit_text=project), 'Project')
72 self._series = urwid.LineBox(urwid.Edit(), 'Series')
73 self._status = []
74 for s in self.statuses:
75@@ -75,7 +75,7 @@ class ReportScreen:
76 rb = urwid.RadioButton(self._bug_type, i, state=False,
77 on_state_change=self.add_tag)
78 self._assignee = urwid.LineBox(urwid.Edit(), 'Assigned To (Launchpad ID)')
79- self._tags = urwid.LineBox(urwid.Edit(), 'Tags')
80+ self._tags = urwid.LineBox(urwid.Edit(edit_text=tags), 'Tags')
81 status_list = urwid.LineBox(urwid.Pile(self._status), 'Status')
82 importance_list = urwid.LineBox(urwid.Pile(self._importance), 'Importance')
83 bug_types_list = urwid.LineBox(urwid.Pile(self._bug_type), 'Bug Type')

Subscribers

People subscribed via source and target branches

to all changes: