summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/contrib/tts/config.py
blob: c0e05369e615f29adfbad279a21451343ae6de05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/python

# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
#
# Copyright (C) 2015 Alexandru Damian for Intel Corp.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# This is the configuration/single module for tts
# everything that would be a global variable goes here

import os, sys, logging
import socket

LOGDIR = "log"
SETTINGS_FILE = os.path.join(os.path.dirname(__file__), "settings.json")
TEST_DIR_NAME = "tts_testdir"

OWN_PID = os.getpid()

W3C_VALIDATOR = "http://icarus.local/w3c-validator/check?doctype=HTML5&uri="

#TODO assign port dynamically
TOASTER_PORT=56789

#we parse the w3c URL to know where to connect

import urlparse

def get_public_ip():
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    p = urlparse.urlparse("http://icarus.local/w3c-validator/check?doctype=HTML5&uri=")
    s.connect(( p.netloc, 80 if p.port is None else p.port))
    hn = s.getsockname()[0]
    s.close()
    return hn

TOASTER_BASEURL="http://%s:%d/" % (get_public_ip(), TOASTER_PORT)


OWN_EMAIL_ADDRESS = "Toaster Testing Framework <alexandru.damian@intel.com>"
REPORT_EMAIL_ADDRESS = "alexandru.damian@intel.com"

# make sure we have the basic logging infrastructure
logger = logging.getLogger("toastertest")
__console = logging.StreamHandler(sys.stdout)
__console.setFormatter(logging.Formatter("%(asctime)s %(levelname)s: %(message)s"))
logger.addHandler(__console)
logger.setLevel(logging.DEBUG)


# singleton file names
LOCKFILE="/tmp/ttf.lock"
BACKLOGFILE=os.path.join(os.path.dirname(__file__), "backlog.txt")

# task states
def enum(*sequential, **named):
    enums = dict(zip(sequential, range(len(sequential))), **named)
    reverse = dict((value, key) for key, value in enums.iteritems())
    enums['reverse_mapping'] = reverse
    return type('Enum', (), enums)


class TASKS:
    PENDING = "PENDING"
    INPROGRESS = "INPROGRESS"
    DONE = "DONE"

    @staticmethod
    def next_task(task):
        if task == TASKS.PENDING:
            return TASKS.INPROGRESS
        if task == TASKS.INPROGRESS:
            return TASKS.DONE
        raise Exception("Invalid next task state for %s" % task)

# TTS specific
CONTRIB_REPO = "git@git.yoctoproject.org:poky-contrib"