示例#1
0
        config = jhbuild.config.Config(options.configfile)
    except FatalError, exc:
        sys.stderr.write('jhbuild: %s\n' %
                         exc.args[0].encode(_encoding, 'replace'))
        sys.exit(1)

    if options.moduleset: config.moduleset = options.moduleset
    if options.nointeract: config.interact = False

    if not args or args[0][0] == '-':
        command = 'build'  # default to cvs update + compile
    else:
        command = args[0]
        args = args[1:]

    warn_local_modulesets(config)

    try:
        rc = jhbuild.commands.run(command,
                                  config,
                                  args,
                                  help=lambda: print_help(parser))
    except UsageError, exc:
        sys.stderr.write('jhbuild %s: %s\n' %
                         (command, exc.args[0].encode(_encoding, 'replace')))
        parser.print_usage()
        sys.exit(1)
    except FatalError, exc:
        sys.stderr.write('jhbuild %s: %s\n' %
                         (command, exc.args[0].encode(_encoding, 'replace')))
        sys.exit(1)
示例#2
0
def main(args):
    localedir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'mo'))
    if not os.path.exists(localedir):
        localedir = None
    gettext.install('jhbuild', localedir=localedir, unicode=True)

    if hasattr(os, 'getuid') and os.getuid() == 0:
        sys.stderr.write(_('You should not run jhbuild as root.\n').encode(_encoding, 'replace'))
        sys.exit(1)

    logging.getLogger().setLevel(logging.INFO)
    logging_handler = logging.StreamHandler()
    logging_handler.setFormatter(LoggingFormatter())
    logging.getLogger().addHandler(logging_handler)
    parser = optparse.OptionParser(
        usage=_('%prog [ -f config ] command [ options ... ]'),
        add_help_option=False,
        description=_('Build a set of modules from diverse repositories in correct dependency order (such as GNOME).'))
    parser.disable_interspersed_args()

    parser.add_option('-h', '--help', action='callback',
                      callback=lambda *args: print_help(parser),
                      help=_("Display this help and exit"))
    parser.add_option('--help-commands', action='callback',
                      callback=lambda *args: print_help(parser),
                      help=optparse.SUPPRESS_HELP)
    parser.add_option('-f', '--file', action='store', metavar='CONFIG',
                      type='string', dest='configfile',
                      default=os.environ.get("JHBUILDRC"),
                      help=_('use a non default configuration file'))
    parser.add_option('-m', '--moduleset', action='store', metavar='URI',
                      type='string', dest='moduleset', default=None,
                      help=_('use a non default module set'))
    parser.add_option('--no-interact', action='store_true',
                      dest='nointeract', default=False,
                      help=_('do not prompt for input'))
    parser.add_option('--exit-on-error', action='store_true',
                      dest='exit_on_error', default=False,
                      help=_('exit immediately when the build fails'))
    parser.add_option('--conditions', action='append',
                      dest='conditions', default=[],
                      help=_('modify the condition set'))

    options, args = parser.parse_args(args)

    try:
        config = jhbuild.config.Config(options.configfile, options.conditions)
    except FatalError as exc:
        sys.stderr.write('jhbuild: %s\n' % exc.args[0].encode(_encoding, 'replace'))
        sys.exit(1)

    if options.moduleset: config.moduleset = options.moduleset
    if options.nointeract: config.interact = False
    if options.exit_on_error: config.exit_on_error = True

    if not args or args[0][0] == '-':
        command = 'build' # default to cvs update + compile
    else:
        command = args[0]
        args = args[1:]

    warn_local_modulesets(config)

    try:
        rc = jhbuild.commands.run(command, config, args, help=lambda: print_help(parser))
    except UsageError as exc:
        sys.stderr.write('jhbuild %s: %s\n' % (command, exc.args[0].encode(_encoding, 'replace')))
        parser.print_usage()
        sys.exit(1)
    except FatalError as exc:
        sys.stderr.write('jhbuild %s: %s\n' % (command, exc.args[0].encode(_encoding, 'replace')))
        sys.exit(1)
    except KeyboardInterrupt:
        uprint(_('Interrupted'))
        sys.exit(1)
    except EOFError:
        uprint(_('EOF'))
        sys.exit(1)
    except IOError as e:
        if e.errno != errno.EPIPE:
            raise
        sys.exit(0)
    if rc:
        sys.exit(rc)
