コード例 #1
0
def create_feature(feature_name, container_name=None, location=None):
    '''
    Create a feature <feature_name>.

    If <location> and <container_name> is specified, an error is raised.
    If <location> is given the feature is created at that location(relative from current working directory)
    If <container_name> is given the feature is created in the "features" directory of the given container.
    If neither <location> nor <container_name> is given, the feature is created in the current container - if
    no container is active an error is raised.
    '''

    if location and container_name:
        print 'ERROR: combining container_name and location options is not supported.'
        sys.exit(1)

    if not location and not container_name:
        container_name = os.environ['CONTAINER_NAME']

    if container_name:
        location = os.path.join(tasks.get_container_dir(container_name), 'features')
    else:
        location = os.path.abspath(os.path.normpath(location))

    from cookiecutter.generate import generate_files
    from django_productline.context import PRODUCT_CONTEXT
    template_dir = tasks.get_cookiecutter_template_dir('djpl_feature')

    feature_dir = os.path.join(location, feature_name)
    if os.path.isdir(feature_dir):
        print 'ERROR: %s already exists.' % feature_dir
        return

    generate_files(
        template_dir,
        context=dict(
            cookiecutter={
                'feature_name': feature_name,
            }
        ),
        output_dir=location
    )
    print '*** Created feature %s in %s' % (feature_name, location)
コード例 #2
0
def create_feature(feature_name, container_name=None, location=None):
    '''
    Create a feature <feature_name>.

    If <location> and <container_name> is specified, an error is raised.
    If <location> is given the feature is created at that location(relative from current working directory)
    If <container_name> is given the feature is created in the "features" directory of the given container.
    If neither <location> nor <container_name> is given, the feature is created in the current container - if
    no container is active an error is raised.
    '''

    if location and container_name:
        print 'ERROR: combining container_name and location options is not supported.'
        sys.exit(1)

    if not location and not container_name:
        container_name = os.environ['CONTAINER_NAME']

    if container_name:
        location = os.path.join(tasks.get_container_dir(container_name), 'features')
    else:
        location = os.path.abspath(os.path.normpath(location))

    from cookiecutter.generate import generate_files
    from django_productline.context import PRODUCT_CONTEXT
    template_dir = tasks.get_cookiecutter_template_dir('djpl_feature')

    feature_dir = os.path.join(location, feature_name)
    if os.path.isdir(feature_dir):
        print 'ERROR: %s already exists.' % feature_dir
        return

    generate_files(
        template_dir,
        context=dict(
            cookiecutter={
                'feature_name': feature_name,
            }
        ),
        output_dir=location
    )
    print '*** Created feature %s in %s' % (feature_name, location)
コード例 #3
0
def create_product(poi):
    '''
    Create a product <product_name> in <container_name>. The argument <poi> is in the form
    container_name:product_name
    '''
    container_name, product_name = get_location(poi)
    from cookiecutter.generate import generate_files
    import uuid
    template_dir = tasks.get_cookiecutter_template_dir('djpl_product')
    webapps = os.environ['APE_ROOT_DIR']
    container_dir = '%s/%s' % (webapps, container_name)

    if not os.path.isdir(container_dir):
        print 'ERROR: %s is not a valid container as it does not exist.' % container_dir
        return

    products_dir = container_dir + '/products'
    if not os.path.isdir(products_dir):
        print 'ERROR: %s must contain a "products" directory.' % container_dir
        return

    product_dir = products_dir + '/' + product_name
    if os.path.isdir(product_dir):
        print 'ERROR: the product "%s:%s" already exists. Choose another product name or delete this product and try again.' % (container_name, product_name)
        return

    generate_files(
        template_dir,
        context=dict(
            cookiecutter={
                'product_name': product_name,
                'product_dir': product_dir,
                'secret_key': str(uuid.uuid1())
            }
        ),
        output_dir=products_dir
    )
    print '*** Created product %s:%s' % (container_name, product_name)
コード例 #4
0
def create_product(poi):
    '''
    Create a product <product_name> in <container_name>. The argument <poi> is in the form
    container_name:product_name
    '''
    container_name, product_name = get_location(poi)
    from cookiecutter.generate import generate_files
    import uuid
    template_dir = tasks.get_cookiecutter_template_dir('djpl_product')
    webapps = os.environ['APE_ROOT_DIR']
    container_dir = '%s/%s' % (webapps, container_name)

    if not os.path.isdir(container_dir):
        print 'ERROR: %s is not a valid container as it does not exist.' % container_dir
        return

    products_dir = container_dir + '/products'
    if not os.path.isdir(products_dir):
        print 'ERROR: %s must contain a "products" directory.' % container_dir
        return

    product_dir = products_dir + '/' + product_name
    if os.path.isdir(product_dir):
        print 'ERROR: the product "%s:%s" already exists. Choose another product name or delete this product and try again.' % (container_name, product_name)
        return

    generate_files(
        template_dir,
        context=dict(
            cookiecutter={
                'product_name': product_name,
                'product_dir': product_dir,
                'secret_key': str(uuid.uuid1())
            }
        ),
        output_dir=products_dir
    )
    print '*** Created product %s:%s' % (container_name, product_name)
コード例 #5
0
def create_container(container_name):
    '''
    Create a container <container_name>.
    '''
    from cookiecutter.generate import generate_files
    template_dir = tasks.get_cookiecutter_template_dir('djpl_container')
    webapps = os.environ['APE_ROOT_DIR']
    container_dir = '%s/%s' % (webapps, container_name)

    if os.path.isdir(container_dir):
        print 'ERROR: %s already exists.' % container_dir
        return

    generate_files(
        template_dir,
        context=dict(
            cookiecutter={
                'container_name': container_name,
            }
        ),
        output_dir=webapps
    )
    print '*** Created container %s' % (container_name)
コード例 #6
0
def create_container(container_name):
    '''
    Create a container <container_name>.
    '''
    from cookiecutter.generate import generate_files
    template_dir = tasks.get_cookiecutter_template_dir('djpl_container')
    webapps = os.environ['APE_ROOT_DIR']
    container_dir = '%s/%s' % (webapps, container_name)

    if os.path.isdir(container_dir):
        print 'ERROR: %s already exists.' % container_dir
        return

    generate_files(
        template_dir,
        context=dict(
            cookiecutter={
                'container_name': container_name,
            }
        ),
        output_dir=webapps
    )
    print '*** Created container %s' % (container_name)