odoo_api.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # -*- coding: utf-8 -*-
  2. from random import randint
  3. from .docker_api import (
  4. get_all_external_ports,
  5. get_internal_ip,
  6. run_container,
  7. start_container,
  8. stop_container,
  9. copy_in
  10. )
  11. import unicodedata
  12. import stringcase
  13. import os
  14. _ODOO_DEFAULT_PATHS = ('/custom-addons', '')
  15. def snakeize_name(name):
  16. try:
  17. name = unicodedata.normalize('NFKD', name)
  18. name = name.encode('ASCII', 'ignore')
  19. except TypeError:
  20. name = ''
  21. name = stringcase.trimcase(name)
  22. name = stringcase.lowercase(name)
  23. name = stringcase.snakecase(name)
  24. return name
  25. def check_name_availability(name):
  26. full_path = os.path.join('TODO', name)
  27. return os.path.exists(full_path)
  28. def randomize_port():
  29. ports = []
  30. port = 0
  31. while not check_port_availability(port):
  32. port = randint(ports[0], ports[1])
  33. return port
  34. def check_port_availability(port):
  35. return port not in get_all_external_ports()
  36. def make_default_dirs(name):
  37. pass
  38. def make_config_file(name):
  39. pass
  40. def create_database(name):
  41. pass
  42. def copy_database_seed():
  43. pass
  44. def restore_database(name):
  45. pass
  46. def remove_database_seed():
  47. pass
  48. def create_container(name, ports):
  49. pass
  50. def apply_permissions(name):
  51. pass
  52. def get_internal_ip(name):
  53. pass