Ejemplo n.º 1
0
def run():
    import sys
    try:
        #
        # Run where defaults.mc is located
        #
        long_opts = {
            # key              macro        handler   param  defs   init
            '--file'  :      ('_file',      'path',   True,  None,  False)
        }
        opts = options.command_line(base_path = '.',
                                    argv = sys.argv,
                                    long_opts = long_opts)
        options.load(opts)
        s = file(opts.defaults['_file'], opts)
        s.load(opts.defaults['_file'])
        print(s)
        del s
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 2
0
def run():
    import sys
    try:
        #
        # Run where defaults.mc is located
        #
        long_opts = {
            # key              macro        handler   param  defs   init
            '--file': ('_file', 'path', True, None, False)
        }
        opts = options.command_line(base_path='.',
                                    argv=sys.argv,
                                    long_opts=long_opts)
        options.load(opts)
        s = file(opts.defaults['_file'], opts)
        s.load(opts.defaults['_file'])
        print(s)
        del s
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 3
0
    def __init__(self, width=640,height=480):
        pygame.init()
        self.width = width - width % sSize
        self.height = height - height % sSize

        self.screen = pygame.display.set_mode((self.width, self.height), flags=pygame.RESIZABLE)

        options.load()

        self.background = black
        self.gameState = 1

        self.mainMenu = MainMenu(self)
        self.game = Game(self)
Ejemplo n.º 4
0
def run(args):
    ec = 0
    try:
        optargs = {"--list-configs": "List available configurations"}
        opts = options.load(args, optargs)
        log.notice("RTEMS Source Builder, Package Builder v%s" % (version.str()))
        if not check.host_setup(opts):
            if not opts.force():
                raise error.general("host build environment is not set up" + " correctly (use --force to proceed)")
            log.notice("warning: forcing build with known host setup problems")
        if opts.get_arg("--list-configs"):
            configs = get_configs(opts)
            for p in configs["paths"]:
                print "Examining: %s" % (os.path.relpath(p))
                for c in configs["files"]:
                    if c.endswith(".cfg"):
                        print "    %s" % (c)
        else:
            for config_file in opts.config_files():
                b = build(config_file, True, opts)
                b.make()
                b = None
    except error.general, gerr:
        log.stderr("Build FAILED")
        ec = 1
def run(args):
    ec = 0
    try:
        optargs = {'--list-configs': 'List available configurations'}
        opts = options.load(args, optargs)
        log.notice('RTEMS Source Builder, Package Builder v%s' %
                   (version.str()))
        if not check.host_setup(opts):
            if not opts.force():
                raise error.general('host build environment is not set up' +
                                    ' correctly (use --force to proceed)')
            log.notice('warning: forcing build with known host setup problems')
        if opts.get_arg('--list-configs'):
            configs = get_configs(opts)
            for p in configs['paths']:
                print 'Examining: %s' % (os.path.relpath(p))
                for c in configs['files']:
                    if c.endswith('.cfg'):
                        print '    %s' % (c)
        else:
            for config_file in opts.config_files():
                b = build(config_file, True, opts)
                b.make()
                b = None
    except error.general, gerr:
        log.stderr('Build FAILED')
        ec = 1
Ejemplo n.º 6
0
def run(args):
    ec = 0
    try:
        optargs = { '--list-configs': 'List available configurations' }
        opts = options.load(args, optargs)
        log.notice('RTEMS Source Builder, Package Builder v%s' % (version.str()))
        if not check.host_setup(opts):
            if not opts.force():
                raise error.general('host build environment is not set up' +
                                    ' correctly (use --force to proceed)')
            log.notice('warning: forcing build with known host setup problems')
        if opts.get_arg('--list-configs'):
            configs = get_configs(opts)
            for p in configs['paths']:
                print 'Examining: %s' % (os.path.relpath(p))
                for c in configs['files']:
                    if c.endswith('.cfg'):
                        print '    %s' % (c)
        else:
            for config_file in opts.config_files():
                b = build(config_file, True, opts)
                b.make()
                b = None
    except error.general, gerr:
        log.stderr('Build FAILED')
        ec = 1
def run(args):
    try:
        optargs = { '--rtems':      'The RTEMS source directory',
                    '--rtems-bsp':  'The RTEMS BSP (arch/bsp)',
                    '--list':       'List the configurations' }
        opts = options.load(sys.argv, optargs)

        if opts.get_arg('--rtems'):
            prefix = opts.get_arg('--rtems')[1]
        else:
            prefix = os.getcwd()
        if opts.get_arg('--rtems-bsp') is None:
            raise error.general('no --rtems-bsp option; please provide')

        bsp = bsp_config(opts, prefix, opts.get_arg('--rtems-bsp')[1])

        if opts.get_arg('--list'):
            log.notice('RTEMS Source Builder - RTEMS Configuration, %s' % (version.str()))
            opts.log_info()
            configs = bsp.keys()
            for c in sorted(configs.keys()):
                print c
        else:
            for p in opts.params():
                print bsp.find(p)

    except error.general, gerr:
        print gerr
        sys.exit(1)
def run():
    import sys
    ec = 0
    setbuilder_error = False
    try:
        optargs = { '--list-configs':  'List available configurations',
                    '--list-bsets':    'List available build sets',
                    '--list-deps':     'List the dependent files.',
                    '--bset-tar-file': 'Create a build set tar file',
                    '--pkg-tar-files': 'Create package tar files',
                    '--no-report':     'Do not create a package report.',
                    '--report-format': 'The report format (text, html, asciidoc).' }
        mailer.append_options(optargs)
        opts = options.load(sys.argv, optargs)
        log.notice('RTEMS Source Builder - Set Builder, %s' % (version.str()))
        opts.log_info()
        if not check.host_setup(opts):
            raise error.general('host build environment is not set up correctly')
        configs = build.get_configs(opts)
        if opts.get_arg('--list-deps'):
            deps = []
        else:
            deps = None
        if not list_bset_cfg_files(opts, configs):
            prefix = opts.defaults.expand('%{_prefix}')
            if opts.canadian_cross():
                opts.disable_install()

            if not opts.dry_run() and \
               not opts.canadian_cross() and \
               not opts.no_install() and \
               not path.ispathwritable(prefix):
                raise error.general('prefix is not writable: %s' % (path.host(prefix)))
            for bset in opts.params():
                setbuilder_error = True
                b = buildset(bset, configs, opts)
                b.build(deps)
                b = None
                setbuilder_error = False
        if deps is not None:
            c = 0
            for d in sorted(set(deps)):
                c += 1
                print('dep[%d]: %s' % (c, d))
    except error.general as gerr:
        if not setbuilder_error:
            log.stderr(str(gerr))
        log.stderr('Build FAILED')
        ec = 1
    except error.internal as ierr:
        if not setbuilder_error:
            log.stderr(str(ierr))
        log.stderr('Internal Build FAILED')
        ec = 1
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        ec = 1
    sys.exit(ec)
Ejemplo n.º 9
0
def run():
    import sys
    ec = 0
    setbuilder_error = False
    try:
        optargs = { '--list-configs':  'List available configurations',
                    '--list-bsets':    'List available build sets',
                    '--list-deps':     'List the dependent files.',
                    '--bset-tar-file': 'Create a build set tar file',
                    '--pkg-tar-files': 'Create package tar files',
                    '--no-report':     'Do not create a package report.',
                    '--report-format': 'The report format (text, html, asciidoc).' }
        mailer.append_options(optargs)
        opts = options.load(sys.argv, optargs)
        log.notice('RTEMS Source Builder - Set Builder, %s' % (version.str()))
        opts.log_info()
        if not check.host_setup(opts):
            raise error.general('host build environment is not set up correctly')
        configs = build.get_configs(opts)
        if opts.get_arg('--list-deps'):
            deps = []
        else:
            deps = None
        if not list_bset_cfg_files(opts, configs):
            prefix = opts.defaults.expand('%{_prefix}')
            if opts.canadian_cross():
                opts.disable_install()

            if not opts.dry_run() and \
               not opts.canadian_cross() and \
               not opts.no_install() and \
               not path.ispathwritable(prefix):
                raise error.general('prefix is not writable: %s' % (path.host(prefix)))
            for bset in opts.params():
                setbuilder_error = True
                b = buildset(bset, configs, opts)
                b.build(deps)
                b = None
                setbuilder_error = False
        if deps is not None:
            c = 0
            for d in sorted(set(deps)):
                c += 1
                print('dep[%d]: %s' % (c, d))
    except error.general as gerr:
        if not setbuilder_error:
            log.stderr(str(gerr))
        log.stderr('Build FAILED')
        ec = 1
    except error.internal as ierr:
        if not setbuilder_error:
            log.stderr(str(ierr))
        log.stderr('Internal Build FAILED')
        ec = 1
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        ec = 1
    sys.exit(ec)
Ejemplo n.º 10
0
def main(playlist):
	interface = interfacer.Interfacer(options.load(), cmus.Cmus)

	main_window = gui.window.Window(interface)
	
	gtk.main()
	return 0
