You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

__init__.py 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # Copyright (c) 2016 Anki, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License in the file LICENSE.txt or at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import sys
  15. if sys.version_info < (3,5,1):
  16. sys.exit('cozmo requires Python 3.5.1 or later')
  17. # Verify cozmoclad version before any other imports, so we can catch a mismatch
  18. # before triggering any exceptions from missing clad definitions
  19. try:
  20. from cozmoclad import __build_version__ as __installed_cozmoclad_build_version__
  21. except ImportError as e:
  22. sys.exit("%s\nCannot import from cozmoclad: Do `pip3 install --user cozmoclad` to install" % e)
  23. from .version import __version__, __cozmoclad_version__, __min_cozmoclad_version__
  24. def verify_min_clad_version():
  25. def _make_sortable_version_string(ver_string):
  26. # pad out an x.y.z version to a 5.5.5 string with leading zeroes
  27. ver_elements = [str(int(x)).zfill(5) for x in ver_string.split(".")]
  28. return '.'.join(ver_elements)
  29. def _trimmed_version(ver_string):
  30. # Trim leading zeros from the version string
  31. trimmed_parts = [str(int(x)) for x in ver_string.split(".")]
  32. return '.'.join(trimmed_parts)
  33. min_cozmoclad_version_str = _make_sortable_version_string(__min_cozmoclad_version__)
  34. if __installed_cozmoclad_build_version__ < min_cozmoclad_version_str:
  35. sys.exit("Incompatible cozmoclad version %s for SDK %s - needs at least %s\n"
  36. "Do `pip3 install --user --upgrade cozmoclad` to upgrade" % (
  37. _trimmed_version(__installed_cozmoclad_build_version__),
  38. __version__,
  39. __min_cozmoclad_version__))
  40. verify_min_clad_version()
  41. import logging as _logging
  42. #: The general purpose logger logs high level information about Cozmo events.
  43. logger = _logging.getLogger('cozmo.general')
  44. #: The protocol logger logs low level messages that are sent back and forth to Cozmo.
  45. logger_protocol = _logging.getLogger('cozmo.protocol')
  46. del _logging
  47. from . import action
  48. from . import anim
  49. from . import annotate
  50. from . import behavior
  51. from . import conn
  52. from . import event
  53. from . import exceptions
  54. from . import lights
  55. from . import nav_memory_map
  56. from . import objects
  57. from . import oled_face
  58. from . import robot
  59. from . import robot_alignment
  60. from . import run
  61. from . import util
  62. from . import world
  63. from .exceptions import *
  64. from .run import *
  65. __all__ = ['logger', 'logger_protocol',
  66. 'action', 'anim', 'annotate', 'behavior', 'conn', 'event',
  67. 'exceptions', 'lights', 'objects', 'oled_face', 'nav_memory_map',
  68. 'robot', 'robot_alignment', 'run', 'util', 'world'] + \
  69. (run.__all__ + exceptions.__all__)