aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/autobuilder/buildsteps/UploadToasterEventlog.py
blob: 8cf24035d315aae824829c98d7db84d316a980c7 (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
'''
Created on Dec 9, 2014

__author__ = "Alex Damian"
__copyright__ = "Copyright 2012-2014, Intel Corp."
__credits__ = ["Elizabeth Flanagan"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Alex Damian"
__email__ = "alexandru.damian@intel.com"
'''


from buildbot.steps.shell import ShellCommand
from buildbot.process.buildstep import LogLineObserver
from autobuilder.config import *


class UploadToasterEventlog(ShellCommand):
    haltOnFailure = False
    flunkOnFailure = True
    name = "UploadToasterEventlog"
    def __init__(self, factory, argdict=None, **kwargs):
        self.factory = factory
        self.workerdir=os.path.join(os.path.join(YOCTO_ABBASE, "yocto-worker"))
        for k, v in argdict.iteritems():
            setattr(self, k, v)
        # Timeout needs to be passed to LoggingBuildStep as a kwarg
        self.timeout = 2000
        kwargs['timeout']=self.timeout
        ShellCommand.__init__(self, **kwargs)

    def start(self):
        self.workerdir=os.path.join(os.path.join(YOCTO_ABBASE, "yocto-worker"))
        self.buildername=self.getProperty("buildername")
        self.layerversion_core = int(self.getProperty("layerversion_core", "0"))
        try:
            self.create_eventlog = self.getProperty("custom_create_eventlog")
        except:
            self.create_eventlog = "False"

        if self.layerversion_core < 5 or self.create_eventlog == "False":
            self.command = "echo 'Skipping Step.'"
            self.description = ["Uploading toaster data skipped"]
        else:
            if os.environ.get('TOASTER_UPLOAD_URL') is not None:
                self.filepath = os.path.join(os.path.join(
                                self.workerdir, self.buildername),
                                "build/build/tmp/log/bitbake_eventlog-*.json")
                self.toasterserver = str(os.environ.get('TOASTER_UPLOAD_URL'))

                self.command = "for fn in %s; do " % self.filepath
                self.command += "curl -F eventlog=@$fn " + self.toasterserver + ";"
                self.command += "done"
            else:
                self.command = "echo environment var TOASTER_UPLOADURL not set - Step is noop"
            self.description = ["Uploading toaster data"]
        ShellCommand.start(self)