def processwwwindex(config):
    master = yield fakemaster.make_master()
    master_service = WWWService()
    master_service.setServiceParent(master)
    if not config.get('index-file'):
        print(
            "Path to the index.html file is required with option --index-file or -i"
        )
        defer.returnValue(1)
    path = config.get('index-file')
    if not os.path.isfile(path):
        print("Invalid path to index.html")
        defer.returnValue(2)

    main_dir = os.path.dirname(path)

    for name in master_service.apps.names:
        if name != 'base':
            pluginapp = master_service.apps.get(name)
            try:
                os.symlink(pluginapp.static_dir, os.path.join(main_dir, name))
            except OSError:
                pass

    plugins = dict((k, {}) for k in master_service.apps.names if k != "base")

    fakeconfig = {"user": {"anonymous": True}}
    fakeconfig['buildbotURL'] = master.config.buildbotURL
    fakeconfig['title'] = master.config.title
    fakeconfig['titleURL'] = master.config.titleURL
    fakeconfig['multiMaster'] = master.config.multiMaster
    fakeconfig['versions'] = IndexResource.getEnvironmentVersions()
    fakeconfig['plugins'] = plugins
    fakeconfig['auth'] = auth.NoAuth().getConfigDict()
    outputstr = ''
    with open(path) as indexfile:
        template = jinja2.Template(indexfile.read())
        outputstr = template.render(configjson=json.dumps(fakeconfig),
                                    config=fakeconfig)
    with open(path, 'w') as indexfile:
        indexfile.write(outputstr)
    defer.returnValue(0)
Esempio n. 2
0
def processwwwindex(config):
    master = yield fakemaster.make_master()
    master_service = WWWService()
    master_service.setServiceParent(master)
    if not config.get('index-file'):
        print(
            "Path to the index.html file is required with option --index-file or -i")
        defer.returnValue(1)
    path = config.get('index-file')
    if not os.path.isfile(path):
        print("Invalid path to index.html")
        defer.returnValue(2)

    main_dir = os.path.dirname(path)

    for name in master_service.apps.names:
        if name != 'base':
            pluginapp = master_service.apps.get(name)
            try:
                os.symlink(pluginapp.static_dir, os.path.join(main_dir, name))
            except OSError:
                pass

    plugins = dict((k, {}) for k in master_service.apps.names if k != "base")

    fakeconfig = {"user": {"anonymous": True}}
    fakeconfig['buildbotURL'] = master.config.buildbotURL
    fakeconfig['title'] = master.config.title
    fakeconfig['titleURL'] = master.config.titleURL
    fakeconfig['multiMaster'] = master.config.multiMaster
    fakeconfig['versions'] = IndexResource.getEnvironmentVersions()
    fakeconfig['plugins'] = plugins
    fakeconfig['auth'] = auth.NoAuth().getConfigDict()
    outputstr = ''
    with open(path) as indexfile:
        template = jinja2.Template(indexfile.read())
        outputstr = template.render(
            configjson=json.dumps(fakeconfig), config=fakeconfig)
    with open(path, 'w') as indexfile:
        indexfile.write(outputstr)
    defer.returnValue(0)
Esempio n. 3
0
import argparse
import flask
import os
import requests

from buildbot.www.service import WWWService
from flask import Response
from flask import request
from flask import stream_with_context

master_service = WWWService(None)

main_dir = master_service.apps['base'].static_dir

application = flask.Flask(__name__, static_url_path='', static_folder=main_dir)

for k, v in master_service.apps.items():
    if k != "base":
        try:
            os.symlink(v.static_dir, os.path.join(main_dir, k))
        except OSError:
            pass


def get_url():
    global args
    url = request.url
    url = url.replace("http://localhost:8010", args.dest_buildbot)
    return url