~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/svn.py

  • Committer: Matt Giuca
  • Date: 2009-02-25 10:19:29 UTC
  • mfrom: (1100.1.35 new-ui)
  • Revision ID: matt.giuca@gmail.com-20090225101929-v2206kbf3lgkm1kz
*Spoiler warning: Plot or ending details follow*

Merged from new-ui branch.

IVLE top bar and top of filebrowser and console have all been made over. They
look very shiny and web 2.0!

Added image-source top-level directory with SVG source images.

Added new chrome images to ivle/webapp/coremedia/images.

Redid a lot CSS and HTML.
Every page now has an H1 at the top (common UI). Moved existing H1s to the top
of the page. Other H1s have been cleaned up (moved to H2s or restyled).
IVLE top bar has been majorly cleaned up (previously had many layered divs);
now more accessible.

Subject icon replaced with tutorial one.

The funeral for the tacky yellow and blue stylesheet will be held this Friday.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
import pysvn
25
25
 
26
 
def create_auth_svn_client_autopass(username, save_credentials=False):
27
 
    """Create a new pysvn client which is set up to automatically authenticate
28
 
    with the supplied user. The user's Subversion password is automatically
29
 
    looked up in the database.
30
 
    (Requires database access -- can't be used inside the jail.)
31
 
    @param username: IVLE/Subversion username.
32
 
    @param save_credentials: Save the user's credentials. Should be False when
33
 
        outside the jail.
34
 
    """
35
 
    # Note: Must do this inside the function, since this file may be used in
36
 
    # the jail, and importing ivle.database crashes in the jail.
37
 
    from ivle.config import Config
38
 
    import ivle.database
39
 
    from ivle.database import User
40
 
    store = ivle.database.get_store(Config())
41
 
    user = store.find(User, User.login==unicode(username)).one()
42
 
    return create_auth_svn_client(username, user.svn_pass, save_credentials)
43
 
 
44
 
def create_auth_svn_client(username, password, save_credentials=True):
45
 
    """Create a new pysvn client which is set up to automatically authenticate
46
 
    with the supplied credentials.
47
 
    @param username: IVLE/Subversion username.
48
 
    @param password: Subversion password.
49
 
    @param save_credentials: Save the user's credentials. Should be False when
50
 
        outside the jail.
51
 
    """
52
 
    username = str(username)
53
 
    password = str(password)
54
 
    def get_login(_realm, existing_login, _may_save):
55
 
        """Callback function used by pysvn for authentication.
56
 
        realm, existing_login, _may_save: The 3 arguments passed by pysvn to
57
 
            callback_get_login.
58
 
            The following has been determined empirically, not from docs:
59
 
            existing_login will be the name of the user who owns the process on
60
 
            the first attempt, "" on subsequent attempts. We use this fact.
61
 
        """
62
 
        # Only provide credentials on the _first_ attempt.
63
 
        # If we're being asked again, then it means the credentials failed for
64
 
        # some reason and we should just fail. (This is not desirable, but it's
65
 
        # better than being asked an infinite number of times).
66
 
        return (existing_login != "", username, password, save_credentials)
67
 
 
68
 
    svnclient = pysvn.Client()
69
 
    svnclient.callback_get_login = get_login
70
 
    return svnclient
71
 
 
72
26
def revision_from_string(r_str):
73
27
    if r_str is None:
74
28
        pass
94
48
    except pysvn.ClientError:
95
49
        return False
96
50
 
97
 
def revision_is_dir(client, path, revision):
98
 
    """Returns True if the given path+revision is a directory.
99
 
    @raises a pysvn.ClientError if it does not exist.
100
 
    """
101
 
    # XXX I *think* the first element of the list is the requested object, and
102
 
    # subsequent items are its possible children (so ignore them).
103
 
    list_object, _ = client.list(path, revision=revision)[0]
104
 
    # list_object is a PySvnList object
105
 
    return list_object.kind == pysvn.node_kind.dir
106
 
 
107
51
class PysvnListStatWrapper:
108
52
    '''Wrap a pysvn listing object to look somewhat like a result of
109
53
       os.stat.