# -*- python -*-
# ex: set filetype=python:

from buildbot.plugins import *

import lib

builds =  [ x for x in dir(lib) if "__" not in x ]

change = []
scheduler = []
build = []
for b in builds:
		c="builder = lib."+b+".Builder()"
		exec(c)
		
		if hasattr(builder, 'change'):
				ch = builder.change()
				change.append(ch)
				
		if hasattr(builder, 'build'):
				bu = builder.build()
				build.append(bu)

		if hasattr(builder, 'scheduler'):
                        s = builder.scheduler()
                        for si in s:
                                scheduler.append(si)

try:
	import privdir
	builds =  [ x for x in dir(privdir) if "__" not in x ]
	for b in builds:
		c="builder = privdir."+b+".Builder()"
		exec(c)
		
		if hasattr(builder, 'change'):
			ch = builder.change()
			change.append(ch)
				
		if hasattr(builder, 'build'):
			bu = builder.build()
			build.append(bu)

		if hasattr(builder, 'scheduler'):
			s = builder.scheduler()
			for si in s:
				scheduler.append(si)
	
except:
	print("[WARNING] privdir extention is not installed.")


c = BuildmasterConfig = {}

####### WORKERS

c['workers'] = [worker.Worker("bbmaster-worker", "pass"), \
worker.Worker("debrepo-worker", "pass"), \
]

c['protocols'] = {'pb': {'port': 9989}}

####### CHANGESOURCES

c['change_source'] = change

####### SCHEDULERS

c['schedulers'] = scheduler

####### BUILDERS

c['builders'] = build

####### BUILDBOT SERVICES

# 'services' is a list of BuildbotService items like reporter targets. The
# status of each build will be pushed to these targets. buildbot/reporters/*.py
# has a variety to choose from, like IRC bots.

c['services'] = []

# Email notifications
from buildbot.plugins import reporters

mn = reporters.MailNotifier(fromaddr="buildbot@botsoftware.com",
                           extraRecipients=["myemail@example.com",],
                           sendToInterestedUsers=False)
c['services'].append(mn)


####### PROJECT IDENTITY

# the 'title' string will appear at the top of this buildbot installation's
# home pages (linked to the 'titleURL').

c['title'] = "Hello World CI"
c['titleURL'] = "https://buildbot.github.io/hello-world/"

# the 'buildbotURL' string should point to the location where the buildbot's
# internal web server is visible. This typically uses the port number set in
# the 'www' entry below, but with an externally-visible host name which the
# buildbot cannot figure out without some help.

c['buildbotURL'] = "http://localhost:8010/"

# minimalistic config to activate new web UI
c['www'] = dict(port=8010,
                plugins=dict(waterfall_view={}, console_view={}, grid_view={}))

####### DB URL

c['db'] = {
    # This specifies what database buildbot uses to store its state.
    # It's easy to start with sqlite, but it's recommended to switch to a dedicated
    # database, such as PostgreSQL or MySQL, for use in production environments.
    # http://docs.buildbot.net/current/manual/configuration/global.html#database-specification
    'db_url' : "sqlite:///state.sqlite",
}
