Handle repo configuration.
558934
def _handle_repos(self, root):
        """"""
        ElementTree.SubElement(root, "key").text = "repos"
        repos_array = ElementTree.SubElement(root, "array")

        # Make a temporary jss object to try to pull repo information.
        jss_server = JSS(url=self.url, user=self.user, password=self.password,
                         ssl_verify=self.verify, suppress_warnings=True)
        print "Fetching distribution point info..."
        try:
            dpts = jss_server.DistributionPoint()
        except JSSGetError:
            print ("Fetching distribution point info failed. If you want to "
                   "configure distribution points, ensure that your API user "
                   "has read permissions for distribution points, and that "
                   "the URL, username, and password are correct.")
            dpts = None

        if dpts:
            print ("There are file share distribution points configured on "
                   "your JSS. Most of the configuration can be automated "
                   "from the information on the JSS, with the exception of "
                   "the password for the R/W user.\n")

            for dpt in dpts:
                repo_dict = ElementTree.SubElement(repos_array, "dict")

                repo_name_key = ElementTree.SubElement(repo_dict, "key")
                repo_name_key.text = "name"
                repo_name_string = ElementTree.SubElement(repo_dict, "string")
                repo_name_string.text = dpt.get("name")

                repo_pass_key = ElementTree.SubElement(repo_dict, "key")
                repo_pass_key.text = "password"
                repo_pass_string = ElementTree.SubElement(repo_dict, "string")
                repo_pass_string.text = getpass.getpass(
                    "Please enter the R/W user's password for distribution "
                    "point: %s: " % dpt.get("name", "<NO NAME CONFIGURED>"))

        _handle_dist_server("JDS", repos_array)
        _handle_dist_server("CDP", repos_array)
121603
def pull_repo(repo_name):
    """"""
    repo = ClonedRepo.objects.get(pk=repo_name)
    repo.pull()
1065320
def configure(self):
        """"""

        config = self.config
        if 'version' not in config:
            raise ValueError("dictionary doesn't specify a version")
        if config['version'] != 1:
            raise ValueError("Unsupported version: %s" % config['version'])
        incremental = config.pop('incremental', False)
        EMPTY_DICT = {}
        logging._acquireLock()
        try:
            if incremental:
                handlers = config.get('handlers', EMPTY_DICT)
                # incremental handler config only if handler name
                # ties in to logging._handlers (Python 2.7)
                if sys.version_info[:2] == (2, 7):
                    for name in handlers:
                        if name not in logging._handlers:
                            raise ValueError('No handler found with '
                                             'name %r'  % name)
                        else:
                            try:
                                handler = logging._handlers[name]
                                handler_config = handlers[name]
                                level = handler_config.get('level', None)
                                if level:
                                    handler.setLevel(_checkLevel(level))
                            except StandardError, e:
                                raise ValueError('Unable to configure handler '
                                                 '%r: %s' % (name, e))
                loggers = config.get('loggers', EMPTY_DICT)
                for name in loggers:
                    try:
                        self.configure_logger(name, loggers[name], True)
                    except StandardError, e:
                        raise ValueError('Unable to configure logger '
                                         '%r: %s' % (name, e))
                root = config.get('root', None)
                if root:
                    try:
                        self.configure_root(root, True)
                    except StandardError, e:
                        raise ValueError('Unable to configure root '
                                         'logger: %s' % e)
            else:
                disable_existing = config.pop('disable_existing_loggers', True)
                
                logging._handlers.clear()
                del logging._handlerList[:]
                    
                # Do formatters first - they don't refer to anything else
                formatters = config.get('formatters', EMPTY_DICT)
                for name in formatters:
                    try:
                        formatters[name] = self.configure_formatter(
                                                            formatters[name])
                    except StandardError, e:
                        raise ValueError('Unable to configure '
                                         'formatter %r: %s' % (name, e))
                # Next, do filters - they don't refer to anything else, either
                filters = config.get('filters', EMPTY_DICT)
                for name in filters:
                    try:
                        filters[name] = self.configure_filter(filters[name])
                    except StandardError, e:
                        raise ValueError('Unable to configure '
                                         'filter %r: %s' % (name, e))

                # Next, do handlers - they refer to formatters and filters
                # As handlers can refer to other handlers, sort the keys
                # to allow a deterministic order of configuration
                handlers = config.get('handlers', EMPTY_DICT)
                for name in sorted(handlers):
                    try:
                        handler = self.configure_handler(handlers[name])
                        handler.name = name
                        handlers[name] = handler
                    except StandardError, e:
                        raise ValueError('Unable to configure handler '
                                         '%r: %s' % (name, e))
                # Next, do loggers - they refer to handlers and filters
                
                #we don't want to lose the existing loggers,
                #since other threads may have pointers to them.
                #existing is set to contain all existing loggers,
                #and as we go through the new configuration we
                #remove any which are configured. At the end,
                #what's left in existing is the set of loggers
                #which were in the previous configuration but
                #which are not in the new configuration.
                root = logging.root
                existing = root.manager.loggerDict.keys()
                #The list needs to be sorted so that we can
                #avoid disabling child loggers of explicitly
                #named loggers. With a sorted list it is easier
                #to find the child loggers.
                existing.sort()
                #We'll keep the list of existing loggers
                #which are children of named loggers here...
                child_loggers = []
                #now set up the new ones...
                loggers = config.get('loggers', EMPTY_DICT)
                for name in loggers:
                    if name in existing:
                        i = existing.index(name)
                        prefixed = name + "."
                        pflen = len(prefixed)
                        num_existing = len(existing)
                        i = i + 1 # look at the entry after name
                        while (i < num_existing) and\
                              (existing[i][:pflen] == prefixed):
                            child_loggers.append(existing[i])
                            i = i + 1
                        existing.remove(name)
                    try:
                        self.configure_logger(name, loggers[name])
                    except StandardError, e:
                        raise ValueError('Unable to configure logger '
                                         '%r: %s' % (name, e))
                    
                #Disable any old loggers. There's no point deleting
                #them as other threads may continue to hold references
                #and by disabling them, you stop them doing any logging.
                #However, don't disable children of named loggers, as that's
                #probably not what was intended by the user.
                for log in existing:
                    logger = root.manager.loggerDict[log]
                    if log in child_loggers:
                        logger.level = logging.NOTSET
                        logger.handlers = []
                        logger.propagate = True
                    elif disable_existing:
                        logger.disabled = True
    
                # And finally, do the root logger
                root = config.get('root', None)
                if root:
                    try:
                        self.configure_root(root)                        
                    except StandardError, e:
                        raise ValueError('Unable to configure root '
                                         'logger: %s' % e)
        finally:
            logging._releaseLock()
