def list(self): from source.repository import new_repository return [ new_repository(self.this.sourcerepo(r_name)) for r_name in self.this.group('sourcerepo').keys() if r_name != 'dir' ]
def testBasic(self): import random repo = new_repository(self.rc.sourcerepo('clarinova.data')) repo.bundle_dir = self.bundle.bundle_dir repo.delete_remote() import time time.sleep(3) repo.init() repo.init_remote() repo.push(repo.service.user, repo.service.password)
def run(self, argv): b = self args = b.parse_args(argv) if args.command == "config": if args.subcommand == "rewrite": b.log("Rewriting the config file") with self.session: b.update_configuration() elif args.subcommand == "dump": print b.config._run_config.dump() elif args.subcommand == "schema": print b.schema.as_markdown() return if "command_group" in args and args.command_group == "source": from source.repository import new_repository repo = new_repository(b.config._run_config.sourcerepo("default")) repo.bundle = b if args.command == "commit": repo.commit(args.message) elif args.command == "push": repo.commit(args.message) repo.push() elif args.command == "pull": repo.pull() return if args.command == "repopulate": b.repopulate() return if hasattr(args, "clean") and args.clean: # If the clean arg is set, then we need to run clean, and all of the # earlerier build phases. ph = { "meta": ["clean"], "prepare": ["clean"], "build": ["clean", "prepare"], "update": ["clean", "prepare"], "install": ["clean", "prepare", "build"], "submit": ["clean", "prepare", "build"], "extract": ["clean", "prepare", "build"], } else: ph = {"build": ["prepare"]} phases = ph.get(args.command, []) + [args.command] if args.test: print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" print "!!!!!! In Test Mode !!!!!!!!!!" print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" import time time.sleep(1) if "info" in phases: if args.schema: print b.schema.as_csv() else: b.log("----Info ---") b.log("VID : " + b.identity.vid) b.log("Name : " + b.identity.name) b.log("VName: " + b.identity.vname) b.log("Parts: {}".format(b.partitions.count)) if b.config.build.get("dependencies", False): b.log("---- Dependencies ---") for k, v in b.config.build.dependencies.items(): b.log(" {}: {}".format(k, v)) if b.partitions.count < 5: b.log("---- Partitions ---") for partition in b.partitions: b.log(" " + partition.name) return if "run" in phases: # # Run a method on the bundle. Can be used for testing and development. try: f = getattr(b, str(args.method)) except AttributeError as e: b.error("Could not find method named '{}': {} ".format(args.method, e)) b.error("Available methods : {} ".format(dir(b))) return if not callable(f): raise TypeError("Got object for name '{}', but it isn't a function".format(args.method)) return f(*args.args) if "clean" in phases: b.log("---- Cleaning ---") # Only clean the meta phases when it is explicityly specified. b.clean(clean_meta=("meta" in phases)) # The Meta phase prepares neta information, such as list of cites # that is doenloaded from a website, or a specificatoin for a schema. # The meta phase does not require a database, and should write files # that only need to be done once. if "meta" in phases: if b.pre_meta(): b.log("---- Meta ----") if b.meta(): b.post_meta() b.log("---- Done Meta ----") else: b.log("---- Meta exited with failure ----") return False else: b.log("---- Skipping Meta ---- ") if "prepare" in phases: if not b.run_prepare(): return False if "build" in phases: if b.run_args.test: print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" print "!!!!!! In Test Mode !!!!!!!!!!" print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" time.sleep(1) if not b.run_build(): return False if "update" in phases: if b.pre_update(): b.log("---- Update ---") if b.update(): b.post_update() b.log("---- Done Updating ---") else: b.log("---- Update exited with failure ---") return False else: b.log("---- Skipping Update ---- ") if "install" in phases: self.run_install() if "extract" in phases: if b.pre_extract(): b.log("---- Extract ---") if b.extract(): b.post_extract() b.log("---- Done Extracting ---") else: b.log("---- Extract exited with failure ---") else: b.log("---- Skipping Extract ---- ") # Submit puts information about the the bundles into a catalog # and may store extracts of the data in the catalog. if "submit" in phases: if b.pre_submit(): b.log("---- Submit ---") if b.submit(): b.post_submit() b.log("---- Done Submitting ---") else: b.log("---- Submit exited with failure ---") else: b.log("---- Skipping Submit ---- ") if "test" in phases: """ Run the unit tests""" import nose, unittest, sys # @UnresolvedImport dir_ = b.filesystem.path("test") # @ReservedAssignment loader = nose.loader.TestLoader() tests = loader.loadTestsFromDir(dir_) result = unittest.TextTestResult(sys.stdout, True, 1) # @UnusedVariable print "Loading tests from ", dir_ for test in tests: print "Running ", test test.context.bundle = b unittest.TextTestRunner().run(test)