def process_config_set(config_set_name, destination_path=None, configs_folder=None, params=None, verbose=True): if params is None: params = {} if os.path.isfile(config_set_name): # it's a file config_xml = et.parse(config_set_name) source_context = os.path.dirname(config_set_name) else: # try a named config set in the configs folder if configs_folder is None: configs_folder = get_configs_folder() if config_set_name not in get_config_sets(configs_folder): raise NamedConfigSetNotFoundException(config_set_name) filename = pathutil.join(configs_folder, config_set_name, '.config-set.xml') config_xml = et.parse(filename) source_context = pathutil.join(configs_folder, config_set_name) for folder in config_xml.findall('folder'): folder_path = folder.attrib.get('path', '.') for f in folder.findall('file'): file_source = pathutil.join(source_context, f.attrib['src']) file_basename = os.path.basename(file_source) if destination_path and folder_path: full_dest = pathutil.join(destination_path, folder_path) elif destination_path: full_dest = destination_path elif folder_path: full_dest = folder_path else: full_dest = '.' pathutil.create_folder(full_dest) file_dest = pathutil.join(full_dest, file_basename) if verbose: applying = '' if len(params) > 0: # TODO: maybe output parameters provided/substituted? applying = ', applying config parameters' print ('Copy from "%s" to "%s"%s' % (file_source, file_dest, applying)) copy_and_apply_params(file_source, file_dest, params, verbose)
def _expandsubinclude(kindpats, root): '''Returns the list of subinclude matchers and the kindpats without the subincludes in it.''' relmatchers = [] other = [] for kind, pat, source in kindpats: if kind == 'subinclude': sourceroot = pathutil.dirname(util.normpath(source)) pat = util.pconvert(pat) path = pathutil.join(sourceroot, pat) newroot = pathutil.dirname(path) relmatcher = match(newroot, '', [], ['include:%s' % path]) prefix = pathutil.canonpath(root, root, newroot) if prefix: prefix += '/' relmatchers.append((prefix, relmatcher)) else: other.append((kind, pat, source)) return relmatchers, other
import requests import unittest import conf import pathutil import xmlrunner as _xmlrunner import logging import time import argparse import os logger = logging.getLogger(__name__) target_hostname = '50.57.189.15' target_port = 8080 config_dir = pathutil.join(os.getcwd(), 'etc/repose') deploy_dir = pathutil.join(os.getcwd(), 'var/repose') artifact_dir = pathutil.join(os.getcwd(), 'usr/share/repose/filters') log_file = pathutil.join(os.getcwd(), 'var/log/repose/current.log') stop_port = 7777 def setUpModule(): # Set up folder hierarchy and install repose JAR/EARs if needed logger.debug('setUpModule') pathutil.create_folder(config_dir) pathutil.create_folder(deploy_dir) pathutil.create_folder(os.path.dirname(log_file)) pass
def get_config_sets(configs_folder): for entry in os.listdir(configs_folder): if os.path.isdir('%s/%s' % (configs_folder, entry)): if os.path.exists(pathutil.join(configs_folder, entry, '.config-set.xml')): yield entry