Beispiel #1
0
def main():
    args = docopt(__doc__, version=_get_version(), options_first=True)

    cmd = args['COMMAND'] or 'snap'
    if cmd not in _VALID_COMMANDS:
        sys.exit('Command {!r} was not recognized'.format(cmd))

    # Default log level is INFO unless --debug is specified
    log_level = logging.INFO
    if args['--debug']:
        log_level = logging.DEBUG

    log.configure(log_level=log_level)

    common.set_enable_parallel_builds(not args['--no-parallel-build'])

    if args['--target-arch']:
        common.set_target_machine(args['--target-arch'])

    try:
        commands.load(cmd).main(argv=args['ARGS'])
    except Exception as e:
        if args['--debug']:
            raise

        sys.exit(textwrap.fill(str(e)))
Beispiel #2
0
def main(argv=None):
    args = docopt(__doc__, version=_get_version(), argv=argv)

    # Default log level is INFO unless --debug is specified
    log_level = logging.INFO
    if args['--debug']:
        log_level = logging.DEBUG

    log.configure(log_level=log_level)

    common.set_enable_parallel_builds(not args['--no-parallel-build'])

    project_options = snapcraft.ProjectOptions()
    if args['--enable-geoip']:
        project_options.use_geoip = True

    if args['--target-arch']:
        common.set_target_machine(args['--target-arch'])

    try:
        run(args, project_options)
    except Exception as e:
        if args['--debug']:
            raise

        sys.exit(textwrap.fill(str(e)))
Beispiel #3
0
def main():
    args = docopt(__doc__, version=_get_version(), options_first=True)

    cmd = args['COMMAND'] or 'snap'
    if cmd not in _VALID_COMMANDS:
        sys.exit('Command {!r} was not recognized'.format(cmd))

    # Default log level is INFO unless --debug is specified
    log_level = logging.INFO
    if args['--debug']:
        log_level = logging.DEBUG

    log.configure(log_level=log_level)

    common.set_enable_parallel_builds(not args['--no-parallel-build'])

    try:
        commands.load(cmd).main(argv=args['ARGS'])
    except Exception as e:
        if args['--debug']:
            raise

        sys.exit(textwrap.fill(str(e)))
Beispiel #4
0
 def test_get_parallel_build_count_disabled(self, mock_cpu_count):
     common.set_enable_parallel_builds(False)
     mock_cpu_count.return_value = 3
     self.assertEqual(common.get_parallel_build_count(), 1)
Beispiel #5
0
 def test_get_parallel_build_count_disabled(self, mock_cpu_count):
     common.set_enable_parallel_builds(False)
     mock_cpu_count.return_value = 3
     self.assertEqual(common.get_parallel_build_count(), 1)