Merge lp:~kissiel/checkbox/validate-providers-in-cbt into lp:checkbox

Proposed by Maciej Kisielewski
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 3915
Merged at revision: 3920
Proposed branch: lp:~kissiel/checkbox/validate-providers-in-cbt
Merge into: lp:checkbox
Diff against target: 46 lines (+29/-0)
1 file modified
checkbox-touch/build-me (+29/-0)
To merge this branch: bzr merge lp:~kissiel/checkbox/validate-providers-in-cbt
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+265968@code.launchpad.net

Description of the change

Validation of providers when building CBT.

This patch make build-me run validate command on every provider in
'checkbox-touch/providers' directory. If the problem with validation is not
caused by invalid provider content (i.e. missing plainbox or directory not
being a provider), then user-friendly message is shown.

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Look at some of the small things below.

review: Needs Fixing
3915. By Maciej Kisielewski

checkbox-touch: validate providers when building click

This patch make build-me run validate command on every provider in
'checkbox-touch/providers' directory. If the problem with validation is not
caused by invalid provider content (i.e. missing plainbox or directory not
being a provider), then user-friendly message is shown.

Signed-off-by: Maciej Kisielewski <email address hidden>

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

> Look at some of the small things below.

Formatting changed to .format(...)

Capturing of FileNotFoundError changed to OSError.

pushed

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-touch/build-me'
2--- checkbox-touch/build-me 2015-07-21 13:04:53 +0000
3+++ checkbox-touch/build-me 2015-07-29 08:14:31 +0000
4@@ -115,6 +115,9 @@
5 target_base_name = os.path.basename(os.path.normpath(path))
6 copy_tree(path, os.path.join('providers', target_base_name))
7
8+ if not validate_providers():
9+ sys.exit('Provider validation failed.')
10+
11 generate_desktop_file()
12
13 if not os.path.exists('../build-cbt'):
14@@ -129,6 +132,32 @@
15 install_click(pkg, adb_options)
16
17
18+def validate_providers():
19+ print("Validating providers")
20+ providers_valid = True
21+ for provider_dir in os.listdir('providers'):
22+ try:
23+ subprocess.check_output(
24+ [os.path.join('providers', provider_dir, 'manage.py'),
25+ 'validate'], stderr=subprocess.STDOUT)
26+ except OSError as e:
27+ print(e.strerror)
28+ providers_valid = False
29+ except subprocess.CalledProcessError as e:
30+ output_lines = e.output.decode(sys.stdout.encoding).split('\n')
31+ if (len(output_lines) > 0 and
32+ "ImportError: No module named 'plainbox'" in output_lines):
33+ print('Plainbox not found. Install plainbox or run the'
34+ 'command from the virtual env.')
35+ return False
36+ else:
37+ print(("Problem encountered when validating '{}'."
38+ " Output:\n{}").format(provider_dir, e.output.decode(
39+ sys.stdout.encoding)))
40+ providers_valid = False
41+ return providers_valid
42+
43+
44 def generate_desktop_file():
45 template = textwrap.dedent("""
46 # This file has been generated by build-me script

Subscribers

People subscribed via source and target branches