Skip to content

Commit

Permalink
seabreeze.os_setup: fix py2/py3 compatibility
Browse files Browse the repository at this point in the history
fixes unicode error on python3 when udev rules differed
  • Loading branch information
ap-- committed Sep 7, 2019
1 parent 56a8aa1 commit 8a1dcd8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0


## [Unreleased]
### Fixed
- `seabreeze_os_setup` fix py3 error when udev rules differed on linux

## [1.0.0rc4] - 2017-09-07
### Added
Expand Down
8 changes: 4 additions & 4 deletions src/seabreeze/os_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
except ImportError:
# noinspection PyUnusedLocal
def _indent(text, prefix, predicate=None):
return "".join(prefix + line for line in text.splitlines(True))
return u"".join(prefix + line for line in text.splitlines(True))

_GITHUB_REPO_URL = 'https://raw.githubusercontent.com/ap--/python-seabreeze/master/os_support'
_UDEV_RULES_PATH = '/etc/udev/rules.d/10-oceanoptics.rules'
Expand All @@ -39,9 +39,9 @@ def _indent(text, prefix, predicate=None):
def _diff_files(file1, file2):
"""diff two files using linux `diff`"""
try:
return subprocess.check_output(['diff', file1, file2])
return subprocess.check_output(['diff', file1, file2]).decode('utf8')
except subprocess.CalledProcessError as err:
return err.output
return err.output.decode('utf8')


def _request_confirmation(question):
Expand Down Expand Up @@ -95,7 +95,7 @@ def linux_install_udev_rules():
_log.info("udev rules already newest version")
sys.exit(0)
else:
_log.info(_indent(rules_differ, ' ').rstrip())
_log.info(_indent(rules_differ, u' ').rstrip())
_log.info("udev rules differ. To overwrite run with '--overwrite-existing'")
sys.exit(1)

Expand Down

0 comments on commit 8a1dcd8

Please sign in to comment.