Exemple #1
0
def _get_ssh_config(path="~/.ssh/config"):
    """Return a parsed ``SSHConfig``, if config file present and parsable."""
    try:
        with open(os.path.expanduser(path), "r") as f:
            config = SSHConfig()
            try:
                # noinspection PyTypeChecker
                config.parse(f)
                return config
            except Exception:
                pass
    except IOError:
        pass
Exemple #2
0
		host, _ = netloc.split(':')
	else:
		host = netloc

	return host


def get_ssh_config(logger):
	try:
		config_file = file(expanduser('~/.ssh/config'))
	except IOError, ex:
		logger.debug(ex)
		return None
	else:
		try:
			config = SSHConfig()
			config.parse(config_file)
		except Exception, ex:
			logger.debug(ex)
			return None
	return config


def annotate_url_with_ssh_config_info(url, logger):
	from urlparse import urlsplit, urlunsplit

	config = get_ssh_config(logger)

	added = None
	if config:
		parsed_url = urlsplit(url)