def load(args, optargs=None, command_path=None, defaults='%s' % (defaults_mc)): # # The path to this command if not supplied by the upper layers. # if command_path is None: command_path = path.dirname(args[0]) if len(command_path) == 0: command_path = '.' # # Check if there is a defaults.mc file under the command path. If so this is # the tester being run from within the git repo. If not found assume the tools # have been installed and the defaults is in the install prefix. # if path.exists(path.join(command_path, defaults_mc)): rtdir = command_path else: rtdir = '%{_prefix}/share/rtems/tester' defaults = '%s/%s' % (rtdir, defaults_mc) # # The command line contains the base defaults object all build objects copy # and modify by loading a configuration. # opts = command_line(args, optargs, macros.macros(name=defaults, rtdir=rtdir), command_path) options.load(opts) return opts
def load(args, optargs=None, command_path=None, defaults="%s" % (defaults_mc)): # # The path to this command if not supplied by the upper layers. # if command_path is None: command_path = path.dirname(args[0]) if len(command_path) == 0: command_path = "." # # Check if there is a defaults.mc file under the command path. If so this is # the tester being run from within the git repo. If not found assume the tools # have been installed and the defaults is in the install prefix. # if path.exists(path.join(command_path, defaults_mc)): rtdir = command_path else: rtdir = "%{_prefix}/share/rtems/tester" defaults = "%s/%s" % (rtdir, defaults_mc) # # The command line contains the base defaults object all build objects copy # and modify by loading a configuration. # opts = command_line(args, optargs, macros.macros(name=defaults, rtdir=rtdir), command_path) options.load(opts) return opts
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)
def load(args, optargs = None, command_path = None, defaults = '%{_rtdir}/rtems/testing/defaults.mc'): # # The path to this command if not supplied by the upper layers. # if command_path is None: command_path = path.dirname(args[0]) if len(command_path) == 0: command_path = '.' # # The command line contains the base defaults object all build objects copy # and modify by loading a configuration. # opts = command_line(args, optargs, macros.macros(name = defaults, rtdir = command_path), command_path) options.load(opts) return opts
def run(args): import sys try: _opts = options.command_line(argv=args) options.load(_opts) log.notice('RTEMS Toolkit - Check, v%s' % (version.string())) 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)
def send_file_as_body(self, to_addr, subject, name, intro=None): try: with open(name, 'r') as f: body = f.readlines() except IOError as err: raise error.general('error reading mail body: %s' % (name)) if intro is not None: body = intro + body self.send(to_addr, from_addr, body) if __name__ == '__main__': import sys from rtemstoolkit import macros optargs = {} rtdir = 'rtemstoolkit' defaults = '%s/defaults.mc' % (rtdir) append_options(optargs) opts = options.command_line(base_path='.', argv=sys.argv, optargs=optargs, defaults=macros.macros(name=defaults, rtdir=rtdir), command_path='.') options.load(opts) m = mail(opts) print('From: %s' % (m.from_address())) print('SMTP Host: %s' % (m.smtp_host())) if '--mail' in sys.argv: m.send(m.from_address(), 'Test mailer.py', 'This is a test')