Ejemplo n.º 11
0
def run():
    import sys
    try:
        _opts = options.load(args=sys.argv, logfile=False)
        log.notice('RTEMS Source Builder - Check, %s' % (version.str()))

        orphans = _opts.parse_args('--check-orphans', error=False, extra=False)
        if orphans:
            print('Checking for orphans...')
            check_orphans(_opts)
        else:
            if host_setup(_opts):
                print('Environment is ok')
            else:
                print('Environment is not correctly set up')
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 12
0
def run():
    import sys
    try:
        _opts = options.load(args = sys.argv, logfile = False)
        log.notice('RTEMS Source Builder - Check, %s' % (version.str()))

        orphans = _opts.parse_args('--check-orphans', error = False, extra = False)
        if orphans:
            print('Checking for orphans...')
            check_orphans(_opts)
        else:
            if host_setup(_opts):
                print('Environment is ok')
            else:
                print('Environment is not correctly set up')
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 13
0
def run(args):
    try:
        optargs = {
            '--rtems': 'The RTEMS source directory',
            '--rtems-bsp': 'The RTEMS BSP (arch/bsp)',
            '--list': 'List the configurations'
        }
        opts = options.load(sys.argv, optargs)

        if opts.get_arg('--rtems'):
            prefix = opts.get_arg('--rtems')[1]
        else:
            prefix = os.getcwd()
        if opts.get_arg('--rtems-bsp') is None:
            raise error.general('no --rtems-bsp option; please provide')

        bsp = bsp_config(opts, prefix, opts.get_arg('--rtems-bsp')[1])

        if opts.get_arg('--list'):
            log.notice('RTEMS Source Builder - RTEMS Configuration, v%s' %
                       (version.str()))
            opts.log_info()
            configs = bsp.keys()
            for c in sorted(configs.keys()):
                print c
        else:
            for p in opts.params():
                print bsp.find(p)

    except error.general, gerr:
        print gerr
        sys.exit(1)
Ejemplo n.º 14
0
def run(args):
    try:
        optargs = {
            '--list-bsets': 'List available build sets',
            '--list-configs': 'List available configurations',
            '--format': 'Output format (text, html, asciidoc, ini, xml)',
            '--output': 'File name to output the report'
        }
        opts = options.load(args, optargs)
        if opts.get_arg('--output') and len(opts.params()) > 1:
            raise error.general(
                '--output can only be used with a single config')
        print 'RTEMS Source Builder, Reporter v%s' % (version.str())
        opts.log_info()
        if not check.host_setup(opts):
            log.warning('forcing build with known host setup problems')
        configs = build.get_configs(opts)
        if not setbuilder.list_bset_cfg_files(opts, configs):
            output = opts.get_arg('--output')
            if output is not None:
                output = output[1]
            formatter = text_formatter()
            format_opt = opts.get_arg('--format')
            if format_opt:
                if len(format_opt) != 2:
                    raise error.general('invalid format option: %s' %
                                        ('='.join(format_opt)))
                if format_opt[1] == 'text':
                    pass
                elif format_opt[1] == 'asciidoc':
                    formatter = asciidoc_formatter()
                elif format_opt[1] == 'html':
                    formatter = html_formatter()
                elif format_opt[1] == 'ini':
                    formatter = ini_formatter()
                elif format_opt[1] == 'xml':
                    formatter = xml_formatter()
                else:
                    raise error.general('invalid format: %s' % (format_opt[1]))
            r = report(formatter, configs, opts)
            for _config in opts.params():
                if output is None:
                    outname = path.splitext(_config)[0] + formatter.ext()
                    outname = outname.replace('/', '-')
                else:
                    outname = output
                config = build.find_config(_config, configs)
                if config is None:
                    raise error.general('config file not found: %s' % (inname))
                r.create(config, outname)
            del r
        else:
            raise error.general('invalid config type: %s' % (config))
    except error.general, gerr:
        print gerr
        sys.exit(1)
def run():
    import sys

    ec = 0
    setbuilder_error = False
    try:
        optargs = {
            "--list-configs": "List available configurations",
            "--list-bsets": "List available build sets",
            "--list-deps": "List the dependent files.",
            "--bset-tar-file": "Create a build set tar file",
            "--pkg-tar-files": "Create package tar files",
            "--no-report": "Do not create a package report.",
            "--report-format": "The report format (text, html, asciidoc).",
        }
        mailer.append_options(optargs)
        opts = options.load(sys.argv, optargs)
        log.notice("RTEMS Source Builder - Set Builder, %s" % (version.str()))
        opts.log_info()
        if not check.host_setup(opts):
            raise error.general("host build environment is not set up correctly")
        configs = build.get_configs(opts)
        if opts.get_arg("--list-deps"):
            deps = []
        else:
            deps = None
        if not list_bset_cfg_files(opts, configs):
            prefix = opts.defaults.expand("%{_prefix}")
            if opts.canadian_cross():
                opts.disable_install()

            if (
                not opts.dry_run()
                and not opts.canadian_cross()
                and not opts.no_install()
                and not path.ispathwritable(prefix)
            ):
                raise error.general("prefix is not writable: %s" % (path.host(prefix)))
            for bset in opts.params():
                setbuilder_error = True
                b = buildset(bset, configs, opts)
                b.build(deps)
                b = None
                setbuilder_error = False
        if deps is not None:
            c = 0
            for d in sorted(set(deps)):
                c += 1
                print "dep[%d]: %s" % (c, d)
    except error.general, gerr:
        if not setbuilder_error:
            log.stderr(str(gerr))
        log.stderr("Build FAILED")
        ec = 1
Ejemplo n.º 16
0
def run(args):
    try:
        optargs = { '--list-bsets':   'List available build sets',
                    '--list-configs': 'List available configurations',
                    '--format':       'Output format (text, html, asciidoc, ini)',
                    '--output':       'File name to output the report' }
        opts = options.load(args, optargs)
        if opts.get_arg('--output') and len(opts.params()) > 1:
            raise error.general('--output can only be used with a single config')
        print 'RTEMS Source Builder, Reporter v%s' % (version.str())
        opts.log_info()
        if not check.host_setup(opts):
            log.warning('forcing build with known host setup problems')
        configs = build.get_configs(opts)
        if not setbuilder.list_bset_cfg_files(opts, configs):
            output = opts.get_arg('--output')
            if output is not None:
                output = output[1]
            format = 'text'
            ext = '.txt'
            format_opt = opts.get_arg('--format')
            if format_opt:
                if len(format_opt) != 2:
                    raise error.general('invalid format option: %s' % ('='.join(format_opt)))
                if format_opt[1] == 'text':
                    pass
                elif format_opt[1] == 'asciidoc':
                    format = 'asciidoc'
                    ext = '.txt'
                elif format_opt[1] == 'html':
                    format = 'html'
                    ext = '.html'
                elif format_opt[1] == 'ini':
                    format = 'ini'
                    ext = '.ini'
                else:
                    raise error.general('invalid format: %s' % (format_opt[1]))
            r = report(format, configs, opts)
            for _config in opts.params():
                if output is None:
                    outname = path.splitext(_config)[0] + ext
                    outname = outname.replace('/', '-')
                else:
                    outname = output
                config = build.find_config(_config, configs)
                if config is None:
                    raise error.general('config file not found: %s' % (inname))
                r.create(config, outname)
            del r
        else:
            raise error.general('invalid config type: %s' % (config))
    except error.general, gerr:
        print gerr
        sys.exit(1)
Ejemplo n.º 17
0
def run(args):
    try:
        optargs = {
            "--list-bsets": "List available build sets",
            "--list-configs": "List available configurations",
            "--format": "Output format (text, html, asciidoc)",
            "--output": "File name to output the report",
        }
        opts = options.load(args, optargs)
        if opts.get_arg("--output") and len(opts.params()) > 1:
            raise error.general("--output can only be used with a single config")
        print "RTEMS Source Builder, Reporter v%s" % (version.str())
        opts.log_info()
        if not check.host_setup(opts):
            log.warning("forcing build with known host setup problems")
        configs = build.get_configs(opts)
        if not setbuilder.list_bset_cfg_files(opts, configs):
            output = opts.get_arg("--output")
            if output is not None:
                output = output[1]
            format = "text"
            ext = ".txt"
            format_opt = opts.get_arg("--format")
            if format_opt:
                if len(format_opt) != 2:
                    raise error.general("invalid format option: %s" % ("=".join(format_opt)))
                if format_opt[1] == "text":
                    pass
                elif format_opt[1] == "asciidoc":
                    format = "asciidoc"
                    ext = ".txt"
                elif format_opt[1] == "html":
                    format = "html"
                    ext = ".html"
                else:
                    raise error.general("invalid format: %s" % (format_opt[1]))
            r = report(format, configs, opts)
            for _config in opts.params():
                if output is None:
                    outname = path.splitext(_config)[0] + ext
                    outname = outname.replace("/", "-")
                else:
                    outname = output
                config = build.find_config(_config, configs)
                if config is None:
                    raise error.general("config file not found: %s" % (inname))
                r.create(config, outname)
            del r
        else:
            raise error.general("invalid config type: %s" % (config))
    except error.general, gerr:
        print gerr
        sys.exit(1)
Ejemplo n.º 18
0
def run():
    import sys
    try:
        _opts = options.load(args = sys.argv)
        log.notice('RTEMS Source Builder - Check, v%s' % (version.str()))
        if host_setup(_opts):
            print 'Environment is ok'
        else:
            print 'Environment is not correctly set up'
    except error.general, gerr:
        print gerr
        sys.exit(1)
Ejemplo n.º 19
0
def run():
    import sys
    try:
        _opts = options.load(args=sys.argv)
        log.notice('RTEMS Source Builder - Check, %s' % (version.str()))
        if host_setup(_opts):
            print 'Environment is ok'
        else:
            print 'Environment is not correctly set up'
    except error.general, gerr:
        print gerr
        sys.exit(1)
Ejemplo n.º 20
0
def run():
    import sys
    try:
        _opts = options.command_line(argv = sys.argv)
        options.load(_opts)
        log.notice('RTEMS Source Builder - Check, v%s' % (version.str()))
        if host_setup(_opts):
            print('Environment is ok')
        else:
            print('Environment is not correctly set up')
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print (ierr)
        sys.exit(1)
    except error.exit:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 21
