def __init__(self, **kwargs): """init""" super(Action, self).__init__(**kwargs) base = kwargs.get("base") if not base: base = rfx.Base() # no .cfg_load() -- we don't need it rcs = kwargs.get('rcs') if not rcs: rcs = rfx.client.Session(base=base) self.rfxcfg = rfx.config.ConfigProcessor(base=base, rcs=rcs)
def main(): parser = argparse.ArgumentParser() parser.add_argument("--debug", action='append') parser.add_argument("--dbinit", action='store_true') parser.add_argument("--noclean", "--no-clean", action='store_true') parser.add_argument("option", choices=['unit', 'lint', 'integration', 'functional', 'full-stack']) args = parser.parse_args() base = rfx.Base(debug=args.debug).cfg_load() libdir = "../../src" baseurl = "http://127.0.0.1:54321/api" tester = Tester(base=base, baseurl=baseurl) tap = tester.tap ########################################################################### base.timestamp = False # so our output is not altered by timestamps base.term_width = 80 #schema = rfxengine.db.objects.Schema(master=tester.dbm) schema = None def get_libfiles(): flist = [] for (base, folders, files) in os.walk(libdir + "/rfxengine"): for f in files: if f[-3:] == ".py": if libdir == base: flist.append(f) else: flist.append(base.replace(libdir + "/", "") + "/" + f) return flist # if args.dbinit: # schema.initialize(verbose=True, reset=True) if args.option == 'unit': for f in get_libfiles(): if f != "rfxengine/abac.py": # bug w/global:MASTER_ATTRS breaking doctest tap.unit(libdir, f, exit_on_fail=False) return elif args.option == 'lint': tap.lint(libdir, 'rfxengine', exit_on_fail=False) return elif args.option == 'integration': test_integration(schema, base, tester, args) elif args.option == 'functional': test_functional(schema, base, tester, baseurl, args) elif args.option == 'full-stack': test_full_stack(schema, base, tester, baseurl, args) tester.tap.exit()
def main(): """de mojo""" parser = argparse.ArgumentParser() parser.add_argument("--debug", action='append') parser.add_argument("--test", action='store_true') args = parser.parse_args() base = rfx.Base(debug=args.debug, logfmt='txt').cfg_load() if args.test: base.timestamp = False else: base.timestamp = True setproctitle.setproctitle('reflex-engine') # pylint: disable=no-member rfxengine.SERVER = Server(base=base) rfxengine.SERVER.start(test=args.test)
def start(self, argv=None, opts=None): args = self.args.handle_parse(caller=self, argv=argv, opts=opts) if not args or args.get('--help') and not self.args.argv: self.fail() self.base = rfx.Base().cfg_load() self.engine = Engine(base=self.base) cfg = self.engine.TRAP(self.engine.get_object, 'config', 'reflex', notify=False) if not cfg: self.fail( "Missing config.reflex. Try setting up demo data `reflex setup demo`" ) self.cfg = dictlib.Obj(cfg['config']) # if args.get('action') == 'list': self._list(args)
def new_base(args): """ Common code to get the reflex base object >>> import json >>> b = new_base({'--debug': '*', '--logfmt': 'json', '--notime':True}) >>> json.dumps(b.debug, sort_keys=True) '{"*": true, "basic": false}' >>> b.logfmt 'json' >>> b.timestamp False """ debug = [] logfmt = 'txt' if args: debug = args.get('--debug', []) logfmt = args.get('--logfmt', 'txt') timestamp = not args.get('--notime') base = rfx.Base(debug=debug, logfmt=logfmt).cfg_load() base.timestamp = timestamp return base