Пример #1
0
 def configure(self, config):
     Module.configure(self, config)
     if not self.version:
         self.version = m.ReadModuleName()
     # Import appropriate the ADAM module (or package).
     module = 'mpx.ion.adam.adam' + self.version
     command = compile('import ' + module,
                       'mpx.ion.adam.unknown.configure()', 'exec')
     eval(command)
     # Get the module's factory and instanciate the "real" class.
     command = module + '.factory'
     adam_factory = eval(command, globals(), locals())
     self.instance = adam_factory()
     
     # Scary stuff.  Detach this ion from our parent, configure the real
     # instance (thus attaching it to the parent) and then morph this
     # instance to behave like the real instance (in case anyone has a
     # handle to this instance).
     try:
         self.parent._del_child(self.name)
         self.instance.configure(config)
         attributes = vars(self.instance.__class__)
         attributes.update(vars(self.instance))
         for attrribute in attributes:
             setattr(self, attrribute, getattr(self.instance, attrribute))
     except:
         msglog.exception()
         # The scary stuff failed, reattach to the parent.
         try:
             self.parent._del_child(self.instance.name)
         except:
             pass
         self.parent._add_child(self)
Пример #2
0
    def configure(self, config):
        Module.configure(self, config)
        if not self.version:
            self.version = m.ReadModuleName()
        # Import appropriate the ADAM module (or package).
        module = 'mpx.ion.adam.adam' + self.version
        command = compile('import ' + module,
                          'mpx.ion.adam.unknown.configure()', 'exec')
        eval(command)
        # Get the module's factory and instanciate the "real" class.
        command = module + '.factory'
        adam_factory = eval(command, globals(), locals())
        self.instance = adam_factory()

        # Scary stuff.  Detach this ion from our parent, configure the real
        # instance (thus attaching it to the parent) and then morph this
        # instance to behave like the real instance (in case anyone has a
        # handle to this instance).
        try:
            self.parent._del_child(self.name)
            self.instance.configure(config)
            attributes = vars(self.instance.__class__)
            attributes.update(vars(self.instance))
            for attrribute in attributes:
                setattr(self, attrribute, getattr(self.instance, attrribute))
        except:
            msglog.exception()
            # The scary stuff failed, reattach to the parent.
            try:
                self.parent._del_child(self.instance.name)
            except:
                pass
            self.parent._add_child(self)
Пример #3
0
 def scan(self):
     for addr in range(0,0x100):
         try:
             m = Module()
             m.configure({'name':'adamXXXX', 'parent':self,
                          'line_handler':self, 'address':addr})
             print '0x%02X' % addr, '(%3d)' % addr, m.ReadModuleName()
         except EIOError:
             print "."
         del m
Пример #4
0
 def scan(self):
     for addr in range(0, 0x100):
         try:
             m = Module()
             m.configure({
                 'name': 'adamXXXX',
                 'parent': self,
                 'line_handler': self,
                 'address': addr
             })
             print '0x%02X' % addr, '(%3d)' % addr, m.ReadModuleName()
         except EIOError:
             print "."
         del m
Пример #5
0
def do_build(module_configs, log_dir, options):
    result = BuildResult()
    nb_modules = len(module_configs)
    for idx, config in enumerate(module_configs):
        name = config.flat_get("name")
        assert name
        flog.h1("%d/%d %s" % (idx + 1, nb_modules, name))
        module = Module(config)
        log_file_name = os.path.join(log_dir, name.replace("/", "_") + ".log")
        log_file = open(log_file_name, "w")
        runner = Runner(log_file, options.verbose)

        # update/checkout
        if options.switch_branch and module.has_checkout():
            module.switch_branch(runner)

        if not options.no_src:
            try:
                if module.has_checkout():
                    module.update(runner)
                else:
                    module.checkout(runner)
            except BatchBuildError, exc:
                flog.error("%s failed to update/checkout: %s", name, exc)
                flog.p("See %s", log_file_name)
                result.vcs_fails.append([name, str(exc), log_file_name])
                nanotify.notify(name, "Failed to update/checkout", icon="dialog-warning")
                if options.fatal:
                    return result

        # Build
        try:
            if not options.src_only:
                if options.refresh_build:
                    module.refresh_build()
                module.configure(runner)
                module.build(runner)
                module.install(runner)
                nanotify.notify(name, "Build successfully", icon="dialog-ok")
        except BatchBuildError, exc:
            flog.error("%s failed to build: %s", name, exc)
            flog.p("See %s", log_file_name)
            result.build_fails.append([name, str(exc), log_file_name])
            nanotify.notify(name, "Failed to build", icon="dialog-error")
            if options.fatal:
                return result