Exemple #1
0
import os, sys
from os.path import dirname as pdir, join as pjoin
_bbot_parent_dir = pdir(pdir(pdir(__file__)))
if _bbot_parent_dir not in sys.path:
    sys.path.insert(0, _bbot_parent_dir)
Exemple #2
0
Generated by 'django-admin startproject' using Django 2.2.6.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
import json
from os.path import join as pjoin
from os.path import dirname as pdir
from datetime import timedelta
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = pdir(pdir(pdir(os.path.abspath(__file__))))

# load config files
CONFIG_DIR = pjoin(BASE_DIR, '.config')
CONFIG_BASE_FILE = pjoin(CONFIG_DIR, 'settings_base.json')
CONFIG_DEBUG_FILE = pjoin(CONFIG_DIR, 'settings_debug.json')
CONFIG_DEPLOY_FILE = pjoin(CONFIG_DIR, 'settings_deploy.json')

config_base = json.loads(open(CONFIG_BASE_FILE).read())


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config_base['django']['secret_key']
Exemple #3
0
# -*- coding:utf-8 -*-

import logging
from os.path import dirname as pdir
from os.path import join as pjoin

from pony.orm import Database

ROOT_PATH = pdir(pdir(__file__))
DB_PATH = pjoin(ROOT_PATH, 'db', 'project.db')
logging.basicConfig(
    filename=pjoin(ROOT_PATH, 'db', 'project.log'),
    format='[%(asctime)-15s] [%(processName)s:%(process)d] %(name)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
    level=logging.INFO
)

db = Database('sqlite', DB_PATH, create_db=True)

protocols = pjoin(ROOT_PATH, 'protocols')
Exemple #4
0
def load_template(name):
    return open(pjoin(pdir(__file__), name + '.template')).read()
Exemple #5
0
from __future__ import print_function, absolute_import

from os.path import abspath, join as pjoin, dirname as pdir
import os
import json
import re

#from jsonschema import Draft4Validator

SCHEMA_FOLDER_NAME = 'jcf_schema'
MAIN_SCHEMA = 'main.json'
SCHEMA_FOLDER = pjoin(pdir(__file__), SCHEMA_FOLDER_NAME)


class VersionNumberError(Exception):
    pass


def unify_rule_version(version):
    r"""
    unify version number from "a.b.c" to "a_b_c"

    >>> unify_rule_version('2_0_5')
    '2_0_5'
    >>> unify_rule_version('1.12.4')
    '1_12_4'
    >>> unify_rule_version('a____A')
    Traceback (most recent call last):
        ...
    VersionNumberError: Not a good form. Expected form: "2_0_5", or "1.12.4"
    """
Exemple #6
0
import os, sys
from os.path import dirname as pdir, join as pjoin

_bbot_parent_dir = pdir(pdir(pdir(__file__)))
if _bbot_parent_dir not in sys.path:
    sys.path.insert(0, _bbot_parent_dir)
Exemple #7
0
class BuildMaster(Bot):
    """
    Represents a test of a BuildMaster installation
    """

    #
    # constants
    #
    master_cfg_template = load_template('master.cfg')

    environ = dict(os.environ.items() +
                   [('PYTHONPATH', pdir(pdir(bbot.__file__)))])

    executable = 'buildbot'

    #
    # instance attributes
    #
    name = None
    """Name of the directory where the configuration sourcec lives"""

    bot_dir = None
    """Path to the directory where "buildbot create-master" gets run"""

    src_dir = None
    """Path to the directory containing the configuration source files"""
    def __init__(self, config_fn, name='buildmaster'):
        super(BuildMaster, self).__init__()
        self.name = name

        # Create a submodule
        self.src_dir = self.bot_dir / self.name
        os.mkdir(self.src_dir)
        open(self.src_dir / '__init__.py', 'w')

        # Create the master.cfg file
        master_cfg = self.src_dir / 'master.cfg'
        open(master_cfg,
             'w').write(self.master_cfg_template % dict(name=self.name))

        # Add a link to master.cfg in the bot directory
        _link_or_copy(master_cfg, self.bot_dir / 'master.cfg')

        # Generate config.py
        config_fn(self.src_dir)

    def check_cmd(self, *popenargs, **kwargs):
        cmd = kwargs.pop('args', None)
        if cmd is None:
            cmd = popenargs[0]
            popenargs = popenargs[1:]
        cwd = kwargs.pop('cwd', self.bot_dir)

        quietly.check_call(*popenargs,
                           args=['buildbot'] + cmd,
                           env=self.environ,
                           cwd=cwd,
                           **kwargs)

    def create_master(self):
        self.check_cmd(['create-master', '-r'])
Exemple #8
0
def load_template(name):
    return open(pjoin(pdir(__file__), name+'.template')).read()