config.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #config.py
  2. import os
  3. import time
  4. from sikuli.Sikuli import *
  5. def set_image_dirs():
  6. """Set the Sikuli image path for the os specific
  7. image directory and the main Image dir.
  8. """
  9. os_imgs = os.path.join(
  10. os.path.dirname(
  11. os.path.abspath(__file__)), "Images_"+get_os_name())
  12. imgs = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Images")
  13. dir_list = [imgs, os_imgs]
  14. # Add the image dirs to the sikuli search
  15. # path if it is not in there already
  16. for d in dir_list:
  17. if d not in list(getImagePath()):
  18. addImagePath(d)
  19. def get_os_name():
  20. """Returns the os string for the SUT
  21. """
  22. if "MAC" in str(Env.getOS()):
  23. return "osx"
  24. elif "WINDOWS" in str(Env.getOS()):
  25. return "win"
  26. elif "LINUX" in str(Env.getOS()):
  27. return "lin"
  28. else:
  29. print("I don't know how to handle platform '%s'", Env.getOS())
  30. def launch_cmd():
  31. """Returns the launch path for the application.
  32. launch is an os specific command
  33. """
  34. if get_os_name() == "osx":
  35. launch_cmd = "/Applications/Libre Video Converter.app"
  36. elif get_os_name() == "win":
  37. launch_cmd = os.path.join(
  38. os.getenv("PROGRAMFILES"),
  39. "Participatory Culture Foundation",
  40. "Libre Video Converter",
  41. "LibreVideoConverter.exe")
  42. else:
  43. print(get_os_name())
  44. print(launch_cmd)
  45. return launch_cmd