diff --git a/.gitmodules b/.gitmodules index ba05cc2..f43ab5e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/ev3dev/ev3dev-lang.git [submodule "tests/fake-sys"] path = tests/fake-sys - url = https://github.com/rhempel/ev3dev-lang-fake-sys.git + url = https://github.com/ev3dev/ev3dev-lang-fake-sys.git diff --git a/debian/changelog b/debian/changelog index 6f80429..9155bf0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-ev3dev (1.1.0) testing; urgency=medium + + [Daniel Walton] + * Fixes to make the library work on Debian Stretch. + + -- Denis Demidov Sat, 06 Oct 2017 00:00:00 +0300 + python-ev3dev (1.0.0) stable; urgency=medium [Denis Demidov] diff --git a/ev3dev-lang b/ev3dev-lang index 008804f..0169750 160000 --- a/ev3dev-lang +++ b/ev3dev-lang @@ -1 +1 @@ -Subproject commit 008804f5c28acd225f1b43057be2060d9965b2c1 +Subproject commit 0169750bf9aeefac423c38929287b4ad9ef7abd4 diff --git a/ev3dev/core.py b/ev3dev/core.py index 8747923..f543bca 100644 --- a/ev3dev/core.py +++ b/ev3dev/core.py @@ -42,6 +42,7 @@ import fnmatch import numbers import array +import logging import mmap import ctypes import re @@ -53,6 +54,8 @@ from struct import pack, unpack from subprocess import Popen, check_output, PIPE +log = logging.getLogger(__name__) + try: # This is a linux-specific module. # It is required by the Button() class, but failure to import it may be @@ -195,7 +198,8 @@ def _get_attribute(self, attribute, name): attribute.seek(0) return attribute, attribute.read().strip().decode() else: - raise Exception('Device is not connected') + log.info("%s: path %s, attribute %s" % (self, self._path, name)) + raise Exception("%s is not connected" % self) def _set_attribute(self, attribute, name, value): """Device attribute setter""" @@ -208,7 +212,8 @@ def _set_attribute(self, attribute, name, value): attribute.flush() return attribute else: - raise Exception('Device is not connected') + log.info("%s: path %s, attribute %s" % (self, self._path, name)) + raise Exception("%s is not connected" % self) def get_attr_int(self, attribute, name): attribute, value = self._get_attribute(attribute, name) @@ -3445,7 +3450,7 @@ def speak(text, espeak_opts='-a 200 -s 130'): cmd_line = '/usr/bin/espeak --stdout {0} "{1}"'.format(espeak_opts, text) espeak = Popen(shlex.split(cmd_line), stdout=PIPE) play = Popen(['/usr/bin/aplay', '-q'], stdin=espeak.stdout, stdout=n) - return espeak + return play @staticmethod def _get_channel(): diff --git a/tests/README.md b/tests/README.md index b8f0017..0c7adf4 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,8 +1,27 @@ +# fake-sys directory +The tests require the fake-sys directory which comes from +https://github.com/ddemidov/ev3dev-lang-fake-sys + +If you have already cloned the ev3dev-lang-python repo but do not have the +`fake-sys` directory use `git submodule init` to get it. If you have not +already cloned the ev3dev-lang-python repo you can use the `--recursive` option +when you git clone. Example: + +``` +$ git clone --recursive https://github.com/rhempel/ev3dev-lang-python.git +``` + +# Running Tests +To run the tests do: +``` +$ ./api_tests.py +``` + +# Misc Commands used to copy the /sys/class node: -```sh -node=lego-sensor/sensor0 -mkdir -p ./${node} -# Copy contents of special files, do not follow symlinks: -cp -P --copy-contents -r /sys/class/${node}/* ./${node}/ +``` +$ node=lego-sensor/sensor0 +$ mkdir -p ./${node} +$ cp -P --copy-contents -r /sys/class/${node}/* ./${node}/ ``` diff --git a/tests/api_tests.py b/tests/api_tests.py index 6edb48e..7476352 100755 --- a/tests/api_tests.py +++ b/tests/api_tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import unittest, sys, os FAKE_SYS = os.path.join(os.path.dirname(__file__), 'fake-sys')