Beispiel #1
0
def less(environment, opts):
    # pylint: disable=unused-argument
    """Recompiles less files in an environment.

Usage:
  datacats less [ENVIRONMENT]

ENVIRONMENT may be an environment name or a path to an environment directory.
Default: '.'
"""
    require_extra_image(LESSC_IMAGE)

    print 'Converting .less files to .css...'
    for log in environment.compile_less():
        print log
Beispiel #2
0
def less(environment, opts):
    # pylint: disable=unused-argument
    """Recompiles less files in an environment.

Usage:
  datacats less [ENVIRONMENT]

ENVIRONMENT may be an environment name or a path to an environment directory.
Default: '.'
"""
    require_extra_image(LESSC_IMAGE)

    print 'Converting .less files to .css...'
    for log in environment.compile_less():
        print log
Beispiel #3
0
def reload_(environment, opts):
    """Reload environment source and configuration

Usage:
  datacats reload [-b] [-p|--no-watch] [--syslog] [-s NAME] [--address=IP] [ENVIRONMENT [PORT]]
  datacats reload -r [-b] [--syslog] [-s NAME] [--address=IP] [ENVIRONMENT]

Options:
  --address=IP       Address to listen on (Linux-only) [default: 127.0.0.1]
  -b --background    Don't wait for response from web server
  --no-watch         Do not automatically reload templates and .py files on change
  -p --production    Reload with apache and debug=false
  -r --remote        Reload DataCats.com cloud instance
  -s --site=NAME     Specify a site to reload [default: primary]
  --syslog           Log to the syslog

ENVIRONMENT may be an environment name or a path to an environment directory.
Default: '.'
"""
    environment.require_data()
    environment.stop_ckan()
    if opts['PORT'] or opts['--address'] != '127.0.0.1':
        if opts['PORT']:
            environment.port = int(opts['PORT'])
        if opts['--address'] != '127.0.0.1':
            environment.address = opts['--address']
        environment.save()

    for container in environment.extra_containers:
        require_extra_image(EXTRA_IMAGE_MAPPING[container])

    environment.stop_supporting_containers()
    environment.start_supporting_containers()

    environment.start_ckan(
        production=opts['--production'],
        address=opts['--address'],
        paster_reload=not opts['--no-watch'],
        log_syslog=opts['--syslog'])
    write('Starting web server at {0} ...'.format(environment.web_address()))
    if opts['--background']:
        write('\n')
        return

    try:
        environment.wait_for_web_available()
    finally:
        write('\n')
Beispiel #4
0
def reload_(environment, opts):
    """Reload environment source and configuration

Usage:
  datacats reload [-b] [-p|--no-watch] [--syslog] [-s NAME] [--site-url=SITE_URL]
                            [--address=IP] [ENVIRONMENT [PORT]]
  datacats reload -r [-b] [--syslog] [-s NAME] [--address=IP] [--site-url=SITE_URL]
                            [ENVIRONMENT]

Options:
  --address=IP          Address to listen on (Linux-only) [default: 127.0.0.1]
  --site-url=SITE_URL   The site_url to use in API responses. Can use Python template syntax
                        to insert the port and address (e.g. http://example.org:{port}/)
  -b --background       Don't wait for response from web server
  --no-watch            Do not automatically reload templates and .py files on change
  -p --production       Reload with apache and debug=false
  -r --remote           Reload DataCats.com cloud instance
  -s --site=NAME        Specify a site to reload [default: primary]
  --syslog              Log to the syslog

ENVIRONMENT may be an environment name or a path to an environment directory.
Default: '.'
"""
    environment.require_data()
    environment.stop_ckan()
    if opts['PORT'] or opts['--address'] != '127.0.0.1' or opts['--site-url']:
        if opts['PORT']:
            environment.port = int(opts['PORT'])
        if opts['--address'] != '127.0.0.1':
            environment.address = opts['--address']
        if opts['--site-url']:
            site_url = opts['--site-url']
            # TODO: Check it against a regex or use urlparse
            try:
                site_url = site_url.format(address=environment.address, port=environment.port)
                environment.site_url = site_url
                environment.save_site(False)
            except (KeyError, IndexError, ValueError) as e:
                raise DatacatsError('Could not parse site_url: {}'.format(e))
        environment.save()

    for container in environment.extra_containers:
        require_extra_image(EXTRA_IMAGE_MAPPING[container])

    environment.stop_supporting_containers()
    environment.start_supporting_containers()

    environment.start_ckan(
        production=opts['--production'],
        address=opts['--address'],
        paster_reload=not opts['--no-watch'],
        log_syslog=opts['--syslog'],)
    write('Starting web server at {0} ...'.format(environment.web_address()))
    if opts['--background']:
        write('\n')
        return

    try:
        environment.wait_for_web_available()
    finally:
        write('\n')