796026
def get_value(repo_directory, key, expect_type=None):
    """"""
    config = read_config(repo_directory)
    value = config.get(key)
    if expect_type and value is not None and not isinstance(value, expect_type):
        raise ConfigSchemaError('Expected config variable %s to be type %s, got %s'
            % (repr(key), repr(expect_type), repr(type(value))))
    return value
802509
def _read_repos(conf_file, repos, filename, regex):
    '''
    
    '''
    for line in conf_file:
        line = salt.utils.stringutils.to_unicode(line)
        if not regex.search(line):
            continue
        repo = _create_repo(line, filename)

        # do not store duplicated uri's
        if repo['uri'] not in repos:
            repos[repo['uri']] = [repo]
898934
def set(self, repo):
        
        name = repo.name
        if name in self.__repositories \
           and self.__repositories[name].is_initialized:
            raise ValueError('Can not replace repositories that have been '
                             'initialized.')
        self.__repositories[name] = repo
970094
def config(
    state, host, key, value,
    repo=None,
):
    '''
    
    '''

    existing_config = host.fact.git_config(repo)

    if key not in existing_config or existing_config[key] != value:
        if repo is None:
            yield 'git config --global {0} "{1}"'.format(key, value)
        else:
            yield 'cd {0} && git config --local {1} "{2}"'.format(repo, key, value)
1266093
def Handle(self, args, token=None):
    """"""

    if not args.name:
      raise ValueError("Name not specified.")

    return ApiConfigOption().InitFromConfigOption(args.name)
237115
def _config(self):
        """"""
        cfg_wr = self.repo.config_writer()
        cfg_wr.add_section('user')
        cfg_wr.set_value('user', 'name', self.metadata.author)
        cfg_wr.set_value('user', 'email', self.metadata.email)
        cfg_wr.release()
756227
def generate_repo_files(self, release):
        """"""
        repo_tmpl = pkg_resources.resource_string(__name__, 'templates/repo.mako')
        repo_file = os.path.join(release['git_dir'], '%s.repo' % release['repo'])
        with file(repo_file, 'w') as repo:
            repo_out = Template(repo_tmpl).render(**release)
            self.log.debug('Writing repo file %s:\n%s', repo_file, repo_out)
            repo.write(repo_out)
        self.log.info('Wrote repo configuration to %s', repo_file)
