def __hook(self): dirname = bzt.get_configs_dir() if os.path.exists(dirname): sys.stdout.write("[%s] Found %s\n" % (bzt.VERSION, dirname)) src = os.path.join(dirname, "10-base.json") if os.path.exists(src): sys.stdout.write("Removing outdated %s\n" % src) os.remove(src)
def __hook(self): dirname = bzt.get_configs_dir() sys.stdout.write("[%s] Creating %s\n" % (bzt.VERSION, dirname)) if not os.path.exists(dirname): os.makedirs(dirname) src = os.path.join(os.path.dirname(__file__), "bzt", "10-base.json") sys.stdout.write("[%s] Copying %s to %s\n" % (bzt.VERSION, src, dirname)) shutil.copy(src, dirname + os.path.sep)
def _scan_system_configs(self): configs = [] machine_dir = get_configs_dir() # can't refactor machine_dir out - see setup.py if os.path.isdir(machine_dir): self.log.debug("Reading system configs from: %s", machine_dir) for cfile in sorted(os.listdir(machine_dir)): fname = os.path.join(machine_dir, cfile) if os.path.isfile(fname): configs.append(fname) return configs
def _load_base_configs(self): base_configs = [os.path.join(get_full_path(__file__, step_up=1), 'resources', 'base-config.yml')] machine_dir = get_configs_dir() # can't refactor machine_dir out - see setup.py if os.path.isdir(machine_dir): self.log.debug("Reading extension configs from: %s", machine_dir) for cfile in sorted(os.listdir(machine_dir)): fname = os.path.join(machine_dir, cfile) if os.path.isfile(fname): base_configs.append(fname) else: self.log.debug("No machine configs dir: %s", machine_dir) self.config.load(base_configs)
def _load_base_configs(self): base_configs = [os.path.join(RESOURCES_DIR, 'base-config.yml')] machine_dir = get_configs_dir() # can't refactor machine_dir out - see setup.py if os.path.isdir(machine_dir): self.log.debug("Reading extension configs from: %s", machine_dir) for cfile in sorted(os.listdir(machine_dir)): fname = os.path.join(machine_dir, cfile) if os.path.isfile(fname): base_configs.append(fname) else: self.log.debug("No machine configs dir: %s", machine_dir) self.log.debug("Base configs list: %s", base_configs) self.config.load(base_configs)
def __hook(self): dirname = bzt.get_configs_dir() sys.stdout.write("[%s] Creating %s\n" % (bzt.VERSION, dirname)) if not os.path.exists(dirname): os.makedirs(dirname) src = os.path.join(os.path.dirname(__file__), "bzt", "10-base.json") sys.stdout.write("Copying %s to %s\n" % (src, dirname)) shutil.copy(src, dirname + os.path.sep) sys.stdout.write("Generating install-id\n") install_id = os.path.join(dirname, '99-installID.yml') if not os.path.exists(install_id): with open(install_id, 'w') as fhd: fhd.write("---\ninstall-id: %s" % uuid.uuid4())
def _load_base_configs(self): base_configs = [] machine_dir = get_configs_dir() # can't refactor machine_dir out - see setup.py if os.path.isdir(machine_dir): self.log.debug("Reading machine configs from: %s", machine_dir) for cfile in sorted(os.listdir(machine_dir)): fname = os.path.join(machine_dir, cfile) if os.path.isfile(fname): base_configs.append(fname) else: self.log.info("No machine configs dir: %s", machine_dir) user_file = os.path.expanduser(os.path.join('~', ".bzt-rc")) if os.path.isfile(user_file): self.log.debug("Adding personal config: %s", user_file) base_configs.append(user_file) else: self.log.info("No personal config: %s", user_file) self.config.load(base_configs)
def __load_configs(self, user_configs): """ :param user_configs: list of config files :return: """ for fname in user_configs: self.existing_artifact(fname) # prepare base configs base_configs = [] # can't refactor machine_dir out - see setup.py machine_dir = get_configs_dir() if os.path.isdir(machine_dir): self.log.debug("Reading machine configs from: %s", machine_dir) for cfile in os.listdir(machine_dir): fname = os.path.join(machine_dir, cfile) if os.path.isfile(fname): base_configs.append(fname) else: self.log.info("No machine configs dir: %s", machine_dir) user_file = os.path.expanduser(os.path.join('~', ".bzt-rc")) if os.path.isfile(user_file): self.log.debug("Adding personal config: %s", user_file) base_configs.append(user_file) else: self.log.info("No personal config: %s", user_file) # load user configs user_config = Configuration() user_config.load(user_configs) user_config.dump(self.create_artifact("merged", ".yml"), Configuration.YAML) user_config.dump(self.create_artifact("merged", ".json"), Configuration.JSON) # load base and merge user into it self.config.load(base_configs) self.config.merge(user_config)