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

« back to all changes in this revision

Viewing changes to scripts/usrmgt-server

  • Committer: drtomc
  • Date: 2008-02-25 04:12:24 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:571
usrmgt: improve the logging. Amazing what happens when you actually read
    the documentation. :-)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#   - Rebuild svn auth file
35
35
#   - Rebuild passwd + push to nodes.
36
36
 
37
 
log = logging.FileHandler("/var/log/usrmgt.log")
38
 
 
39
37
def create_user(props):
40
38
    """Create the database record for the given user.
41
39
       Expected properties:
102
100
def get_login(login, passwd, _realm, _login, _may_save):
103
101
    """Callback function used by pysvn for authentication.
104
102
    """
105
 
    log.debug("Getting password for %s (realm %s)" % (login, _realm))
 
103
    logging.debug("Getting password for %s (realm %s)" % (login, _realm))
106
104
    return (True, login, passwd, False)
107
105
 
108
106
def activate_user(props):
126
124
 
127
125
        # make svn config/auth
128
126
 
129
 
        log.debug("Creating repo")
 
127
        logging.debug("Creating repo")
130
128
        common.makeuser.make_svn_repo(login, throw_on_error=False)
131
 
        log.debug("Creating svn config")
 
129
        logging.debug("Creating svn config")
132
130
        common.makeuser.make_svn_config(login, throw_on_error=False)
133
 
        log.debug("Creating svn auth")
 
131
        logging.debug("Creating svn auth")
134
132
        passwd = common.makeuser.make_svn_auth(login, throw_on_error=False)
135
 
        log.debug("passwd: %s" % passwd)
 
133
        logging.debug("passwd: %s" % passwd)
136
134
 
137
135
        svn = pysvn.Client()
138
136
        svn.callback_get_login = partial(get_login, login, passwd)
146
144
        #        offerings.
147
145
        #        Instead, we're just going to use a single offering with
148
146
        #        a "short" name of "info1".
149
 
        log.debug("Creating /info1")
 
147
        logging.debug("Creating /info1")
150
148
        try:
151
149
            svn.mkdir(conf.svn_addr + login + "/info1",
152
150
                      "Initial creation of work directory for Informatics 1")
153
151
        except Exception, exc:
154
 
            log.warning("While mkdiring info1: %s" % str(exc))
 
152
            logging.warning("While mkdiring info1: %s" % str(exc))
155
153
            pass
156
 
        log.debug("Creating /submissions")
 
154
        logging.debug("Creating /submissions")
157
155
        try:
158
156
            svn.mkdir(conf.svn_addr + login + "/submissions",
159
157
                      "Initial creation of submissions directory")
160
158
        except Exception, exc:
161
 
            log.warning("While mkdiring submissions: %s" % str(exc))
 
159
            logging.warning("While mkdiring submissions: %s" % str(exc))
162
160
            pass
163
 
        log.debug("Creating /stuff")
 
161
        logging.debug("Creating /stuff")
164
162
        try:
165
163
            svn.mkdir(conf.svn_addr + login + "/stuff",
166
164
                      "Initial creation of directory for miscellania")
167
165
        except Exception, exc:
168
 
            log.warning("While mkdiring stuff: %s" % str(exc))
 
166
            logging.warning("While mkdiring stuff: %s" % str(exc))
169
167
            pass
170
168
 
171
 
        log.debug("Creating jail")
 
169
        logging.debug("Creating jail")
172
170
        common.makeuser.make_jail(login, details.unixid)
173
171
 
174
172
        # FIXME: <hack>
188
186
 
189
187
        # FIXME: </hack>
190
188
 
191
 
        log.debug("Checking out directories in the jail")
 
189
        logging.debug("Checking out directories in the jail")
192
190
        try:
193
191
            svn.checkout(conf.svn_addr + login + "/stuff",
194
192
                         common.studpath.url_to_local(login + "/stuff")[1])
195
193
        except Exception, exc:
196
 
            log.warning("While mkdiring stuff: %s" % str(exc))
 
194
            logging.warning("While mkdiring stuff: %s" % str(exc))
197
195
            pass
198
196
        try:
199
197
            svn.checkout(conf.svn_addr + login + "/submissions",
200
198
                         common.studpath.url_to_local(login + "/submissions")[1])
201
199
        except Exception, exc:
202
 
            log.warning("While mkdiring submissions: %s" % str(exc))
 
200
            logging.warning("While mkdiring submissions: %s" % str(exc))
203
201
            pass
204
202
        try:
205
203
            svn.checkout(conf.svn_addr + login + "/info1",
206
204
                         common.studpath.url_to_local(login + "/info1")[1])
207
205
        except Exception, exc:
208
 
            log.warning("While mkdiring info1: %s" % str(exc))
 
206
            logging.warning("While mkdiring info1: %s" % str(exc))
209
207
            pass
210
208
 
211
209
        # FIXME: should this be nicer?
214
212
                   common.studpath.url_to_local(login)[1]))
215
213
 
216
214
 
217
 
        log.info("Enabling user")
 
215
        logging.info("Enabling user")
218
216
        db.update_user(login, state='enabled')
219
217
 
220
218
        return {"response": "okay"}
229
227
    }
230
228
 
231
229
def dispatch(props):
232
 
    log.debug(repr(props))
 
230
    logging.debug(repr(props))
233
231
    action = props.keys()[0]
234
232
    return actions[action](props[action])
235
233
 
239
237
 
240
238
    pid = os.getpid()
241
239
 
242
 
    log.info("Starting usrmgt server on port %d (pid = %d)" % (port, pid))
 
240
    logging.basicConfig(filename="/var/log/usrmgt.log", level=logging.INFO)
 
241
    logging.info("Starting usrmgt server on port %d (pid = %d)" % (port, pid))
243
242
 
244
243
    common.chat.start_server(port, magic, True, dispatch)