def get_svn_auth(project_name, config_dir): """Return (username, password) for project_name in config_dir.""" # Default to returning nothing. result = (None, None) try: from svn.core import SVN_AUTH_CRED_SIMPLE, svn_config_read_auth_data from svn.core import SubversionException except ImportError: return result realm = ('<https://%s.googlecode.com:443> Google Code Subversion Repository' % project_name) # auth may be none even if no exception is raised, e.g. if config_dir does # not exist, or exists but has no entry for realm. try: auth = svn_config_read_auth_data(SVN_AUTH_CRED_SIMPLE, realm, config_dir) except SubversionException: auth = None if auth is not None: try: result = (auth['username'], auth['password']) except KeyError: # Missing the keys, so return nothing. pass return result
def get_svn_auth(project_name, config_dir): """Return (username, password) for project_name in config_dir.""" # Default to returning nothing. result = (None, None) try: from svn.core import SVN_AUTH_CRED_SIMPLE, svn_config_read_auth_data from svn.core import SubversionException except ImportError: return result realm = ( '<https://%s.googlecode.com:443> Google Code Subversion Repository' % project_name) # auth may be none even if no exception is raised, e.g. if config_dir does # not exist, or exists but has no entry for realm. try: auth = svn_config_read_auth_data(SVN_AUTH_CRED_SIMPLE, realm, config_dir) except SubversionException: auth = None if auth is not None: try: result = (auth['username'], auth['password']) except KeyError: # Missing the keys, so return nothing. pass return result
def get_svn_auth(project_name, config_dir): """Return (username, password) for project_name in config_dir. This function is not working now, as svn_config_read_auth_data's 1st argument should be apr_hash_t **, it requies ctypes module. It is possible to implement it. However, there is already a Summer of Code project working on ctypes_python_binding. So, we don't have to waste our engergy. The work around for now is add a password option to this script """ # Default to returning nothing. result = (None, None) try: from svn.core import SVN_AUTH_CRED_SIMPLE, svn_config_read_auth_data from svn.core import SubversionException import csvn # We will fail here, so this function will returen None regardlessly except ImportError: return result realm = ( '<https://%s.googlecode.com:443> Google Code Subversion Repository' % project_name) pool = Pool() creds_hash = apr_hash_make(pool) # auth may be none even if no exception is raised, e.g. if config_dir does # not exist, or exists but has no entry for realm. try: auth = svn_config_read_auth_data(creds_hash, SVN_AUTH_CRED_SIMPLE, realm, config_dir, pool) except SubversionException: auth = None if auth is not None: try: result = (auth['username'], auth['password']) except KeyError: # Missing the keys, so return nothing. pass print pool print creds_hash print realm return result
def get_svn_auth(project_name, config_dir): """Return (username, password) for project_name in config_dir. This function is not working now, as svn_config_read_auth_data's 1st argument should be apr_hash_t **, it requies ctypes module. It is possible to implement it. However, there is already a Summer of Code project working on ctypes_python_binding. So, we don't have to waste our engergy. The work around for now is add a password option to this script """ # Default to returning nothing. result = (None, None) try: from svn.core import SVN_AUTH_CRED_SIMPLE, svn_config_read_auth_data from svn.core import SubversionException import csvn # We will fail here, so this function will returen None regardlessly except ImportError: return result realm = ('<https://%s.googlecode.com:443> Google Code Subversion Repository' % project_name) pool = Pool() creds_hash = apr_hash_make(pool) # auth may be none even if no exception is raised, e.g. if config_dir does # not exist, or exists but has no entry for realm. try: auth = svn_config_read_auth_data(creds_hash, SVN_AUTH_CRED_SIMPLE, realm, config_dir, pool) except SubversionException: auth = None if auth is not None: try: result = (auth['username'], auth['password']) except KeyError: # Missing the keys, so return nothing. pass print pool print creds_hash print realm return result