0
def run(args):
    try:
        #
        # On Windows MSYS2 prepends a path to itself to the environment
        # path. This means the RTEMS specific automake is not found and which
        # breaks the bootstrap. We need to remove the prepended path. Also
        # remove any ACLOCAL paths from the environment.
        #
        if os.name == 'nt':
            cspath = os.environ['PATH'].split(os.pathsep)
            if 'msys' in cspath[0] and cspath[0].endswith('bin'):
                os.environ['PATH'] = os.pathsep.join(cspath[1:])
            if 'ACLOCAL_PATH' in os.environ:
                #
                # The clear fails on a current MSYS2 python (Feb 2016). Delete
                # the entry if the clear fails.
                #
                try:
                    os.environ['ACLOCAL_PATH'].clear()
                except:
                    del os.environ['ACLOCAL_PATH']
        optargs = {
            '--rtems': 'The RTEMS source directory',
            '--preinstall': 'Preinstall AM generation'
        }
        log.notice('RTEMS Source Builder - RTEMS Bootstrap, %s' %
                   (version.str()))
        opts = options.load(sys.argv, optargs, logfile=False)
        if opts.get_arg('--rtems'):
            topdir = opts.get_arg('--rtems')
        else:
            topdir = os.getcwd()
        if opts.get_arg('--preinstall'):
            preinstall(topdir, opts.jobs(opts.defaults['_ncpus']))
        else:
            generate(topdir, opts.jobs(opts.defaults['_ncpus']))
    except error.general as gerr:
        print(gerr)
        print('Bootstrap FAILED', file=sys.stderr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        print('Bootstrap FAILED', file=sys.stderr)
        sys.exit(1)
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 22
0
def run():
    import sys
    try:
        #
        # Run where defaults.mc is located
        #
        opts = options.load(sys.argv, defaults='defaults.mc')
        log.trace('config: count %d' % (len(opts.config_files())))
        for config_file in opts.config_files():
            s = file(config_file, opts)
            print s
            del s
    except error.general, gerr:
        print gerr
        sys.exit(1)
Ejemplo n.º 23
0
def run():
    import sys
    try:
        #
        # Run where defaults.mc is located
        #
        opts = options.load(sys.argv, defaults = 'defaults.mc')
        log.trace('config: count %d' % (len(opts.config_files())))
        for config_file in opts.config_files():
            s = file(config_file, opts)
            print s
            del s
    except error.general, gerr:
        print gerr
        sys.exit(1)
Ejemplo n.º 24
0
def run(args):
    try:
        #
        # On Windows MSYS2 prepends a path to itself to the environment
        # path. This means the RTEMS specific automake is not found and which
        # breaks the bootstrap. We need to remove the prepended path. Also
        # remove any ACLOCAL paths from the environment.
        #
        if os.name == 'nt':
            cspath = os.environ['PATH'].split(os.pathsep)
            if 'msys' in cspath[0] and cspath[0].endswith('bin'):
                os.environ['PATH'] = os.pathsep.join(cspath[1:])
            if 'ACLOCAL_PATH' in os.environ:
                #
                # The clear fails on a current MSYS2 python (Feb 2016). Delete
                # the entry if the clear fails.
                #
                try:
                    os.environ['ACLOCAL_PATH'].clear()
                except:
                    del os.environ['ACLOCAL_PATH']
        optargs = { '--rtems':       'The RTEMS source directory',
                    '--preinstall':  'Preinstall AM generation' }
        log.notice('RTEMS Source Builder - RTEMS Bootstrap, %s' % (version.str()))
        opts = options.load(sys.argv, optargs, logfile = False)
        if opts.get_arg('--rtems'):
            topdir = opts.get_arg('--rtems')
        else:
            topdir = os.getcwd()
        if opts.get_arg('--preinstall'):
            preinstall(topdir, opts.jobs(opts.defaults['_ncpus']))
        else:
            generate(topdir, opts.jobs(opts.defaults['_ncpus']))
    except error.general as gerr:
        print(gerr)
        print('Bootstrap FAILED', file = sys.stderr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        print('Bootstrap FAILED', file = sys.stderr)
        sys.exit(1)
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 25
0
def run(args):
    try:
        optargs = { '--rtems':       'The RTEMS source directory',
                    '--preinstall':  'Preinstall AM generation' }
        log.notice('RTEMS Source Builder - RTEMS Bootstrap, v%s' % (version.str()))
        opts = options.load(sys.argv, optargs)
        if opts.get_arg('--rtems'):
            topdir = opts.get_arg('--rtems')
        else:
            topdir = os.getcwd()
        if opts.get_arg('--preinstall'):
            preinstall(topdir, opts.defaults['_ncpus'])
        else:
            generate(topdir, opts.defaults['_ncpus'])
    except error.general, gerr:
        print gerr
        print >> sys.stderr, 'Bootstrap FAILED'
        sys.exit(1)
Ejemplo n.º 26
0
def run():
    import sys
    try:
        optargs = {
            '--list-configs': 'List available configurations',
            '--list-bsets': 'List available build sets',
            '--list-deps': 'List the dependent files.',
            '--bset-tar-file': 'Create a build set tar file',
            '--pkg-tar-files': 'Create package tar files',
            '--no-report': 'Do not create a package report.',
            '--report-format': 'The report format (text, html, asciidoc).'
        }
        mailer.append_options(optargs)
        opts = options.load(sys.argv, optargs)
        log.notice('RTEMS Source Builder - Set Builder, v%s' % (version.str()))
        opts.log_info()
        if not check.host_setup(opts):
            raise error.general(
                'host build environment is not set up correctly')
        configs = build.get_configs(opts)
        if opts.get_arg('--list-deps'):
            deps = []
        else:
            deps = None
        if not list_bset_cfg_files(opts, configs):
            prefix = opts.defaults.expand('%{_prefix}')
            if not opts.dry_run() and not opts.no_install() and \
                    not path.ispathwritable(prefix):
                raise error.general('prefix is not writable: %s' %
                                    (path.host(prefix)))
            for bset in opts.params():
                b = buildset(bset, configs, opts)
                b.build(deps)
                del b
        if deps is not None:
            c = 0
            for d in sorted(set(deps)):
                c += 1
                print 'dep[%d]: %s' % (c, d)
    except error.general, gerr:
        log.notice(str(gerr))
        print >> sys.stderr, 'Build FAILED'
        sys.exit(1)
Ejemplo n.º 27
0
def run(args):
    try:
        optargs = {
            '--rtems': 'The RTEMS source directory',
            '--rtems-bsp': 'The RTEMS BSP (arch/bsp)',
            '--list': 'List the configurations'
        }
        opts = options.load(sys.argv, optargs)

        if opts.get_arg('--rtems'):
            prefix = opts.get_arg('--rtems')[1]
        else:
            prefix = os.getcwd()
        if opts.get_arg('--rtems-bsp') is None:
            raise error.general('no --rtems-bsp option; please provide')

        bsp = bsp_config(opts, prefix, opts.get_arg('--rtems-bsp')[1])

        if opts.get_arg('--list'):
            log.notice('RTEMS Source Builder - RTEMS Configuration, %s' %
                       (version.str()))
            opts.log_info()
            configs = list(bsp.keys())
            for c in sorted(configs.keys()):
                print(c)
        else:
            for p in opts.params():
                print(bsp.find(p))

    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 28
0
def run():
    import sys
    try:
        #
        # Run where defaults.mc is located
        #
        opts = options.load(sys.argv, defaults = 'defaults.mc')
        log.trace('config: count %d' % (len(opts.config_files())))
        for config_file in opts.config_files():
            s = open(config_file, opts)
            print(s)
            del s
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 29
0
def run():
    import sys
    try:
        #
        # Run where defaults.mc is located
        #
        opts = options.load(sys.argv, defaults='defaults.mc')
        log.trace('config: count %d' % (len(opts.config_files())))
        for config_file in opts.config_files():
            s = open(config_file, opts)
            print(s)
            del s
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 30
0
def run():
    import sys
    try:
        optargs = { '--list-configs':  'List available configurations',
                    '--list-bsets':    'List available build sets',
                    '--list-deps':     'List the dependent files.',
                    '--bset-tar-file': 'Create a build set tar file',
                    '--pkg-tar-files': 'Create package tar files',
                    '--no-report':     'Do not create a package report.',
                    '--report-format': 'The report format (text, html, asciidoc).' }
        mailer.append_options(optargs)
        opts = options.load(sys.argv, optargs)
        log.notice('RTEMS Source Builder - Set Builder, v%s' % (version.str()))
        opts.log_info()
        if not check.host_setup(opts):
            raise error.general('host build environment is not set up correctly')
        configs = build.get_configs(opts)
        if opts.get_arg('--list-deps'):
            deps = []
        else:
            deps = None
        if not list_bset_cfg_files(opts, configs):
            prefix = opts.defaults.expand('%{_prefix}')
            if not opts.dry_run() and not opts.no_install() and \
                    not path.ispathwritable(prefix):
                raise error.general('prefix is not writable: %s' % (path.host(prefix)))
            for bset in opts.params():
                b = buildset(bset, configs, opts)
                b.build(deps)
                del b
        if deps is not None:
            c = 0
            for d in sorted(set(deps)):
                c += 1
                print 'dep[%d]: %s' % (c, d)
    except error.general, gerr:
        log.notice(str(gerr))
        print >> sys.stderr, 'Build FAILED'
        sys.exit(1)
Ejemplo n.º 31
0
def run(args):
    try:
        optargs = { '--rtems':      'The RTEMS source directory',
                    '--rtems-bsp':  'The RTEMS BSP (arch/bsp)',
                    '--list':       'List the configurations' }
        opts = options.load(sys.argv, optargs)

        if opts.get_arg('--rtems'):
            prefix = opts.get_arg('--rtems')[1]
        else:
            prefix = os.getcwd()
        if opts.get_arg('--rtems-bsp') is None:
            raise error.general('no --rtems-bsp option; please provide')

        bsp = bsp_config(opts, prefix, opts.get_arg('--rtems-bsp')[1])

        if opts.get_arg('--list'):
            log.notice('RTEMS Source Builder - RTEMS Configuration, %s' % (version.str()))
            opts.log_info()
            configs = list(bsp.keys())
            for c in sorted(configs.keys()):
                print(c)
        else:
            for p in opts.params():
                print(bsp.find(p))

    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
def run(args):
    try:
        optargs = {
            '--list-bsets': 'List available build sets',
            '--list-configs': 'List available configurations',
            '--format': 'Output format (text, html, markdown, ini, xml)',
            '--output': 'File name to output the report',
            '--sanitize': 'Remove Remotes information from report'
        }
        opts = options.load(args, optargs, logfile=False)
        if opts.get_arg('--output') and len(opts.params()) > 1:
            raise error.general(
                '--output can only be used with a single config')
        print('RTEMS Source Builder, Reporter, %s' % (version.string()))
        opts.log_info()
        if not check.host_setup(opts):
            log.warning('forcing build with known host setup problems')
        configs = build.get_configs(opts)
        if not setbuilder.list_bset_cfg_files(opts, configs):
            output = opts.get_arg('--output')
            if output is not None:
                output = output[1]
            formatter = text_formatter()
            format_opt = opts.get_arg('--format')
            if format_opt:
                if len(format_opt) != 2:
                    raise error.general('invalid format option: %s' %
                                        ('='.join(format_opt)))
                if format_opt[1] == 'text':
                    pass
                elif format_opt[1] == 'markdown':
                    formatter = markdown_formatter()
                elif format_opt[1] == 'html':
                    formatter = html_formatter()
                elif format_opt[1] == 'ini':
                    formatter = ini_formatter()
                elif format_opt[1] == 'xml':
                    formatter = xml_formatter()
                else:
                    raise error.general('invalid format: %s' % (format_opt[1]))
            sanitize = False
            if opts.get_arg('--sanitize'):
                sanitize = True
            r = report(formatter, sanitize, configs, opts)
            for _config in opts.params():
                if output is None:
                    outname = path.splitext(_config)[0] + formatter.ext()
                    outname = outname.replace('/', '-')
                else:
                    outname = output
                config = build.find_config(_config, configs)
                if config is None:
                    raise error.general('config file not found: %s' %
                                        (_config))
                r.create(config, outname)
            del r
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 33
0
        if _email is not None:
            if _name is not None:
                _email = '%s <%s>' % (_name, _email)
            return _email
        return None

    def head(self):
        hash = ''
        ec, output = self._run(['log', '-n', '1'])
        if ec == 0:
            l1 = output.split('\n')[0]
            if l1.startswith('commit '):
                hash = l1[len('commit '):]
        return hash

if __name__ == '__main__':
    import os.path
    import sys
    defaults = path.join(path.dirname(path.dirname(path.shell(sys.argv[0]))), 'defaults.mc')
    opts = options.load(sys.argv, defaults = defaults)
    g = repo('.', opts)
    print('g.git_version():', g.git_version())
    print('g.valid():', g.valid())
    print('g.submodules():', g.submodules())
    print('g.status():', g.status())
    print('g.status():', g.status(True))
    print('g.dirty():', g.dirty())
    print('g.remotes():', g.remotes())
    print('g.email():', g.email())
    print('g.head():', g.head())
Ejemplo n.º 34
0
        host = self.opts.defaults.get_value('%{_mail_smtp_host}')
        if host is not None:
            return host
        return 'localhost'

    def send(self, to_addr, subject, body):
        from_addr = self.from_address()
        msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % \
            (from_addr, to_addr, subject) + body
        if type(to_addr) is str:
            to_addr = to_addr.split(',')
        if type(to_addr) is not list:
            raise error.general('invalid to_addr type')
        try:
            s = smtplib.SMTP(self.smtp_host())
            s.sendmail(from_addr, to_addr, msg)
        except smtplib.SMTPException as se:
            raise error.general('sending mail: %s' % (str(se)))
        except socket.error as se:
            raise error.general('sending mail: %s' % (str(se)))

if __name__ == '__main__':
    import sys
    optargs = {}
    append_options(optargs)
    opts = options.load(sys.argv, optargs = optargs, defaults = 'defaults.mc')
    m = mail(opts)
    print('From: %s' % (m.from_address()))
    print('SMTP Host: %s' % (m.smtp_host()))
    m.send(m.from_address(), 'Test mailer.py', 'This is a test')
Ejemplo n.º 35
0
def run(args, command_path = None):
    tests = []
    stdtty = console.save()
    opts = None
    default_exefilter = '*.exe'
    try:
        optargs = { '--rtems-tools': 'The path to the RTEMS tools',
                    '--rtems-bsp':   'The RTEMS BSP to run the test on',
                    '--user-config': 'Path to your local user configuration INI file',
                    '--list-bsps':   'List the supported BSPs',
                    '--debug-trace': 'Debug trace based on specific flags',
                    '--stacktrace':  'Dump a stack trace on a user termination (^C)' }
        opts = options.load(args,
                            optargs = optargs,
                            command_path = command_path)
        log.notice('RTEMS Testing - Run, %s' % (version.string()))
        if opts.find_arg('--list-bsps'):
            bsps.list(opts)
        opts.log_info()
        log.output('Host: ' + host.label(mode = 'all'))
        debug_trace = opts.find_arg('--debug-trace')
        if debug_trace:
            if len(debug_trace) != 1:
                debug_trace = 'output,' + debug_trace[1]
            else:
                raise error.general('no debug flags, can be: console,gdb,output')
        else:
            debug_trace = 'output'
        opts.defaults['debug_trace'] = debug_trace
        rtems_tools = opts.find_arg('--rtems-tools')
        if rtems_tools:
            if len(rtems_tools) != 2:
                raise error.general('invalid RTEMS tools option')
            rtems_tools = rtems_tools[1]
        else:
            rtems_tools = '%{_prefix}'
        bsp = opts.find_arg('--rtems-bsp')
        if bsp is None or len(bsp) != 2:
            raise error.general('RTEMS BSP not provided or an invalid option')
        bsp = config.load(bsp[1], opts)
        bsp_config = opts.defaults.expand(opts.defaults['tester'])
        executables = find_executables(opts.params())
        if len(executables) != 1:
            raise error.general('one executable required, found %d' % (len(executables)))
        opts.defaults['test_disable_header'] = '1'
        reports = report.report(1)
        start_time = datetime.datetime.now()
        opts.defaults['exe_trace'] = debug_trace
        tst = test(1, 1, reports, executables[0], rtems_tools, bsp, bsp_config, opts)
        tst.run()
        end_time = datetime.datetime.now()
        total_time = 'Run time     : %s' % (str(end_time - start_time))
        log.notice(total_time)

    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit:
        sys.exit(2)
    except KeyboardInterrupt:
        if opts is not None and opts.find_arg('--stacktrace'):
            print('}} dumping:', threading.active_count())
            for t in threading.enumerate():
                print('}} ', t.name)
            print(stacktraces.trace())
        log.notice('abort: user terminated')
        sys.exit(1)
    finally:
        console.restore(stdtty)
    sys.exit(0)
Ejemplo n.º 36
0
def run(command_path = None):
    import sys
    stdtty = console.save()
    opts = None
    try:
        optargs = { '--rtems-tools': 'The path to the RTEMS tools',
                    '--rtems-bsp':   'The RTEMS BSP to run the test on',
                    '--report-mode': 'Reporting modes, failures (default),all,none',
                    '--list-bsps':   'List the supported BSPs',
                    '--debug-trace': 'Debug trace based on specific flags',
                    '--stacktrace':  'Dump a stack trace on a user termination (^C)' }
        opts = options.load(sys.argv,
                            optargs = optargs,
                            command_path = command_path)
        log.notice('RTEMS Testing - Tester, v%s' % (version.str()))
        if opts.find_arg('--list-bsps'):
            list_bsps(opts)
        opts.log_info()
        debug_trace = opts.find_arg('--debug-trace')
        if debug_trace:
            debug_trace = debug_trace[1]
        else:
            debug_trace = ''
        opts.defaults['debug_trace'] = debug_trace
        job_trace = 'jobs' in debug_trace.split(',')
        rtems_tools = opts.find_arg('--rtems-tools')
        if rtems_tools:
            rtems_tools = rtems_tools[1]
        bsp = opts.find_arg('--rtems-bsp')
        if bsp is None:
            raise error.general('no RTEMS BSP provided')
        opts.defaults.load('%%{_configdir}/bsps/%s.mc' % (bsp[1]))
        bsp = opts.defaults.get('%{bsp}')
        if not bsp:
            raise error.general('BSP definition (%{bsp}) not found in the global map')
        bsp = bsp[2]
        if not opts.defaults.set_read_map(bsp):
            raise error.general('no BSP map found')
        bsp_script = opts.defaults.get(bsp)
        if not bsp_script:
            raise error.general('BSP script not found: %s' % (bsp))
        bsp_config = opts.defaults.expand(opts.defaults[bsp])
        report_mode = opts.find_arg('--report-mode')
        if report_mode:
            if report_mode[1] != 'failures' and \
                    report_mode[1] != 'all' and \
                    report_mode[1] != 'none':
                raise error.general('invalid report mode')
            report_mode = report_mode[1]
        else:
            report_mode = 'failures'
        executables = find_executables(opts.params())
        if len(executables) == 0:
            raise error.general('no executbles supplied')
        start_time = datetime.datetime.now()
        total = len(executables)
        reports = report.report(total)
        invalid_tests = opts.defaults['invalid_tests']
        if invalid_tests:
            reports.set_invalid_tests([l.strip() for l in invalid_tests.splitlines()])
        reporting = 1
        jobs = int(opts.jobs(opts.defaults['_ncpus']))
        exe = 0
        tests = []
        finished = []
        if jobs > len(executables):
            jobs = len(executables)
        while exe < total or len(tests) > 0:
            if exe < total and len(tests) < jobs:
                tst = test_run(exe + 1, total, reports,
                               executables[exe],
                               rtems_tools, bsp, bsp_config,
                               opts)
                exe += 1
                tests += [tst]
                if job_trace:
                    _job_trace(tst, 'create',
                               total, exe, tests, reporting)
                tst.run()
            else:
                dead = [t for t in tests if not t.is_alive()]
                tests[:] = [t for t in tests if t not in dead]
                for tst in dead:
                    if job_trace:
                        _job_trace(tst, 'dead',
                                   total, exe, tests, reporting)
                    finished += [tst]
                    tst.reraise()
                del dead
                if len(tests) >= jobs or exe >= total:
                    time.sleep(0.250)
                if len(finished):
                    reporting = report_finished(reports,
                                                report_mode,
                                                reporting,
                                                finished,
                                                job_trace)
        finished_time = datetime.datetime.now()
        reporting = report_finished(reports, report_mode,
                                    reporting, finished, job_trace)
        if reporting < total:
            log.warning('finished jobs does match: %d' % (reporting))
            report_finished(reports, report_mode, -1, finished, job_trace)
        reports.summary()
        end_time = datetime.datetime.now()
        log.notice('Testing time: %s' % (str(end_time - start_time)))
    except error.general, gerr:
        print gerr
        sys.exit(1)
Ejemplo n.º 37
0
        return None

    def head(self):
        hash = ''
        ec, output = self._run(['log', '-n', '1'])
        if ec == 0:
            l1 = output.split('\n')[0]
            if l1.startswith('commit '):
                hash = l1[len('commit '):]
        return hash


if __name__ == '__main__':
    import sys
    import options
    long_opts = {
        # key              macro        handler   param  defs   init
    }
    opts = options.command_line(base_path='.',
                                argv=sys.argv,
                                long_opts=long_opts)
    options.load(opts)
    g = repo('.', opts)
    print('version:', g.git_version())
    print('valid:', g.valid())
    print('status:', g.status())
    print('dirty:', g.dirty())
    print('remotes:', g.remotes())
    print('email:', g.email())
    print('head:', g.head())
Ejemplo n.º 38
0
                elif l.startswith('user.name'):
                    ls = l.split('=')
                    if len(ls) >= 2:
                        _name = ls[1]
        if _email is not None:
            if _name is not None:
                _email = '%s <%s>' % (_name, _email)
            return _email
        return None

    def head(self):
        hash = ''
        ec, output = self._run(['log', '-n', '1'])
        if ec == 0:
            l1 = output.split('\n')[0]
            if l1.startswith('commit '):
                hash = l1[len('commit '):]
        return hash

if __name__ == '__main__':
    import sys
    opts = options.load(sys.argv)
    g = repo('.', opts)
    print g.git_version()
    print g.valid()
    print g.status()
    print g.clean()
    print g.remotes()
    print g.email()
    print g.head()
Ejemplo n.º 39
0
def run(command_path = None):
    import sys
    tests = []
    stdtty = console.save()
    opts = None
    default_exefilter = '*.exe'
    try:
        optargs = { '--rtems-tools': 'The path to the RTEMS tools',
                    '--rtems-bsp':   'The RTEMS BSP to run the test on',
                    '--report-mode': 'Reporting modes, failures (default),all,none',
                    '--list-bsps':   'List the supported BSPs',
                    '--debug-trace': 'Debug trace based on specific flags',
                    '--filter':      'Glob that executables must match to run (default: ' +
                              default_exefilter + ')',
                    '--stacktrace':  'Dump a stack trace on a user termination (^C)',
                    '--rtems-builddir': 'The path to the build directory ( including e.g. /b-leon2/ )'}
        opts = options.load(sys.argv,
                            optargs = optargs,
                            command_path = command_path)
        log.notice('RTEMS Testing - Tester, v%s' % (version.str()))
        if opts.find_arg('--list-bsps'):
            bsps.list(opts)
        exe_filter = opts.find_arg('--filter')
        if exe_filter:
            exe_filter = exe_filter[1]
        else:
            exe_filter = default_exefilter
        opts.log_info()
        debug_trace = opts.find_arg('--debug-trace')
        if debug_trace:
            debug_trace = debug_trace[1]
        else:
            debug_trace = ''
        opts.defaults['debug_trace'] = debug_trace
        job_trace = 'jobs' in debug_trace.split(',')
        rtems_tools = opts.find_arg('--rtems-tools')
        if rtems_tools:
            bla = '%{_prefix}'
            print "prefixx: " + bla
            if len(rtems_tools) != 2:
                raise error.general('invalid RTEMS tools option')
            rtems_tools = rtems_tools[1]
        else:
            rtems_tools = '%{_prefix}'
        bsp = opts.find_arg('--rtems-bsp')
        if bsp is None or len(bsp) != 2:
            raise error.general('RTEMS BSP not provided or invalid option')
        opts.defaults.load('%%{_configdir}/bsps/%s.mc' % (bsp[1]))
        bsp = opts.defaults.get('%{bsp}')
        if not bsp:
            raise error.general('BSP definition (%{bsp}) not found in the global map')
        bsp = bsp[2]
        if not opts.defaults.set_read_map(bsp):
            raise error.general('no BSP map found')
        bsp_script = opts.defaults.get(bsp)
        if not bsp_script:
            raise error.general('BSP script not found: %s' % (bsp))
        bsp_config = opts.defaults.expand(opts.defaults[bsp])

        path_to_builddir= opts.find_arg('--rtems-builddir')
        if not path_to_builddir:
            raise error.general("Path to build directory not provided")

        coverage_enabled = opts.coverage()
        if coverage_enabled:
            import coverage
            from rtemstoolkit import check
            log.notice("Coverage analysis requested")
            opts.defaults.load('%%{_configdir}/coverage.mc')
            if not check.check_exe('__covoar', opts.defaults['__covoar']):
                raise error.general("Covoar not found!")

            coverage = coverage.coverage_run(opts.defaults, path_to_builddir[1])
            coverage.prepareEnvironment();

        report_mode = opts.find_arg('--report-mode')
        if report_mode:
            if report_mode[1] != 'failures' and \
                    report_mode[1] != 'all' and \
                    report_mode[1] != 'none':
                raise error.general('invalid report mode')
            report_mode = report_mode[1]
        else:
            report_mode = 'failures'
        executables = find_executables(opts.params(), exe_filter, path_to_builddir[1])
        if len(executables) == 0:
            raise error.general('no executables supplied')
        start_time = datetime.datetime.now()
        total = len(executables)
        reports = report.report(total)
        invalid_tests = opts.defaults['invalid_tests']
        if invalid_tests:
            reports.set_invalid_tests([l.strip() for l in invalid_tests.splitlines()])
        reporting = 1
        jobs = int(opts.jobs(opts.defaults['_ncpus']))
        exe = 0
        finished = []
        if jobs > len(executables):
            jobs = len(executables)
        while exe < total or len(tests) > 0:
            if exe < total and len(tests) < jobs:
                tst = test_run(exe + 1, total, reports,
                               executables[exe],
                               rtems_tools, bsp, bsp_config,
                               opts)
                exe += 1
                tests += [tst]
                if job_trace:
                    _job_trace(tst, 'create',
                               total, exe, tests, reporting)
                tst.run()
            else:
                dead = [t for t in tests if not t.is_alive()]
                tests[:] = [t for t in tests if t not in dead]
                for tst in dead:
                    if job_trace:
                        _job_trace(tst, 'dead',
                                   total, exe, tests, reporting)
                    finished += [tst]
                    tst.reraise()
                del dead
                if len(tests) >= jobs or exe >= total:
                    time.sleep(0.250)
                if len(finished):
                    reporting = report_finished(reports,
                                                report_mode,
                                                reporting,
                                                finished,
                                                job_trace)
        finished_time = datetime.datetime.now()
        reporting = report_finished(reports, report_mode,
                                    reporting, finished, job_trace)
        if reporting < total:
            log.warning('finished jobs does match: %d' % (reporting))
            report_finished(reports, report_mode, -1, finished, job_trace)
        reports.summary()
        end_time = datetime.datetime.now()
        log.notice('Average test time: %s' % (str((end_time - start_time) / total)))
        log.notice('Testing time     : %s' % (str(end_time - start_time)))

        if coverage_enabled:
            coverage.config_map = opts.defaults.macros['coverage']
            coverage.executables = executables
            print [c for c in coverage.config_map]
            print [e for e in executables]
Ejemplo n.º 40
0
def run():
    import sys
    ec = 0
    setbuilder_error = False
    mail = None
    try:
        optargs = {
            '--list-configs': 'List available configurations',
            '--list-bsets': 'List available build sets',
            '--list-configs': 'List available configuration files.',
            '--list-deps': 'List the dependent files.',
            '--bset-tar-file': 'Create a build set tar file',
            '--pkg-tar-files': 'Create package tar files',
            '--no-report': 'Do not create a package report.',
            '--report-format': 'The report format (text, html, asciidoc).'
        }
        mailer.append_options(optargs)
        opts = options.load(sys.argv, optargs)
        if opts.get_arg('--mail'):
            mail = {'mail': mailer.mail(opts), 'output': log_capture()}
            to_addr = opts.get_arg('--mail-to')
            if to_addr is not None:
                mail['to'] = to_addr[1]
            else:
                mail['to'] = opts.defaults.expand('%{_mail_tools_to}')
            mail['from'] = mail['mail'].from_address()
        log.notice('RTEMS Source Builder - Set Builder, %s' % (version.str()))
        opts.log_info()
        if not check.host_setup(opts):
            raise error.general(
                'host build environment is not set up correctly')
        if mail:
            mail['header'] = os.linesep.join(mail['output'].get()) + os.linesep
            mail['header'] += os.linesep
            mail['header'] += 'Host: ' + reports.platform(
                'compact') + os.linesep
            indent = '       '
            for l in textwrap.wrap(reports.platform('extended'),
                                   width=80 - len(indent)):
                mail['header'] += indent + l + os.linesep
        configs = build.get_configs(opts)
        if opts.get_arg('--list-deps'):
            deps = []
        else:
            deps = None
        if not list_bset_cfg_files(opts, configs):
            prefix = opts.defaults.expand('%{_prefix}')
            if opts.canadian_cross():
                opts.disable_install()

            if not opts.dry_run() and \
               not opts.canadian_cross() and \
               not opts.no_install() and \
               not path.ispathwritable(prefix):
                raise error.general('prefix is not writable: %s' %
                                    (path.host(prefix)))

            for bset in opts.params():
                setbuilder_error = True
                b = buildset(bset, configs, opts)
                b.build(deps, mail=mail)
                b = None
                setbuilder_error = False

        if deps is not None:
            c = 0
            for d in sorted(set(deps)):
                c += 1
                print('dep[%d]: %s' % (c, d))
    except error.general as gerr:
        if not setbuilder_error:
            log.stderr(str(gerr))
        log.stderr('Build FAILED')
        ec = 1
    except error.internal as ierr:
        if not setbuilder_error:
            log.stderr(str(ierr))
        log.stderr('Internal Build FAILED')
        ec = 1
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        ec = 1
    except:
        raise
        log.notice('abort: unknown error')
        ec = 1
    sys.exit(ec)
Ejemplo n.º 41
0
def run(command_path = None):
    import sys
    tests = []
    stdtty = console.save()
    opts = None
    default_exefilter = '*.exe'
    try:
        optargs = { '--rtems-tools': 'The path to the RTEMS tools',
                    '--rtems-bsp':   'The RTEMS BSP to run the test on',
                    '--report-mode': 'Reporting modes, failures (default),all,none',
                    '--list-bsps':   'List the supported BSPs',
                    '--debug-trace': 'Debug trace based on specific flags',
                    '--filter':      'Glob that executables must match to run (default: ' +
                              default_exefilter + ')',
                    '--stacktrace':  'Dump a stack trace on a user termination (^C)' }
        opts = options.load(sys.argv,
                            optargs = optargs,
                            command_path = command_path)
        log.notice('RTEMS Testing - Tester, v%s' % (version.str()))
        if opts.find_arg('--list-bsps'):
            bsps.list(opts)
        exe_filter = opts.find_arg('--filter')
        if exe_filter:
            exe_filter = exe_filter[1]
        else:
            exe_filter = default_exefilter
        opts.log_info()
        debug_trace = opts.find_arg('--debug-trace')
        if debug_trace:
            debug_trace = debug_trace[1]
        else:
            debug_trace = ''
        opts.defaults['debug_trace'] = debug_trace
        job_trace = 'jobs' in debug_trace.split(',')
        rtems_tools = opts.find_arg('--rtems-tools')
        if rtems_tools:
            if len(rtems_tools) != 2:
                raise error.general('invalid RTEMS tools option')
            rtems_tools = rtems_tools[1]
        else:
            rtems_tools = '%{_prefix}'
        bsp = opts.find_arg('--rtems-bsp')
        if bsp is None or len(bsp) != 2:
            raise error.general('RTEMS BSP not provided or invalid option')
        opts.defaults.load('%%{_configdir}/bsps/%s.mc' % (bsp[1]))
        bsp = opts.defaults.get('%{bsp}')
        if not bsp:
            raise error.general('BSP definition (%{bsp}) not found in the global map')
        bsp = bsp[2]
        if not opts.defaults.set_read_map(bsp):
            raise error.general('no BSP map found')
        bsp_script = opts.defaults.get(bsp)
        if not bsp_script:
            raise error.general('BSP script not found: %s' % (bsp))
        bsp_config = opts.defaults.expand(opts.defaults[bsp])
        report_mode = opts.find_arg('--report-mode')
        if report_mode:
            if report_mode[1] != 'failures' and \
                    report_mode[1] != 'all' and \
                    report_mode[1] != 'none':
                raise error.general('invalid report mode')
            report_mode = report_mode[1]
        else:
            report_mode = 'failures'
        executables = find_executables(opts.params(), exe_filter)
        if len(executables) == 0:
            raise error.general('no executables supplied')
        start_time = datetime.datetime.now()
        total = len(executables)
        reports = report.report(total)
        invalid_tests = opts.defaults['invalid_tests']
        if invalid_tests:
            reports.set_invalid_tests([l.strip() for l in invalid_tests.splitlines()])
        reporting = 1
        jobs = int(opts.jobs(opts.defaults['_ncpus']))
        exe = 0
        finished = []
        if jobs > len(executables):
            jobs = len(executables)
        while exe < total or len(tests) > 0:
            if exe < total and len(tests) < jobs:
                tst = test_run(exe + 1, total, reports,
                               executables[exe],
                               rtems_tools, bsp, bsp_config,
                               opts)
                exe += 1
                tests += [tst]
                if job_trace:
                    _job_trace(tst, 'create',
                               total, exe, tests, reporting)
                tst.run()
            else:
                dead = [t for t in tests if not t.is_alive()]
                tests[:] = [t for t in tests if t not in dead]
                for tst in dead:
                    if job_trace:
                        _job_trace(tst, 'dead',
                                   total, exe, tests, reporting)
                    finished += [tst]
                    tst.reraise()
                del dead
                if len(tests) >= jobs or exe >= total:
                    time.sleep(0.250)
                if len(finished):
                    reporting = report_finished(reports,
                                                report_mode,
                                                reporting,
                                                finished,
                                                job_trace)
        finished_time = datetime.datetime.now()
        reporting = report_finished(reports, report_mode,
                                    reporting, finished, job_trace)
        if reporting < total:
            log.warning('finished jobs does match: %d' % (reporting))
            report_finished(reports, report_mode, -1, finished, job_trace)
        reports.summary()
        end_time = datetime.datetime.now()
        log.notice('Average test time: %s' % (str((end_time - start_time) / total)))
        log.notice('Testing time     : %s' % (str(end_time - start_time)))
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit:
        sys.exit(2)
    except KeyboardInterrupt:
        if opts is not None and opts.find_arg('--stacktrace'):
            print('}} dumping:', threading.active_count())
            for t in threading.enumerate():
                print('}} ', t.name)
            print(stacktraces.trace())
        log.notice('abort: user terminated')
        killall(tests)
        sys.exit(1)
    finally:
        console.restore(stdtty)
    sys.exit(0)
Ejemplo n.º 42
0
def run(args):
    try:
        optargs = { '--list-bsets':   'List available build sets',
                    '--list-configs': 'List available configurations',
                    '--format':       'Output format (text, html, markdown, ini, xml)',
                    '--output':       'File name to output the report' }
        opts = options.load(args, optargs, logfile = False)
        if opts.get_arg('--output') and len(opts.params()) > 1:
            raise error.general('--output can only be used with a single config')
        print('RTEMS Source Builder, Reporter, %s' % (version.str()))
        opts.log_info()
        if not check.host_setup(opts):
            log.warning('forcing build with known host setup problems')
        configs = build.get_configs(opts)
        if not setbuilder.list_bset_cfg_files(opts, configs):
            output = opts.get_arg('--output')
            if output is not None:
                output = output[1]
            formatter = text_formatter()
            format_opt = opts.get_arg('--format')
            if format_opt:
                if len(format_opt) != 2:
                    raise error.general('invalid format option: %s' % ('='.join(format_opt)))
                if format_opt[1] == 'text':
                    pass
                elif format_opt[1] == 'markdown':
                    formatter = markdown_formatter()
                elif format_opt[1] == 'html':
                    formatter = html_formatter()
                elif format_opt[1] == 'ini':
                    formatter = ini_formatter()
                elif format_opt[1] == 'xml':
                    formatter = xml_formatter()
                else:
                    raise error.general('invalid format: %s' % (format_opt[1]))
            r = report(formatter, configs, opts)
            for _config in opts.params():
                if output is None:
                    outname = path.splitext(_config)[0] + formatter.ext()
                    outname = outname.replace('/', '-')
                else:
                    outname = output
                config = build.find_config(_config, configs)
                if config is None:
                    raise error.general('config file not found: %s' % (_config))
                r.create(config, outname)
            del r
        else:
            raise error.general('invalid config type: %s' % (config))
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Ejemplo n.º 43
0
def run(command_path=None):
    import sys
    tests = []
    stdtty = console.save()
    opts = None
    default_exefilter = '*.exe'
    try:
        optargs = {
            '--rtems-tools':
            'The path to the RTEMS tools',
            '--rtems-bsp':
            'The RTEMS BSP to run the test on',
            '--report-mode':
            'Reporting modes, failures (default),all,none',
            '--list-bsps':
            'List the supported BSPs',
            '--debug-trace':
            'Debug trace based on specific flags',
            '--filter':
            'Glob that executables must match to run (default: ' +
            default_exefilter + ')',
            '--stacktrace':
            'Dump a stack trace on a user termination (^C)'
        }
        opts = options.load(sys.argv,
                            optargs=optargs,
                            command_path=command_path)
        log.notice('RTEMS Testing - Tester, %s' % (version.str()))
        if opts.find_arg('--list-bsps'):
            bsps.list(opts)
        exe_filter = opts.find_arg('--filter')
        if exe_filter:
            exe_filter = exe_filter[1]
        else:
            exe_filter = default_exefilter
        opts.log_info()
        debug_trace = opts.find_arg('--debug-trace')
        if debug_trace:
            debug_trace = debug_trace[1]
        else:
            debug_trace = ''
        opts.defaults['debug_trace'] = debug_trace
        job_trace = 'jobs' in debug_trace.split(',')
        rtems_tools = opts.find_arg('--rtems-tools')
        if rtems_tools:
            if len(rtems_tools) != 2:
                raise error.general('invalid RTEMS tools option')
            rtems_tools = rtems_tools[1]
        else:
            rtems_tools = '%{_prefix}'
        bsp = opts.find_arg('--rtems-bsp')
        if bsp is None or len(bsp) != 2:
            raise error.general('RTEMS BSP not provided or invalid option')
        opts.defaults.load('%%{_configdir}/bsps/%s.mc' % (bsp[1]))
        bsp = opts.defaults.get('%{bsp}')
        if not bsp:
            raise error.general(
                'BSP definition (%{bsp}) not found in the global map')
        bsp = bsp[2]
        if not opts.defaults.set_read_map(bsp):
            raise error.general('no BSP map found')
        bsp_script = opts.defaults.get(bsp)
        if not bsp_script:
            raise error.general('BSP script not found: %s' % (bsp))
        bsp_config = opts.defaults.expand(opts.defaults[bsp])
        report_mode = opts.find_arg('--report-mode')
        if report_mode:
            if report_mode[1] != 'failures' and \
                    report_mode[1] != 'all' and \
                    report_mode[1] != 'none':
                raise error.general('invalid report mode')
            report_mode = report_mode[1]
        else:
            report_mode = 'failures'
        executables = find_executables(opts.params(), exe_filter)
        if len(executables) == 0:
            raise error.general('no executables supplied')
        start_time = datetime.datetime.now()
        total = len(executables)
        reports = report.report(total)
        invalid_tests = opts.defaults['invalid_tests']
        if invalid_tests:
            reports.set_invalid_tests(
                [l.strip() for l in invalid_tests.splitlines()])
        reporting = 1
        jobs = int(opts.jobs(opts.defaults['_ncpus']))
        exe = 0
        finished = []
        if jobs > len(executables):
            jobs = len(executables)
        while exe < total or len(tests) > 0:
            if exe < total and len(tests) < jobs:
                tst = test_run(exe + 1, total, reports, executables[exe],
                               rtems_tools, bsp, bsp_config, opts)
                exe += 1
                tests += [tst]
                if job_trace:
                    _job_trace(tst, 'create', total, exe, tests, reporting)
                tst.run()
            else:
                dead = [t for t in tests if not t.is_alive()]
                tests[:] = [t for t in tests if t not in dead]
                for tst in dead:
                    if job_trace:
                        _job_trace(tst, 'dead', total, exe, tests, reporting)
                    finished += [tst]
                    tst.reraise()
                del dead
                if len(tests) >= jobs or exe >= total:
                    time.sleep(0.250)
                if len(finished):
                    reporting = report_finished(reports, report_mode,
                                                reporting, finished, job_trace)
        finished_time = datetime.datetime.now()
        reporting = report_finished(reports, report_mode, reporting, finished,
                                    job_trace)
        if reporting < total:
            log.warning('finished jobs does match: %d' % (reporting))
            report_finished(reports, report_mode, -1, finished, job_trace)
        reports.summary()
        end_time = datetime.datetime.now()
        log.notice('Average test time: %s' % (str(
            (end_time - start_time) / total)))
        log.notice('Testing time     : %s' % (str(end_time - start_time)))
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit:
        sys.exit(2)
    except KeyboardInterrupt:
        if opts is not None and opts.find_arg('--stacktrace'):
            print('}} dumping:', threading.active_count())
            for t in threading.enumerate():
                print('}} ', t.name)
            print(stacktraces.trace())
        log.notice('abort: user terminated')
        killall(tests)
        sys.exit(1)
    finally:
        console.restore(stdtty)
    sys.exit(0)
Ejemplo n.º 44
0
def run():
    import sys
    ec = 0
    setbuilder_error = False
    mail = None
    try:
        optargs = { '--list-configs':  'List available configurations',
                    '--list-bsets':    'List available build sets',
                    '--list-configs':  'List available configuration files.',
                    '--list-deps':     'List the dependent files.',
                    '--bset-tar-file': 'Create a build set tar file',
                    '--pkg-tar-files': 'Create package tar files',
                    '--no-report':     'Do not create a package report.',
                    '--report-format': 'The report format (text, html, asciidoc).' }
        mailer.append_options(optargs)
        opts = options.load(sys.argv, optargs)
        if opts.get_arg('--mail'):
            mail = { 'mail'  : mailer.mail(opts),
                     'output': log_capture() }
            to_addr = opts.get_arg('--mail-to')
            if to_addr is not None:
                mail['to'] = to_addr[1]
            else:
                mail['to'] = opts.defaults.expand('%{_mail_tools_to}')
            mail['from'] = mail['mail'].from_address()
        log.notice('RTEMS Source Builder - Set Builder, %s' % (version.str()))
        opts.log_info()
        if not check.host_setup(opts):
            raise error.general('host build environment is not set up correctly')
        if mail:
            mail['header'] = os.linesep.join(mail['output'].get()) + os.linesep
            mail['header'] += os.linesep
            mail['header'] += 'Host: '  + reports.platform('compact') + os.linesep
            indent = '       '
            for l in textwrap.wrap(reports.platform('extended'),
                                   width = 80 - len(indent)):
                mail['header'] += indent + l + os.linesep
        configs = build.get_configs(opts)
        if opts.get_arg('--list-deps'):
            deps = []
        else:
            deps = None
        if not list_bset_cfg_files(opts, configs):
            prefix = opts.defaults.expand('%{_prefix}')
            if opts.canadian_cross():
                opts.disable_install()

            if not opts.dry_run() and \
               not opts.canadian_cross() and \
               not opts.no_install() and \
               not path.ispathwritable(prefix):
                raise error.general('prefix is not writable: %s' % (path.host(prefix)))

            for bset in opts.params():
                setbuilder_error = True
                b = buildset(bset, configs, opts)
                b.build(deps, mail = mail)
                b = None
                setbuilder_error = False

        if deps is not None:
            c = 0
            for d in sorted(set(deps)):
                c += 1
                print('dep[%d]: %s' % (c, d))
    except error.general as gerr:
        if not setbuilder_error:
            log.stderr(str(gerr))
        log.stderr('Build FAILED')
        ec = 1
    except error.internal as ierr:
        if not setbuilder_error:
            log.stderr(str(ierr))
        log.stderr('Internal Build FAILED')
        ec = 1
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        ec = 1
    except:
        raise
        log.notice('abort: unknown error')
        ec = 1
    sys.exit(ec)
Ejemplo n.º 45
0
        if host is not None:
            return host
        return 'localhost'

    def send(self, to_addr, subject, body):
        from_addr = self.from_address()
        msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % \
            (from_addr, to_addr, subject) + body
        if type(to_addr) is str:
            to_addr = to_addr.split(',')
        if type(to_addr) is not list:
            raise error.general('invalid to_addr type')
        try:
            s = smtplib.SMTP(self.smtp_host())
            s.sendmail(from_addr, to_addr, msg)
        except smtplib.SMTPException as se:
            raise error.general('sending mail: %s' % (str(se)))
        except socket.error as se:
            raise error.general('sending mail: %s' % (str(se)))


if __name__ == '__main__':
    import sys
    optargs = {}
    append_options(optargs)
    opts = options.load(sys.argv, optargs=optargs, defaults='defaults.mc')
    m = mail(opts)
    print('From: %s' % (m.from_address()))
    print('SMTP Host: %s' % (m.smtp_host()))
    m.send(m.from_address(), 'Test mailer.py', 'This is a test')
Ejemplo n.º 46
0
                    ls = l.split('=')
                    if len(ls) >= 2:
                        _name = ls[1]
        if _email is not None:
            if _name is not None:
                _email = '%s <%s>' % (_name, _email)
            return _email
        return None

    def head(self):
        hash = ''
        ec, output = self._run(['log', '-n', '1'])
        if ec == 0:
            l1 = output.split('\n')[0]
            if l1.startswith('commit '):
                hash = l1[len('commit '):]
        return hash


if __name__ == '__main__':
    import sys
    opts = options.load(sys.argv)
    g = repo('.', opts)
    print g.git_version()
    print g.valid()
    print g.status()
    print g.clean()
    print g.remotes()
    print g.email()
    print g.head()
Ejemplo n.º 47
0
                _email = '%s <%s>' % (_name, _email)
            return _email
        return None

    def head(self):
        hash = ''
        ec, output = self._run(['log', '-n', '1'])
        if ec == 0:
            l1 = output.split('\n')[0]
            if l1.startswith('commit '):
                hash = l1[len('commit '):]
        return hash


if __name__ == '__main__':
    import os.path
    import sys
    defaults = path.join(path.dirname(path.dirname(path.shell(sys.argv[0]))),
                         'defaults.mc')
    opts = options.load(sys.argv, defaults=defaults)
    g = repo('.', opts)
    print('g.git_version():', g.git_version())
    print('g.valid():', g.valid())
    print('g.submodules():', g.submodules())
    print('g.status():', g.status())
    print('g.status():', g.status(True))
    print('g.dirty():', g.dirty())
    print('g.remotes():', g.remotes())
    print('g.email():', g.email())
    print('g.head():', g.head())
Ejemplo n.º 48
0
 
    elif options.dataset_name in timeseriesset:
        timeseriesdataset = TimeSeriesDataset(options)
        train_dataset = timeseriesdataset.type('train')
        validation_dataset = timeseriesdataset.type('validation')
        test_dataset = timeseriesdataset.type('test')
        return train_dataset, validation_dataset, test_dataset

    else:
        raise Exception(f"Sorry, it failed to load dataset {options.dataset_name}")

def main(options):
    train_dataset, validation_dataset, test_dataset = AileverDataset(options)
    train_dataloader = DataLoader(train_dataset, batch_size=options.batch_size, shuffle=True)
    validation_dataloader = DataLoader(validation_dataset, batch_size=options.batch_size, shuffle=True)
    test_dataloader = DataLoader(test_dataset, batch_size=options.batch_size, shuffle=False)

    x_train, y_train = next(iter(train_dataloader))
    print(x_train, y_train)
    x_validation, y_validation = next(iter(validation_dataloader))
    print(x_validation, y_validation)
    x_test, y_test = next(iter(test_dataloader))
    print(x_test, y_test)
    

if __name__ == "__main__":
    options = options.load()
    options.dataset_name = 'internal-univariate-linear-scalar'
    options.dataset_name = 'MNIST'
    main(options)
Ejemplo n.º 49
0
def run(args, command_path=None):
    import sys
    tests = []
    stdtty = console.save()
    opts = None
    default_exefilter = '*.exe'
    try:
        optargs = {
            '--rtems-tools':
            'The path to the RTEMS tools',
            '--rtems-bsp':
            'The RTEMS BSP to run the test on',
            '--user-config':
            'Path to your local user configuration INI file',
            '--report-path':
            'Report output base path (file extension will be added)',
            '--report-format':
            'Formats in which to report test results in addition to txt: json',
            '--log-mode':
            'Reporting modes, failures (default),all,none',
            '--list-bsps':
            'List the supported BSPs',
            '--debug-trace':
            'Debug trace based on specific flags (console,gdb,output,cov)',
            '--filter':
            'Glob that executables must match to run (default: ' +
            default_exefilter + ')',
            '--stacktrace':
            'Dump a stack trace on a user termination (^C)',
            '--coverage':
            'Perform coverage analysis of test executables.'
        }
        mailer.append_options(optargs)
        opts = options.load(args, optargs=optargs, command_path=command_path)
        mail = None
        output = None
        if opts.find_arg('--mail'):
            mail = mailer.mail(opts)
            # Request these now to generate any errors.
            from_addr = mail.from_address()
            smtp_host = mail.smtp_host()
            to_addr = opts.find_arg('--mail-to')
            if to_addr:
                to_addr = to_addr[1]
            else:
                to_addr = '*****@*****.**'
            output = log_capture()
        report_location = opts.find_arg('--report-path')
        if report_location is not None:
            report_location = report_location[1]

        report_formats = opts.find_arg('--report-format')
        if report_formats is not None:
            if len(report_formats) != 2:
                raise error.general('invalid RTEMS report formats option')
            report_formats = report_formats[1].split(',')
            check_report_formats(report_formats, report_location)
        else:
            report_formats = []
        log.notice('RTEMS Testing - Tester, %s' % (version.string()))
        if opts.find_arg('--list-bsps'):
            bsps.list(opts)
        exe_filter = opts.find_arg('--filter')
        if exe_filter:
            exe_filter = exe_filter[1]
        else:
            exe_filter = default_exefilter
        opts.log_info()
        log.output('Host: ' + host.label(mode='all'))
        executables = find_executables(opts.params(), exe_filter)
        debug_trace = opts.find_arg('--debug-trace')
        if debug_trace:
            if len(debug_trace) != 1:
                debug_trace = debug_trace[1]
            else:
                raise error.general(
                    'no debug flags, can be: console,gdb,output,cov')
        else:
            debug_trace = ''
        opts.defaults['exe_trace'] = debug_trace
        job_trace = 'jobs' in debug_trace.split(',')
        rtems_tools = opts.find_arg('--rtems-tools')
        if rtems_tools is not None:
            if len(rtems_tools) != 2:
                raise error.general('invalid RTEMS tools option')
            rtems_tools = rtems_tools[1]
        bsp = opts.find_arg('--rtems-bsp')
        if bsp is None or len(bsp) != 2:
            raise error.general('RTEMS BSP not provided or an invalid option')
        bsp = config.load(bsp[1], opts)
        bsp_config = opts.defaults.expand(opts.defaults['tester'])
        coverage_enabled = opts.find_arg('--coverage')
        if coverage_enabled:
            cov_trace = 'cov' in debug_trace.split(',')
            if len(coverage_enabled) == 2:
                coverage_runner = coverage.coverage_run(
                    opts.defaults,
                    executables,
                    rtems_tools,
                    symbol_set=coverage_enabled[1],
                    trace=cov_trace)
            else:
                coverage_runner = coverage.coverage_run(opts.defaults,
                                                        executables,
                                                        rtems_tools,
                                                        trace=cov_trace)
        log_mode = opts.find_arg('--log-mode')
        if log_mode:
            if log_mode[1] != 'failures' and \
                    log_mode[1] != 'all' and \
                    log_mode[1] != 'none':
                raise error.general('invalid report mode')
            log_mode = log_mode[1]
        else:
            log_mode = 'failures'
        if len(executables) == 0:
            raise error.general('no executables supplied')
        start_time = datetime.datetime.now()
        total = len(executables)
        reports = report.report(total)
        reporting = 1
        jobs = int(opts.jobs(opts.defaults['_ncpus']))
        exe = 0
        finished = []
        if jobs > len(executables):
            jobs = len(executables)
        while exe < total or len(tests) > 0:
            if exe < total and len(tests) < jobs:
                tst = test_run(exe + 1, total, reports, executables[exe],
                               rtems_tools, bsp, bsp_config, opts)
                exe += 1
                tests += [tst]
                if job_trace:
                    _job_trace(tst, 'create', total, exe, tests, reporting)
                tst.run()
            else:
                dead = [t for t in tests if not t.is_alive()]
                tests[:] = [t for t in tests if t not in dead]
                for tst in dead:
                    if job_trace:
                        _job_trace(tst, 'dead', total, exe, tests, reporting)
                    finished += [tst]
                    tst.reraise()
                del dead
                if len(tests) >= jobs or exe >= total:
                    time.sleep(0.250)
                if len(finished):
                    reporting = report_finished(reports, log_mode, reporting,
                                                finished, job_trace)
        finished_time = datetime.datetime.now()
        reporting = report_finished(reports, log_mode, reporting, finished,
                                    job_trace)
        if reporting < total:
            log.warning('finished jobs does match: %d' % (reporting))
            report_finished(reports, log_mode, -1, finished, job_trace)
        reports.summary()
        end_time = datetime.datetime.now()
        average_time = 'Average test time: %s' % (str(
            (end_time - start_time) / total))
        total_time = 'Testing time     : %s' % (str(end_time - start_time))
        log.notice(average_time)
        log.notice(total_time)
        for report_format in report_formats:
            report_formatters[report_format](
                args, reports, start_time, end_time, total,
                '.'.join([report_location, report_format]))

        if mail is not None and output is not None:
            m_arch = opts.defaults.expand('%{arch}')
            m_bsp = opts.defaults.expand('%{bsp}')
            build = ' %s:' % (reports.get_config('build', not_found=''))
            subject = '[rtems-test] %s/%s:%s %s' % (
                m_arch, m_bsp, build, reports.score_card('short'))
            np = 'Not present in test'
            ver = reports.get_config('version', not_found=np)
            build = reports.get_config('build', not_found=np)
            tools = reports.get_config('tools', not_found=np)
            body = [
                total_time, average_time, '', 'Host', '====',
                host.label(mode='all'), '', 'Configuration', '=============',
                'Version: %s' % (ver),
                'Build  : %s' % (build),
                'Tools  : %s' % (tools), '', 'Summary', '=======', '',
                reports.score_card(), '',
                reports.failures(), 'Log', '===', ''
            ] + output.get()
            mail.send(to_addr, subject, os.linesep.join(body))
        if coverage_enabled:
            coverage_runner.run()

    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit:
        sys.exit(2)
    except KeyboardInterrupt:
        if opts is not None and opts.find_arg('--stacktrace'):
            print('}} dumping:', threading.active_count())
            for t in threading.enumerate():
                print('}} ', t.name)
            print(stacktraces.trace())
        log.notice('abort: user terminated')
        killall(tests)
        sys.exit(1)
    finally:
        console.restore(stdtty)
    sys.exit(0)
Ejemplo n.º 50
0
            return _email
        return None

    def head(self):
        hash = ''
        ec, output = self._run(['log', '-n', '1'])
        if ec == 0:
            l1 = output.split('\n')[0]
            if l1.startswith('commit '):
                hash = l1[len('commit '):]
        return hash

if __name__ == '__main__':
    import sys
    import options
    long_opts = {
       # key              macro        handler   param  defs   init
    }
    opts = options.command_line(base_path = '.',
                                argv = sys.argv,
                                long_opts = long_opts)
    options.load(opts)
    g = repo('.', opts)
    print('version:', g.git_version())
    print('valid:', g.valid())
    print('status:', g.status())
    print('dirty:', g.dirty())
    print('remotes:', g.remotes())
    print('email:', g.email())
    print('head:', g.head())
Ejemplo n.º 51
0
    glViewport(0, 0, *dpysize)

reopen()

glEnable(GL_DEPTH_TEST)
glEnable(GL_CULL_FACE)
glEnable(GL_TEXTURE_2D)

glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

timers={"start": 0}

clock=pygame.time.Clock()

if options.load():
    options.add_bind("W", "walk_forward")
    options.add_bind("S", "walk_backward")
    options.add_bind("A", "strafe_left")
    options.add_bind("D", "strafe_right")

    options.add_bind("Space_Tap", "jump")

    options.add_bind("Mouse1", "shoot")
    options.add_bind("Left_Control", "shoot")

    options.add_bind("Mouse4_Tap", "weapon_next")
    options.add_bind("Mouse5_Tap", "weapon_prev")

    options.add_bind("Mouse3", "scope")