Пример #1
0
def eventfile(request):
    """ Receives a file by POST, and runs toaster-eventreply on this file """
    if request.method != "POST":
        return HttpResponseBadRequest("This API only accepts POST requests. Post a file with:\n\ncurl -F eventlog=@bitbake_eventlog.json %s\n" % request.build_absolute_uri(reverse('eventfile')), content_type="text/plain;utf8")

    # write temporary file
    (handle, abstemppath) = tempfile.mkstemp(dir="/tmp/")
    with os.fdopen(handle, "w") as tmpfile:
        for chunk in request.FILES['eventlog'].chunks():
            tmpfile.write(chunk)
    tmpfile.close()

    # compute the path to "bitbake/bin/toaster-eventreplay"
    from os.path import dirname as DN
    import_script = os.path.join(DN(DN(DN(DN(os.path.abspath(__file__))))), "bin/toaster-eventreplay")
    if not os.path.exists(import_script):
        raise Exception("script missing %s" % import_script)
    scriptenv = os.environ.copy()
    scriptenv["DATABASE_URL"] = toastermain.settings.getDATABASE_URL()

    # run the data loading process and return the results
    importer = subprocess.Popen([import_script, abstemppath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=scriptenv)
    (out, err) = importer.communicate()
    if importer.returncode == 0:
        os.remove(abstemppath)
    return HttpResponse("== Retval %d\n== STDOUT\n%s\n\n== STDERR\n%s" % (importer.returncode, out, err), content_type="text/plain;utf8")
Пример #2
0
 def _createdirpath(self, path):
     from os.path import dirname as DN
     if path == "":
         raise Exception("Invalid path creation specified.")
     if not os.path.exists(DN(path)):
         self._createdirpath(DN(path))
     if not os.path.exists(path):
         os.mkdir(path, 0755)
Пример #3
0
    def getGitCloneDirectory(self, url, branch):
        """Construct unique clone directory name out of url and branch."""
        if branch != "HEAD":
            return "_toaster_clones/_%s_%s" % (re.sub('[:/@+%]', '_', url), branch)

        # word of attention; this is a localhost-specific issue; only on the localhost we expect to have "HEAD" releases
        # which _ALWAYS_ means the current poky checkout
        from os.path import dirname as DN
        local_checkout_path = DN(DN(DN(DN(DN(os.path.abspath(__file__))))))
        #logger.debug("localhostbecontroller: using HEAD checkout in %s" % local_checkout_path)
        return local_checkout_path
Пример #4
0
    def __init__(self, be):
        super(LocalhostBEController, self).__init__(be)
        from os.path import dirname as DN
        self.cwd = DN(DN(DN(DN(DN(os.path.realpath(__file__))))))
        if self.be.address is None or len(self.be.address) == 0:
            self.be.address = "build"
            self.be.save()
        self.bwd = self.be.address
        self.dburl = settings.getDATABASE_URL()

        # transform relative paths to absolute ones
        if not self.bwd.startswith("/"):
            self.bwd = os.path.join(self.cwd, self.bwd)
        self._createBE()
Пример #5
0
    def getGitCloneDirectory(self, url, branch):
        """ Utility that returns the last component of a git path as directory
        """
        import re
        components = re.split(r'[:\.\/]', url)
        base = components[-2] if components[-1] == "git" else components[-1]

        if branch != "HEAD":
            return "_%s_%s.toaster_cloned" % (base, branch)

        # word of attention; this is a localhost-specific issue; only on the localhost we expect to have "HEAD" releases
        # which _ALWAYS_ means the current poky checkout
        from os.path import dirname as DN
        local_checkout_path = DN(DN(DN(DN(DN(os.path.abspath(__file__))))))
        #logger.debug("localhostbecontroller: using HEAD checkout in %s" % local_checkout_path)
        return local_checkout_path
Пример #6
0
]

CACHES = {
    #        'default': {
    #            'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    #            'LOCATION': '127.0.0.1:11211',
    #        },
    'default': {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': '/tmp/toaster_cache_%d' % os.getuid(),
        'TIMEOUT': 1,
    }
}

from os.path import dirname as DN
SITE_ROOT = DN(DN(os.path.abspath(__file__)))

import subprocess
TOASTER_BRANCH = subprocess.Popen('git branch | grep "^* " | tr -d "* "',
                                  cwd=SITE_ROOT,
                                  shell=True,
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE).communicate()[0]
TOASTER_REVISION = subprocess.Popen('git rev-parse HEAD ',
                                    cwd=SITE_ROOT,
                                    shell=True,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE).communicate()[0]

ROOT_URLCONF = 'toastermain.urls'
Пример #7
0
 def _createdirpath(self, path):
     from os.path import dirname as DN
     if not os.path.exists(DN(path)):
         self._createdirpath(DN(path))
     if not os.path.exists(path):
         os.mkdir(path, 0755)