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

« back to all changes in this revision

Viewing changes to services/usrmgt-server

  • Committer: Matt Giuca
  • Date: 2009-02-24 02:02:03 UTC
  • mto: This revision was merged to the branch mainline in revision 1119.
  • Revision ID: matt.giuca@gmail.com-20090224020203-aqdcjnsj6y7wl32o
Added a new look to the IVLE header bar. Mmmm... Web 2.0.
Added top-level directory image-source, containing SVG and script files for
    generating the images.
ivle/webapp/coremedia/images: Added 'chrome' directory containing the rendered
    images.
Modified ivle/webapp/base/ivle-headings.html and
    ivle/webapp/coremedia/ivle.css to support the new images.
    Note that the H1 and H2 at the top of the page are no longer displayed
    (and their custom styles have been removed). There is a heading image
    instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import sys
5
5
import logging
6
6
 
7
 
import ivle.config
 
7
import ivle.conf
8
8
import ivle.database
9
9
import ivle.chat
10
10
import ivle.makeuser
11
11
 
12
 
config = ivle.config.Config()
13
 
 
14
12
# usage:
15
13
#   usrmgt-server <port> <magic>
16
14
 
29
27
#   - Rebuild svn auth file
30
28
#   - Rebuild passwd + push to nodes.
31
29
 
32
 
def activate_user(store, props, config):
 
30
def activate_user(store, props):
33
31
    """Create the on-disk stuff for the given user.
34
32
       Sets the state of the user in the db from pending to enabled.
35
 
    @param config: An ivle.config.Config object.
36
33
       Expected properties:
37
34
        login       - the user name for the jail
38
35
                      STRING REQUIRED
39
 
    @return: None
 
36
       Return Value: None
40
37
    """
41
38
 
42
39
    os.umask(0022) # Bad, but start_server sets it worse.
49
46
    user = ivle.database.User.get_by_login(store, login)
50
47
 
51
48
    # make svn config/auth
52
 
    repopath = os.path.join(config['paths']['svn']['repo_path'],
53
 
                            'users', login)
 
49
    repopath = os.path.join(ivle.conf.svn_repo_path, 'users', login)
54
50
    logging.debug("Creating user's Subversion repository")
55
51
    ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
56
52
 
57
 
    rebuild_svn_config(store, props, config)
 
53
    rebuild_svn_config(store, props)
58
54
 
59
55
    logging.debug("Adding Subversion authentication")
60
 
    passwd = ivle.makeuser.make_svn_auth(store, login, config,
 
56
    passwd = ivle.makeuser.make_svn_auth(store, login,
61
57
                                         throw_on_error=True)
62
58
 
63
59
    logging.debug("Creating jail")
64
 
    ivle.makeuser.make_jail(user, config)
 
60
    ivle.makeuser.make_jail(user)
65
61
 
66
62
    logging.info("Enabling user")
67
63
    user.state = u'enabled'
68
64
 
69
65
    return {"response": "okay"}
70
66
 
71
 
def rebuild_svn_config(store, props, config):
 
67
def rebuild_svn_config(store, props):
72
68
    """Rebuilds the svn config file
73
 
    @param config: An ivle.config.Config object.
74
 
    @return: response (okay, failure)
 
69
    Return value:
 
70
        response (okay, failure)
75
71
    """
76
72
    try:
77
 
        ivle.makeuser.rebuild_svn_config(store, config)
 
73
        ivle.makeuser.rebuild_svn_config(store)
78
74
    except Exception, e:
79
75
        logging.warning('Rebuild of Subversion authorization config failed!')
80
76
        return{'response': 'failure', 'msg': repr(e)}
81
77
 
82
78
    return {'response': 'okay'}
83
79
 
84
 
def rebuild_svn_group_config(store, props, config):
 
80
def rebuild_svn_group_config(store, props):
85
81
    """Rebuilds the svn group config file
86
 
    @param config: An ivle.config.Config object.
87
 
    @return: response (okay, failure)
 
82
    Return value:
 
83
        response (okay, failure)
88
84
    """
89
85
    try:
90
 
        ivle.makeuser.rebuild_svn_group_config(store, config)
 
86
        ivle.makeuser.rebuild_svn_group_config(store)
91
87
    except Exception, e:
92
88
        logging.warning(
93
89
            'Rebuild of Subversion group authorization config failed!')
95
91
 
96
92
    return {'response': 'okay'}
97
93
 
98
 
def create_group_repository(store, props, config):
 
94
def create_group_repository(store, props):
99
95
    """Creates on disk repository for the given group
100
 
    @param config: An ivle.config.Config object.
101
96
    Expected properties:
102
97
        subj_short_name, year, semester, groupnm
103
 
    @return: response (okay, failure)
 
98
    Return value:
 
99
        response (okay, failure)
104
100
    """
105
101
 
106
102
    subj_short_name = props['subj_short_name']
109
105
    groupnm = props['groupnm']
110
106
 
111
107
    namespace = "_".join([subj_short_name, year, semester, groupnm])
112
 
    repopath = os.path.join(config['paths']['svn']['repo_path'],
113
 
                            'groups', namespace)
 
108
    repopath = os.path.join(ivle.conf.svn_repo_path, 'groups', namespace)
114
109
    logging.debug("Creating Subversion repository %s"%repopath)
115
110
    try:
116
111
        ivle.makeuser.make_svn_repo(repopath)
131
126
def initializer():
132
127
    logging.basicConfig(filename="/var/log/usrmgt.log", level=logging.INFO)
133
128
    logging.info("Starting usrmgt server on port %d (pid = %d)" %
134
 
                 (config['usrmgt']['port'], pid))
 
129
                 (ivle.conf.usrmgt_port, pid))
135
130
 
136
131
    try:
137
132
        pidfile = open('/var/run/usrmgt-server.pid', 'w')
144
139
def dispatch(props):
145
140
    logging.debug(repr(props))
146
141
 
147
 
    store = ivle.database.get_store(config)
 
142
    store = ivle.database.get_store()
148
143
    action = props.keys()[0]
149
 
    res = actions[action](store, props[action], config)
 
144
    res = actions[action](store, props[action])
150
145
 
151
146
    if res['response'] == 'okay':
152
147
        store.commit()
158
153
if __name__ == "__main__":
159
154
    pid = os.getpid()
160
155
 
161
 
    ivle.chat.start_server(config['usrmgt']['port'],config['usrmgt']['magic'],
 
156
    ivle.chat.start_server(ivle.conf.usrmgt_port, ivle.conf.usrmgt_magic,
162
157
                           True, dispatch, initializer)