示例#3
0
    try:
        config = jhbuild.config.Config(options.configfile)
    except FatalError, exc:
        sys.stderr.write('jhbuild: %s\n' % exc.args[0].encode(_encoding, 'replace'))
        sys.exit(1)

    if options.moduleset: config.moduleset = options.moduleset
    if options.nointeract: config.interact = False

    if not args or args[0][0] == '-':
        command = 'build' # default to cvs update + compile
    else:
        command = args[0]
        args = args[1:]

    warn_local_modulesets(config)

    try:
        rc = jhbuild.commands.run(command, config, args, help=lambda: print_help(parser))
    except UsageError, exc:
        sys.stderr.write('jhbuild %s: %s\n' % (command, exc.args[0].encode(_encoding, 'replace')))
        parser.print_usage()
        sys.exit(1)
    except FatalError, exc:
        sys.stderr.write('jhbuild %s: %s\n' % (command, exc.args[0].encode(_encoding, 'replace')))
        sys.exit(1)
    except KeyboardInterrupt:
        uprint(_('Interrupted'))
        sys.exit(1)
    except EOFError:
        uprint(_('EOF'))
示例#4
0
def main(args):
    if DATADIR is not None:
        localedir = os.path.join(DATADIR, 'locale')
    else:
        localedir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '..', 'mo'))

    if not os.path.exists(localedir):
        localedir = None
    install_translation(
        gettext.translation('jhbuild', localedir=localedir, fallback=True))

    if 'JHBUILD_RUN_AS_ROOT' not in os.environ and hasattr(
            os, 'getuid') and os.getuid() == 0:
        uprint(_('You should not run jhbuild as root.\n'), file=sys.stderr)
        sys.exit(1)

    logging.getLogger().setLevel(logging.INFO)
    logging_handler = logging.StreamHandler()
    logging_handler.setFormatter(LoggingFormatter())
    logging.getLogger().addHandler(logging_handler)
    parser = optparse.OptionParser(
        usage=_('%prog [ -f config ] command [ options ... ]'),
        add_help_option=False,
        description=
        _('Build a set of modules from diverse repositories in correct dependency order (such as GNOME).'
          ))
    parser.disable_interspersed_args()

    parser.add_option('-h',
                      '--help',
                      action='callback',
                      callback=lambda *args: print_help(parser),
                      help=_("Display this help and exit"))
    parser.add_option('--help-commands',
                      action='callback',
                      callback=lambda *args: print_help(parser),
                      help=optparse.SUPPRESS_HELP)
    parser.add_option('-f',
                      '--file',
                      action='store',
                      metavar='CONFIG',
                      type='string',
                      dest='configfile',
                      default=os.environ.get("JHBUILDRC"),
                      help=_('use a non default configuration file'))
    parser.add_option('-m',
                      '--moduleset',
                      action='store',
                      metavar='URI',
                      type='string',
                      dest='moduleset',
                      default=None,
                      help=_('use a non default module set'))
    parser.add_option('--no-interact',
                      action='store_true',
                      dest='nointeract',
                      default=False,
                      help=_('do not prompt for input'))
    parser.add_option('--exit-on-error',
                      action='store_true',
                      dest='exit_on_error',
                      default=False,
                      help=_('exit immediately when the build fails'))
    parser.add_option('--conditions',
                      action='append',
                      dest='conditions',
                      default=[],
                      help=_('modify the condition set'))

    options, args = parser.parse_args(args)

    try:
        config = jhbuild.config.Config(options.configfile, options.conditions)
    except FatalError as exc:
        uprint('jhbuild: %s\n' % exc.args[0], file=sys.stderr)
        sys.exit(1)

    if options.moduleset:
        config.moduleset = options.moduleset
    if options.nointeract:
        config.interact = False
    if options.exit_on_error:
        config.exit_on_error = True

    if not args or args[0][0] == '-':
        command = 'help'
    else:
        command = args[0]
        args = args[1:]

    warn_local_modulesets(config)

    try:
        rc = jhbuild.commands.run(command,
                                  config,
                                  args,
                                  help=lambda: print_help(parser))
    except UsageError as exc:
        uprint('jhbuild %s: %s\n' % (command, exc.args[0]), file=sys.stderr)
        parser.print_usage()
        sys.exit(1)
    except FatalError as exc:
        uprint('jhbuild %s: %s\n' % (command, exc.args[0]), file=sys.stderr)
        sys.exit(1)
    except KeyboardInterrupt:
        uprint(_('Interrupted'))
        sys.exit(1)
    except EOFError:
        uprint(_('EOF'))
        sys.exit(1)
    except IOError as e:
        if e.errno != errno.EPIPE:
            raise
        sys.exit(0)
    if rc:
        sys.exit(rc)