Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/motors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Most methods which run motors with accept a ``speed`` or ``speed_pct`` argument.

.. autoclass:: SpeedInteger
.. autoclass:: SpeedPercent
.. autoclass:: SpeedNativeUnits
.. autoclass:: SpeedRPS
.. autoclass:: SpeedRPM
.. autoclass:: SpeedDPS
Expand Down
3 changes: 3 additions & 0 deletions ev3dev2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def matches(attribute, pattern):
yield f


def library_load_warning_message(library_name, dependent_class):
return 'Import warning: Failed to import "{}". {} will be unusable!'.format(library_name, dependent_class)

class DeviceNotFound(Exception):
pass

Expand Down
18 changes: 14 additions & 4 deletions ev3dev2/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,26 @@

import array
import time
import evdev
from . import get_current_platform
import logging
from . import get_current_platform, library_load_warning_message

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
# It is required by the Button class, but failure to import it may be
# safely ignored if one just needs to run API tests on Windows.
import fcntl
except ImportError:
print("WARNING: Failed to import fcntl. Button class will be unuseable!")
log.warning(library_load_warning_message("fcntl", "Button"))

try:
# This is a linux-specific module.
# It is required by the Button class, but failure to import it may be
# safely ignored if one just needs to run API tests on Windows.
import evdev
except ImportError:
log.warning(library_load_warning_message("evdev", "Button"))


# Import the button filenames, this is platform specific
Expand Down
7 changes: 5 additions & 2 deletions ev3dev2/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@
import os
import mmap
import ctypes
import logging
from PIL import Image, ImageDraw
from . import fonts
from . import get_current_platform
from . import get_current_platform, library_load_warning_message
from struct import pack

log = logging.getLogger(__name__)

try:
# This is a linux-specific module.
# It is required by the Display class, but failure to import it may be
# safely ignored if one just needs to run API tests on Windows.
import fcntl
except ImportError:
print("WARNING: Failed to import fcntl. Display class will be unusable!")
log.warning(library_load_warning_message("fcntl", "Display"))

class FbMem(object):

Expand Down
Loading