Keyboard firmwares for Atmel AVR and Cortex-M
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.

module_copy_mbed.py 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. """
  2. mbed SDK
  3. Copyright (c) 2011-2013 ARM Limited
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. """
  14. from shutil import copy
  15. from host_test_plugins import HostTestPluginBase
  16. class HostTestPluginCopyMethod_Mbed(HostTestPluginBase):
  17. def generic_mbed_copy(self, image_path, destination_disk):
  18. """ Generic mbed copy method for "mbed enabled" devices.
  19. It uses standard python shuitl function to copy
  20. image_file (target specific binary) to device's disk.
  21. """
  22. result = True
  23. if not destination_disk.endswith('/') and not destination_disk.endswith('\\'):
  24. destination_disk += '/'
  25. try:
  26. copy(image_path, destination_disk)
  27. except Exception, e:
  28. self.print_plugin_error("shutil.copy('%s', '%s')"% (image_path, destination_disk))
  29. self.print_plugin_error("Error: %s"% str(e))
  30. result = False
  31. return result
  32. # Plugin interface
  33. name = 'HostTestPluginCopyMethod_Mbed'
  34. type = 'CopyMethod'
  35. stable = True
  36. capabilities = ['default']
  37. required_parameters = ['image_path', 'destination_disk']
  38. def setup(self, *args, **kwargs):
  39. """ Configure plugin, this function should be called before plugin execute() method is used.
  40. """
  41. return True
  42. def execute(self, capabilitity, *args, **kwargs):
  43. """ Executes capability by name.
  44. Each capability may directly just call some command line
  45. program or execute building pythonic function
  46. """
  47. result = False
  48. if self.check_parameters(capabilitity, *args, **kwargs) is True:
  49. if capabilitity == 'default':
  50. image_path = kwargs['image_path']
  51. destination_disk = kwargs['destination_disk']
  52. # Wait for mount point to be ready
  53. self.check_mount_point_ready(destination_disk) # Blocking
  54. result = self.generic_mbed_copy(image_path, destination_disk)
  55. return result
  56. def load_plugin():
  57. """ Returns plugin available in this module
  58. """
  59. return HostTestPluginCopyMethod_Mbed()