381823
def update_configs(self, release):
        
        git_repo = release['git_repo']
        git_cache = release['git_cache']
        if not os.path.isdir(git_cache):
            self.call(['git', 'clone', '--mirror', git_repo, git_cache])
        else:
            self.call(['git', 'fetch', '--all', '--prune'], cwd=git_cache)
        git_dir = release['git_dir'] = os.path.join(release['tmp_dir'],
                                                    os.path.basename(git_repo))
        self.call(['git', 'clone', '-b', release['git_branch'],
                   git_cache, git_dir])

        if release['delete_repo_files']:
            for repo_file in glob.glob(os.path.join(git_dir, '*.repo')):
                self.log.info('Deleting %s' % repo_file)
                os.unlink(repo_file)
1317200
def configure(options)

      # config file default options
      configuration = {
                        :options => {
                          :verbose => false,
                          :color => 'AUTO',
                          :short => false,
                          :unmodified => 'HIDE',
                          :match => 'ALL',
                          :list => 'ALL'
                        },
                        :commands => [
                          'diff',
                          'grep',
                          'log',
                          'ls-files',
                          'show',
                          'status'
                        ]
                      }

      # set default config if not given on command line
      config = options[:config]
      if config.nil?
        config = [
                   File.join(@working_dir, "repo.conf"),
                   File.join(@working_dir, ".repo.conf"),
                   File.join(@working_dir, "repo_manager", "repo.conf"),
                   File.join(@working_dir, ".repo_manager", "repo.conf"),
                   File.join(@working_dir, "config", "repo.conf"),
                   File.expand_path(File.join("~", ".repo.conf")),
                   File.expand_path(File.join("~", "repo.conf")),
                   File.expand_path(File.join("~", "repo_manager", "repo.conf")),
                   File.expand_path(File.join("~", ".repo_manager", "repo.conf"))
                 ].detect { |filename| File.exists?(filename) }
      end

      if config && File.exists?(config)
        # load options from the config file, overwriting hard-coded defaults
        logger.debug "reading configuration file: #{config}"
        config_contents = YAML.load(ERB.new(File.open(config, "rb").read).result)
        configuration.merge!(config_contents.symbolize_keys!) if config_contents && config_contents.is_a?(Hash)
      else
        # user specified a config file?, no error if user did not specify config file
        raise "config file not found" if options[:config]
      end

      # store the original full config filename for later use
      configuration[:configuration_filename] = config

      configuration.recursively_symbolize_keys!

      # the command line options override options read from the config file
      configuration[:options].merge!(options)
      configuration
    end
979396
def hg_hook(ui, repo, node=None, **kwargs):
    """"""
    seen = set()
    paths = []
    if len(repo):
        for rev in range(repo[node], len(repo)):
            for file_ in repo[rev].files():
                file_ = op.join(repo.root, file_)
                if file_ in seen or not op.exists(file_):
                    continue
                seen.add(file_)
                paths.append(file_)

    options = parse_options()
    setup_logger(options)
    if paths:
        process_paths(options, candidates=paths)
1018866
private static function install(Application $app, string $config, string $repo) : void
    {
        $options = [
            'command'         => 'install',
            '--configuration' => $config,
            '--git-directory' => $repo,
            '-f'              => '-f'
        ];
        $app->run(new ArrayInput($options));
    }
1010583
def write_config(repo_directory, config):
    """"""
    return write_config_file(os.path.join(repo_directory, config_file), config)
711798
def write_configuration(self, out, secret_attrs=False):
        """"""
        key_order = ['name', 'path', 'git_dir', 'doc_dir', 'assumed_doc_version',
                     'git_ssh', 'pkey', 'has_aliases', 'number of collections']
        cd = self.get_configuration_dict(secret_attrs=secret_attrs)
        for k in key_order:
            if k in cd:
                out.write('  {} = {}'.format(k, cd[k]))
        out.write('  collections in alias groups:\n')
        for o in cd['collections']:
            out.write('    {} ==> {}\n'.format(o['keys'], o['relpath']))
920355
def cleanup_repo(self):
        """"""
        if self.source and path.isdir(self.source):
            self.log.debug('Cleaning up source repo from %s', self.source)
            shutil.rmtree(self.source)