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

« back to all changes in this revision

Viewing changes to services/usrmgt-server

  • Committer: Matt Giuca
  • Date: 2010-02-11 06:08:15 UTC
  • Revision ID: matt.giuca@gmail.com-20100211060815-9oue3zuuvg18w1yp
Exercises page redone to be consistent with worksheets page. Now looks much better, and contains an edit button for each exercise. Also renamed page headings for both pages to 'manage' rather than 'edit' (consistent with links to these pages).

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import logging
6
6
 
7
7
import ivle.config
8
 
import ivle.conf
9
8
import ivle.database
10
9
import ivle.chat
11
10
import ivle.makeuser
12
11
 
 
12
config = ivle.config.Config()
 
13
 
13
14
# usage:
14
15
#   usrmgt-server <port> <magic>
15
16
 
38
39
    @return: None
39
40
    """
40
41
 
 
42
    if not os.path.exists(config['paths']['jails']['template']):
 
43
        return {
 
44
            'response': 'error',
 
45
            'message': 'Template jail has not been built -- '
 
46
                       'do you need to run ivle-buildjail?'}
 
47
 
41
48
    os.umask(0022) # Bad, but start_server sets it worse.
42
49
 
43
50
    login = props['login']
48
55
    user = ivle.database.User.get_by_login(store, login)
49
56
 
50
57
    # make svn config/auth
51
 
    repopath = os.path.join(ivle.conf.svn_repo_path, 'users', login)
 
58
    repopath = os.path.join(config['paths']['svn']['repo_path'],
 
59
                            'users', login)
52
60
    logging.debug("Creating user's Subversion repository")
53
61
    ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
54
62
 
59
67
                                         throw_on_error=True)
60
68
 
61
69
    logging.debug("Creating jail")
62
 
    ivle.makeuser.make_jail(user)
 
70
    ivle.makeuser.make_jail(user, config)
63
71
 
64
72
    logging.info("Enabling user")
65
73
    user.state = u'enabled'
107
115
    groupnm = props['groupnm']
108
116
 
109
117
    namespace = "_".join([subj_short_name, year, semester, groupnm])
110
 
    repopath = os.path.join(ivle.conf.svn_repo_path, 'groups', namespace)
 
118
    repopath = os.path.join(config['paths']['svn']['repo_path'],
 
119
                            'groups', namespace)
111
120
    logging.debug("Creating Subversion repository %s"%repopath)
112
121
    try:
113
122
        ivle.makeuser.make_svn_repo(repopath)
128
137
def initializer():
129
138
    logging.basicConfig(filename="/var/log/usrmgt.log", level=logging.INFO)
130
139
    logging.info("Starting usrmgt server on port %d (pid = %d)" %
131
 
                 (ivle.conf.usrmgt_port, pid))
 
140
                 (config['usrmgt']['port'], pid))
132
141
 
133
142
    try:
134
143
        pidfile = open('/var/run/usrmgt-server.pid', 'w')
141
150
def dispatch(props):
142
151
    logging.debug(repr(props))
143
152
 
144
 
    config = ivle.config.Config()
145
153
    store = ivle.database.get_store(config)
146
154
    action = props.keys()[0]
147
155
    res = actions[action](store, props[action], config)
156
164
if __name__ == "__main__":
157
165
    pid = os.getpid()
158
166
 
159
 
    ivle.chat.start_server(ivle.conf.usrmgt_port, ivle.conf.usrmgt_magic,
 
167
    ivle.chat.start_server(config['usrmgt']['port'],config['usrmgt']['magic'],
160
168
                           True, dispatch, initializer)