Merge lp:~taihsiangho/checkbox/141224-checkbox-submit-more-automatic into lp:checkbox

Proposed by Taihsiang Ho on 2014-12-24
Status: Merged
Approved by: Maciej Kisielewski on 2015-01-12
Approved revision: 3521
Merged at revision: 3528
Proposed branch: lp:~taihsiangho/checkbox/141224-checkbox-submit-more-automatic
Merge into: lp:checkbox
Diff against target: 58 lines (+32/-2)
2 files modified
checkbox-ng/checkbox_ng/commands/submit.py (+28/-2)
checkbox-ng/checkbox_ng/config.py (+4/-0)
To merge this branch: bzr merge lp:~taihsiangho/checkbox/141224-checkbox-submit-more-automatic
Reviewer Review Type Date Requested Status
Maciej Kisielewski 2014-12-24 Approve on 2015-01-12
Taihsiang Ho Resubmit on 2015-01-09
Review via email: mp+245357@code.launchpad.net

Commit message

Make checkbox-submit more automatic.

The argument secure_id becomes optional
and give it a default value if possible.

Add one more optical submission parameter in the configuration file
to specify the value of the argument, --url, automatically.

Description of the change

checkbox-certification-submit
http://bazaar.launchpad.net/~checkbox-dev/checkbox-certification/trunk/view/head:/bin/checkbox-certification-submit
is outdated and there is checkbox-submit now.

I would like to enhance the feature of checkbox-submit to get the secure id and submission url via a configuration file (checkbox.conf etc.) if it is set up correctly. And then we don't need to use checkbox-certification-submit anymore.

Once this branch is accepted and merged. I will remove checkbox-certification-submit and make it share the same code of checkbox-submit.

To post a comment you must log in.
Maciej Kisielewski (kissiel) wrote :

Added comment about potential crash when self.config.submit_to_c3 is set to something other than 'yes', 'true', castable to integer.

Maciej Kisielewski (kissiel) wrote :

See comments

review: Needs Fixing
3520. By Taihsiang Ho on 2015-01-09

merge trunk

3521. By Taihsiang Ho on 2015-01-09

exception handling for checkbox submit conf submit_to_c3 flag

Taihsiang Ho (taihsiangho) wrote :

add the exception handling based on Maciej's comment.

review: Resubmit
Maciej Kisielewski (kissiel) wrote :

Good stuff!
+1, Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-ng/checkbox_ng/commands/submit.py'
2--- checkbox-ng/checkbox_ng/commands/submit.py 2014-11-18 17:20:58 +0000
3+++ checkbox-ng/checkbox_ng/commands/submit.py 2015-01-09 09:19:10 +0000
4@@ -110,11 +110,37 @@
5 return secure_id
6
7 parser.add_argument(
8- 'secure_id', metavar=_("SECURE-ID"),
9+ '--secure_id', metavar=_("SECURE-ID"),
10+ required=self.config.secure_id is Unset,
11 type=secureid,
12 help=_("associate submission with a machine using this SECURE-ID"))
13+
14 parser.add_argument('submission',
15 help=_("The path to the results xml file"))
16+
17+ # Interpret this setting here
18+ # Please remember the Unset.__bool__() return False
19+ # After Interpret the setting,
20+ # self.config.submit_to_c3 should has value or be Unset.
21+ try:
22+ if self.config.submit_to_c3 and \
23+ (self.config.submit_to_c3.lower() in ('yes', 'true') or
24+ int(self.config.submit_to_c3) == 1):
25+ # self.config.c3_url has a default value written in config.py
26+ parser.set_defaults(url=self.config.c3_url)
27+ else:
28+ # if submit_to_c3 is castable to int but not 1
29+ # this is still set as Unset
30+ # otherwise url requirement will be None
31+ self.config.submit_to_c3 = Unset
32+ except ValueError:
33+ # When submit_to_c3 is something other than 'yes', 'true',
34+ # castable to integer, it raises ValueError.
35+ # e.g. 'no', 'false', 'asdf' ...etc.
36+ # In this case, it is still set as Unset.
37+ self.config.submit_to_c3 = Unset
38+
39 parser.add_argument(
40- '--url', metavar=_("URL"), required=True,
41+ '--url', metavar=_("URL"),
42+ required=self.config.submit_to_c3 is Unset,
43 help=_("destination to submit to"))
44
45=== modified file 'checkbox-ng/checkbox_ng/config.py'
46--- checkbox-ng/checkbox_ng/config.py 2014-10-02 15:19:22 +0000
47+++ checkbox-ng/checkbox_ng/config.py 2015-01-09 09:19:10 +0000
48@@ -43,6 +43,10 @@
49 help_text=_("Secure ID of the system"),
50 validator_list=[config.PatternValidator(SECURE_ID_PATTERN)])
51
52+ submit_to_c3 = config.Variable(
53+ section="submission",
54+ help_text=_("Whether to send the submission data to c3"))
55+
56 submit_to_hexr = config.Variable(
57 section="submission",
58 help_text=_("Whether to also send the submission data to HEXR"),

Subscribers

People subscribed via source and target branches