config.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/python
  2. # ex:ts=4:sw=4:sts=4:et
  3. # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
  4. #
  5. # Copyright (C) 2015 Alexandru Damian for Intel Corp.
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License version 2 as
  9. # published by the Free Software Foundation.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License along
  17. # with this program; if not, write to the Free Software Foundation, Inc.,
  18. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. # This is the configuration/single module for tts
  20. # everything that would be a global variable goes here
  21. import os, sys, logging
  22. import socket
  23. LOGDIR = "log"
  24. SETTINGS_FILE = os.path.join(os.path.dirname(__file__), "settings.json")
  25. TEST_DIR_NAME = "tts_testdir"
  26. DEBUG = True
  27. OWN_PID = os.getpid()
  28. W3C_VALIDATOR = "http://icarus.local/w3c-validator/check?doctype=HTML5&uri="
  29. TOASTER_PORT = 56789
  30. TESTDIR = None
  31. #we parse the w3c URL to know where to connect
  32. import urlparse
  33. def get_public_ip():
  34. temp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  35. parsed_url = urlparse.urlparse("http://icarus.local/w3c-validator/check?doctype=HTML5&uri=")
  36. temp_socket.connect((parsed_url.netloc, 80 if parsed_url.port is None else parsed_url.port))
  37. public_ip = temp_socket.getsockname()[0]
  38. temp_socket.close()
  39. return public_ip
  40. TOASTER_BASEURL = "http://%s:%d/" % (get_public_ip(), TOASTER_PORT)
  41. OWN_EMAIL_ADDRESS = "Toaster Testing Framework <alexandru.damian@intel.com>"
  42. REPORT_EMAIL_ADDRESS = "alexandru.damian@intel.com"
  43. # make sure we have the basic logging infrastructure
  44. #pylint: disable=invalid-name
  45. # we disable the invalid name because the module-level "logger" is used througout bitbake
  46. logger = logging.getLogger("toastertest")
  47. __console__ = logging.StreamHandler(sys.stdout)
  48. __console__.setFormatter(logging.Formatter("%(asctime)s %(levelname)s: %(message)s"))
  49. logger.addHandler(__console__)
  50. logger.setLevel(logging.DEBUG)
  51. # singleton file names
  52. LOCKFILE = "/tmp/ttf.lock"
  53. BACKLOGFILE = os.path.join(os.path.dirname(__file__), "backlog.txt")
  54. # task states
  55. def enum(*sequential, **named):
  56. enums = dict(zip(sequential, range(len(sequential))), **named)
  57. reverse = dict((value, key) for key, value in enums.iteritems())
  58. enums['reverse_mapping'] = reverse
  59. return type('Enum', (), enums)
  60. class TASKS(object):
  61. #pylint: disable=too-few-public-methods
  62. PENDING = "PENDING"
  63. INPROGRESS = "INPROGRESS"
  64. DONE = "DONE"
  65. @staticmethod
  66. def next_task(task):
  67. if task == TASKS.PENDING:
  68. return TASKS.INPROGRESS
  69. if task == TASKS.INPROGRESS:
  70. return TASKS.DONE
  71. raise Exception("Invalid next task state for %s" % task)
  72. # TTS specific
  73. CONTRIB_REPO = "git@git.yoctoproject.org:poky-contrib"