Beispiel #1
0
def main():
    logging.basicConfig(level=logging.DEBUG,
                        format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                        datefmt='%m-%d %H:%M')
    logging.getLogger("requests").propagate = False
    logging.getLogger("sh").propagate = False

    log = logging.getLogger("chaosbot")

    if exists("voters.json"):
        log.info("Moving voters,json to server directory!")
        shutil.move("./voters.json", "./server/voters.json")

    api = gh.API(settings.GITHUB_USER, settings.GITHUB_SECRET)

    log.info("starting up and entering event loop")

    os.system("pkill chaos_server")

    server_dir = join(dirname(abspath(__file__)), "server")
    subprocess.Popen([sys.executable, "server.py"], cwd=server_dir)

    # Schedule all cron jobs to be run
    cron.schedule_jobs()

    log.info("Setting description to {desc}".format(desc=settings.REPO_DESCRIPTION))
    github_api.repos.set_desc(api, settings.URN, settings.REPO_DESCRIPTION)

    while True:
        # Run any scheduled jobs on the next second.
        schedule.run_pending()
        time.sleep(1)
Beispiel #2
0
def main():
    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger("requests").propagate = False
    logging.getLogger("sh").propagate = False

    log = logging.getLogger("chaosbot")

    api = gh.API(settings.GITHUB_USER, settings.GITHUB_SECRET)

    log.info("starting up and entering event loop")

    os.system("pkill chaos_server")

    server_dir = join(dirname(abspath(__file__)), "server")
    subprocess.Popen([sys.executable, "server.py"], cwd=server_dir)

    #log.info("starting http server")
    #start_http_server()

    # Schedule all cron jobs to be run
    cron.schedule_jobs()

    while True:
        # Run any scheduled jobs on the next second.
        schedule.run_pending()
        time.sleep(1)
Beispiel #3
0
def main():
    # Set up logging stuff
    logging_handler_out = logging.StreamHandler(sys.stdout)
    logging_handler_out.setLevel(settings.LOG_LEVEL_OUT)
    logging_handler_out.addFilter(LessThanFilter(settings.LOG_LEVEL_ERR))

    logging_handler_err = logging.StreamHandler(sys.stderr)
    logging_handler_err.setLevel(settings.LOG_LEVEL_ERR)

    logging.basicConfig(
        level=logging.NOTSET,
        format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
        datefmt='%m-%d %H:%M',
        handlers=[logging_handler_out, logging_handler_err])

    logging.getLogger("requests").propagate = False
    logging.getLogger("sh").propagate = False
    logging.getLogger("peewee").propagate = False

    log = logging.getLogger("chaosbot")

    if exists("voters.json"):
        log.info("Moving voters.json to server directory!")
        shutil.move("./voters.json", "./server/voters.json")

    api = gh.API(settings.GITHUB_USER, settings.GITHUB_SECRET)

    log.info("checking if I crashed before...")

    # check if chaosbot is not on the tip of the master branch
    check_for_prev_crash(api, log)

    log.info("starting up and entering event loop")

    os.system("pkill uwsgi")

    subprocess.Popen([
        "/root/.virtualenvs/chaos/bin/uwsgi", "--socket", "127.0.0.1:8085",
        "--wsgi-file", "webserver.py", "--callable", "__hug_wsgi__",
        "--check-static", "/root/workspace/Chaos/server/", "--daemonize",
        "/root/workspace/Chaos/log/uwsgi.log"
    ])

    # Schedule all cron jobs to be run
    cron.schedule_jobs(api)

    log.info(
        "Setting description to {desc}".format(desc=settings.REPO_DESCRIPTION))
    github_api.repos.set_desc(api, settings.URN, settings.REPO_DESCRIPTION)

    log.info("Ensure creation of issue/PR labels")
    for label, color in settings.REPO_LABELS.items():
        github_api.repos.create_label(api, settings.URN, label, color)

    while True:
        # Run any scheduled jobs on the next second.
        schedule.run_pending()
        time.sleep(1)
Beispiel #4
0
def main():
    # Set up logging stuff
    logging_handler_out = logging.StreamHandler(sys.stdout)
    logging_handler_out.setLevel(settings.LOG_LEVEL_OUT)
    logging_handler_out.addFilter(LessThanFilter(settings.LOG_LEVEL_ERR))

    logging_handler_err = logging.StreamHandler(sys.stderr)
    logging_handler_err.setLevel(settings.LOG_LEVEL_ERR)

    logging.basicConfig(
        level=logging.NOTSET,
        format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
        datefmt='%m-%d %H:%M',
        handlers=[logging_handler_out, logging_handler_err])

    logging.getLogger("requests").propagate = False
    logging.getLogger("sh").propagate = False

    log = logging.getLogger("chaosbot")

    if exists("voters.json"):
        log.info("Moving voters.json to server directory!")
        shutil.move("./voters.json", "./server/voters.json")

    api = gh.API(settings.GITHUB_USER, settings.GITHUB_SECRET)

    log.info("checking if I crashed before...")

    # check if chaosbot is not on the tip of the master branch
    check_for_prev_crash(api, log)

    log.info("starting up and entering event loop")

    os.system("pkill chaos_server")

    server_dir = join(dirname(abspath(__file__)), "server")
    subprocess.Popen([sys.executable, "server.py"], cwd=server_dir)

    # Schedule all cron jobs to be run
    cron.schedule_jobs(api)

    log.info(
        "Setting description to {desc}".format(desc=settings.REPO_DESCRIPTION))
    github_api.repos.set_desc(api, settings.URN, settings.REPO_DESCRIPTION)

    log.info("Ensure creation of issue/PR labels")
    for label, color in settings.REPO_LABELS.items():
        github_api.repos.create_label(api, settings.URN, label, color)

    while True:
        # Run any scheduled jobs on the next second.
        schedule.run_pending()
        time.sleep(1)
Beispiel #5
0
from bot.main import mwexpress_bot
from log import mwelog
from cron import schedule_jobs, run_scheduled_jobs
from initial_data import load_initial_data

load_initial_data()

mwelog.info("Starting MWExpress...")

mwexpress_bot.listen()

schedule_jobs()
run_scheduled_jobs()