Don't fail over empty or faulty lines #1570

Merged
merged 1 commit into from Sep 26, 2017

Conversation

Projects
None yet
3 participants
Contributor

aleixpol commented Sep 25, 2017

If we're not going to be able to unpack it, ignore the line.

This is what it looks like on Arch Linux. Note the empty line in the end:

$ cat /etc/os-release 
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
ID_LIKE=archlinux
ANSI_COLOR="0;36"
HOME_URL="https://www.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"

$ 

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on bug reports?
  • If this is a new feature. Have you discussed the design on the forum?
  • Have you successfully run ./runtests.sh static?
  • Have you successfully run ./runtests.sh unit? < some tests fail but they also failed before as well
- os_release_dict[key] = value.strip('"')
+ entry = line.rstrip().split('=')
+ if len(entry) == 2:
+ os_release_dict[entry[0]] = entry[1].strip('"')
@kalikiana

kalikiana Sep 26, 2017

Collaborator

Would you mind adding a unit test to snapcraft/tests/test_common.py with your failing os-release and one that doesn't have an empty line?

common: do not fail over on empty or faulty lines in os-release
If we're not going to be able to unpack it, ignore the line

\o/

@sergiusens sergiusens merged commit bf216fd into snapcore:master Sep 26, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Contributor

aleixpol commented Sep 26, 2017

\o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment