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

« back to all changes in this revision

Viewing changes to scripts/usrmgt-server

  • Committer: mattgiuca
  • Date: 2008-06-13 13:16:17 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:768
usrmgt-server: Made do_checkout work!
    (The "re-checkout" button in the UI now functions - it's not very nice
    though).
    Refactored do_checkout, now gets password from DB and does a bunch of
    other things right which it didn't before.
    activate_user now calls do_checkout rather than having its own checkout
    code.
Note: do_checkout still needs a refactor.

Show diffs side-by-side

added added

removed removed

Lines of Context:
163
163
        logging.debug("Creating jail")
164
164
        common.makeuser.make_jail(login, details.unixid, svn_pass=passwd)
165
165
 
166
 
        # Check out the repositories into the student's home dir
167
 
        # FIXME: Call do_checkout instead of replicating this code.
168
 
        # (do_checkout currently doesn't work)
169
 
        #do_checkout(props)
170
 
 
171
 
        logging.debug("Checking out directories in the jail")
172
 
        try:
173
 
            svn.checkout(conf.svn_addr + login + "/stuff",
174
 
                         common.studpath.url_to_local(login + "/stuff")[1])
175
 
            os.system("chown -R %d:%d %s" \
176
 
                    % (details.unixid, details.unixid,
177
 
                       common.studpath.url_to_local(login + "/stuff")[1]))
178
 
        except Exception, exc:
179
 
            logging.warning("While mkdiring stuff: %s" % str(exc))
180
 
            pass
181
 
        try:
182
 
            svn.checkout(conf.svn_addr + login + "/info1",
183
 
                         common.studpath.url_to_local(login + "/info1")[1])
184
 
            os.system("chown -R %d:%d %s" \
185
 
                    % (details.unixid, details.unixid,
186
 
                       common.studpath.url_to_local(login + "/info1")[1]))
187
 
        except Exception, exc:
188
 
            logging.warning("While mkdiring info1: %s" % str(exc))
189
 
            pass
 
166
        do_checkout(props, svn_pass=passwd)
190
167
 
191
168
        # FIXME: should this be nicer?
192
169
        os.system("chown -R %d:%d %s" \
193
170
                % (details.unixid, details.unixid,
194
171
                   common.studpath.url_to_local(login)[1]))
195
172
 
196
 
 
197
173
        logging.info("Enabling user")
198
174
        db.update_user(login, state='enabled')
199
175
 
202
178
    finally:
203
179
        db.close()
204
180
 
205
 
def do_checkout(props):
 
181
def do_checkout(props, svn_pass=None):
206
182
    """Create the default contents of a user's jail by checking out from the
207
183
    repositories.
208
184
    If any directory already exists, just fail silently (so this is not a
212
188
                      STRING REQUIRED
213
189
       Return Value: None
214
190
    """
215
 
    # XXX / FIXME: This doesn't work - cannot get passwd
216
 
    # (activate_me creates passwd, other svn stuff gets it from jailconf - we
217
 
    # can't access either at this point).
218
 
 
219
191
    login = props['login']
 
192
 
 
193
    # If svn_pass isn't supplied, grab it from the DB
 
194
    if svn_pass is None:
 
195
        db = common.db.DB()
 
196
        user = db.get_user(login)
 
197
        svn_pass = user.svn_pass
 
198
        db.close()
 
199
 
220
200
    svn = pysvn.Client()
221
 
    svn.callback_get_login = partial(get_login, login, passwd)
222
 
 
223
 
    if conf.svn_addr[-1] != '/':
224
 
        conf.svn_addr = conf.svn_addr + "/"
225
 
 
226
 
    # FIXME: </hack>
 
201
    svn.callback_get_login = partial(get_login, login, svn_pass)
 
202
 
 
203
    if conf.svn_addr[-1] != os.sep:
 
204
        conf.svn_addr += os.sep
 
205
 
 
206
    # FIXME: <hack>
227
207
 
228
208
    logging.debug("Checking out directories in the jail")
229
209
    try:
230
210
        svn.checkout(conf.svn_addr + login + "/stuff",
231
211
                     common.studpath.url_to_local(login + "/stuff")[1])
232
212
        os.system("chown -R %d:%d %s" \
233
 
                % (details.unixid, details.unixid,
 
213
                % (user.unixid, user.unixid,
234
214
                   common.studpath.url_to_local(login + "/stuff")[1]))
235
215
    except Exception, exc:
236
216
        logging.warning("While mkdiring stuff: %s" % str(exc))
239
219
        svn.checkout(conf.svn_addr + login + "/info1",
240
220
                     common.studpath.url_to_local(login + "/info1")[1])
241
221
        os.system("chown -R %d:%d %s" \
242
 
                % (details.unixid, details.unixid,
 
222
                % (user.unixid, user.unixid,
243
223
                   common.studpath.url_to_local(login + "/info1")[1]))
244
224
    except Exception, exc:
245
225
        logging.warning("While mkdiring info1: %s" % str(exc))
246
226
        pass
247
227
 
 
228
    # FIXME: </hack>
 
229
 
248
230
    return {"response": "okay"}
249
231
 
250
232
actions = {