Merge lp:~canonical-platform-qa/ubuntu-system-tests/eoferror-on-config into lp:ubuntu-system-tests

Proposed by Allan LeSage
Status: Work in progress
Proposed branch: lp:~canonical-platform-qa/ubuntu-system-tests/eoferror-on-config
Merge into: lp:ubuntu-system-tests
Diff against target: 16 lines (+5/-1)
1 file modified
ubuntu_system_tests/config/__init__.py (+5/-1)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-system-tests/eoferror-on-config
Reviewer Review Type Date Requested Status
Richard Huddie (community) Needs Information
platform-qa-bot continuous-integration Approve
Review via email: mp+294986@code.launchpad.net

Commit message

Catch EOFError on no config input() for Jenkins, offer default.

Description of the change

Quickie change to support Jenkins having no config input.

Seeing this kind of thing with our config system:

The name of the country of the SIM card to use for telegram login (leave blank to use default value: United States): Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/var/lib/jenkins/slaves/krillin-06/workspace/ust_rc-proposed_krillin_sanity/ubuntu-system-tests/ubuntu_system_tests/command_line.py", line 699, in <module>
    sys.exit(main())
  File "/var/lib/jenkins/slaves/krillin-06/workspace/ust_rc-proposed_krillin_sanity/ubuntu-system-tests/ubuntu_system_tests/command_line.py", line 65, in main
    args.verbose)
  File "/var/lib/jenkins/slaves/krillin-06/workspace/ust_rc-proposed_krillin_sanity/ubuntu-system-tests/ubuntu_system_tests/command_line.py", line 137, in run_system_tests
    config_stack = _get_config_stack(conf_name, config_section, silent)
  File "/var/lib/jenkins/slaves/krillin-06/workspace/ust_rc-proposed_krillin_sanity/ubuntu-system-tests/ubuntu_system_tests/command_line.py", line 200, in _get_config_stack
    config_stack.get_missing_options(silent)
  File "/var/lib/jenkins/slaves/krillin-06/workspace/ust_rc-proposed_krillin_sanity/ubuntu-system-tests/ubuntu_system_tests/config/__init__.py", line 269, in get_missing_options
    self._get_option_value(option, silent)
  File "/var/lib/jenkins/slaves/krillin-06/workspace/ust_rc-proposed_krillin_sanity/ubuntu-system-tests/ubuntu_system_tests/config/__init__.py", line 299, in _get_option_value
    self._get_option_value_from_stdin(option)
  File "/var/lib/jenkins/slaves/krillin-06/workspace/ust_rc-proposed_krillin_sanity/ubuntu-system-tests/ubuntu_system_tests/config/__init__.py", line 307, in _get_option_value_from_stdin
    value = self._get_value_from_user_or_default(option)
  File "/var/lib/jenkins/slaves/krillin-06/workspace/ust_rc-proposed_krillin_sanity/ubuntu-system-tests/ubuntu_system_tests/config/__init__.py", line 326, in _get_value_from_user_or_default
    return input() or option.default

To post a comment you must log in.
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Richard Huddie (rhuddie) wrote :

For Jenkins, the silent mode option should take care of this, so the default value is used instead of prompting for user input. Could you confirm you are using -s option for Jenkins?

review: Needs Information

Unmerged revisions

387. By Allan LeSage

Catch EOFError if no input() for config, offer default.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_system_tests/config/__init__.py'
2--- ubuntu_system_tests/config/__init__.py 2016-05-06 10:18:32 +0000
3+++ ubuntu_system_tests/config/__init__.py 2016-05-17 22:33:22 +0000
4@@ -323,7 +323,11 @@
5
6 def _get_value_from_user_or_default(self, option):
7 """Return value from stdin or default value if no stdin value."""
8- return input() or option.default
9+ try:
10+ return input() or option.default
11+ except EOFError:
12+ # e.g. if no terminal (as in Jenkins)
13+ return option.default
14
15 def get_autopilot_config_string(self):
16 """Return the configuration in a string usable by Autopilot.

Subscribers

People subscribed via source and target branches

to all changes: