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

« back to all changes in this revision

Viewing changes to scripts/usrmgt-server

  • Committer: mattgiuca
  • Date: 2008-02-21 05:03:21 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:529
setup.py: Fixed copytree; now able to handle copying a directory over itself
(just does nothing).
usrmgt-server: Fixed all the commented out prints, replacing them with calls
to a "log" function which is configurable as to whether it prints or not.
makeuser.py: Removed the creation of jails.
    Now it creates a unix account, and a database entry.
    It *shouldn't* be creating a unix account still. (?)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#   - Rebuild svn auth file
33
33
#   - Rebuild passwd + push to nodes.
34
34
 
 
35
DEBUG_PRINT = True
35
36
 
36
37
def create_user(props):
37
38
    """Create the database record for the given user.
95
96
def get_login(login, passwd, _realm, _login, _may_save):
96
97
    """Callback function used by pysvn for authentication.
97
98
    """
98
 
    # print >> sys.stderr, "Getting password for %s (realm %s)" % (login, _realm)
 
99
    log("Getting password for %s (realm %s)" % (login, _realm))
99
100
    return (True, login, passwd, False)
100
101
 
101
102
def activate_user(props):
119
120
 
120
121
        # make svn config/auth
121
122
 
122
 
        # print >> sys.stderr, "Creating repo"
 
123
        log("Creating repo")
123
124
        common.makeuser.make_svn_repo(login, throw_on_error=False)
124
 
        # print >> sys.stderr, "Creating svn config"
 
125
        log("Creating svn config")
125
126
        common.makeuser.make_svn_config(login, throw_on_error=False)
126
 
        # print >> sys.stderr, "Creating svn auth"
 
127
        log("Creating svn auth")
127
128
        passwd = common.makeuser.make_svn_auth(login, throw_on_error=False)
128
 
        # print >> sys.stderr, "passwd: %s" % passwd
 
129
        log("passwd: %s" % passwd)
129
130
 
130
131
        svn = pysvn.Client()
131
132
        svn.callback_get_login = partial(get_login, login, passwd)
139
140
        #        offerings.
140
141
        #        Instead, we're just going to use a single offering with
141
142
        #        a "short" name of "info1".
142
 
        # print >> sys.stderr, "Creating /info1"
 
143
        log("Creating /info1")
143
144
        try:
144
145
            svn.mkdir(conf.svn_addr + login + "/info1",
145
146
                      "Initial creation of work directory for Informatics 1")
146
147
        except Exception, exc:
147
 
            # print >> sys.stderr, "While mkdiring info1: %s" % str(exc)
 
148
            log("While mkdiring info1: %s" % str(exc))
148
149
            pass
149
 
        # print >> sys.stderr, "Creating /submissions"
 
150
        log("Creating /submissions")
150
151
        try:
151
152
            svn.mkdir(conf.svn_addr + login + "/submissions",
152
153
                      "Initial creation of submissions directory")
153
154
        except Exception, exc:
154
 
            # print >> sys.stderr, "While mkdiring submissions: %s" % str(exc)
 
155
            log("While mkdiring submissions: %s" % str(exc))
155
156
            pass
156
 
        # print >> sys.stderr, "Creating /stuff"
 
157
        log("Creating /stuff")
157
158
        try:
158
159
            svn.mkdir(conf.svn_addr + login + "/stuff",
159
160
                      "Initial creation of directory for miscellania")
160
161
        except Exception, exc:
161
 
            # print >> sys.stderr, "While mkdiring stuff: %s" % str(exc)
 
162
            log("While mkdiring stuff: %s" % str(exc))
162
163
            pass
163
164
 
164
 
        # print >> sys.stderr, "Creating jail"
 
165
        log("Creating jail")
165
166
        common.makeuser.make_jail(login, details.unixid)
166
167
 
167
168
        # FIXME: <hack>
181
182
 
182
183
        # FIXME: </hack>
183
184
 
184
 
        # print >> sys.stderr, "Checking out directories in the jail"
 
185
        log("Checking out directories in the jail")
185
186
        try:
186
187
            svn.checkout(conf.svn_addr + login + "/stuff",
187
188
                         common.studpath.url_to_local(login + "/stuff")[1])
188
189
        except Exception, exc:
189
 
            # print >> sys.stderr, "While mkdiring stuff: %s" % str(exc)
 
190
            log("While mkdiring stuff: %s" % str(exc))
190
191
            pass
191
192
        try:
192
193
            svn.checkout(conf.svn_addr + login + "/submissions",
193
194
                         common.studpath.url_to_local(login + "/submissions")[1])
194
195
        except Exception, exc:
195
 
            # print >> sys.stderr, "While mkdiring submissions: %s" % str(exc)
 
196
            log("While mkdiring submissions: %s" % str(exc))
196
197
            pass
197
198
        try:
198
199
            svn.checkout(conf.svn_addr + login + "/info1",
199
200
                         common.studpath.url_to_local(login + "/info1")[1])
200
201
        except Exception, exc:
201
 
            # print >> sys.stderr, "While mkdiring info1: %s" % str(exc)
 
202
            log("While mkdiring info1: %s" % str(exc))
202
203
            pass
203
204
 
204
205
        # FIXME: should this be nicer?
207
208
                   common.studpath.url_to_local(login)[1]))
208
209
 
209
210
 
210
 
        # print >> sys.stderr, "Enabling user"
 
211
        log("Enabling user")
211
212
        db.update_user(login, state='enabled')
212
213
 
213
214
        return {"response": "okay"}
223
224
        'activate_user':activate_user
224
225
    }
225
226
 
 
227
def log(msg):
 
228
    """Writes a message to stderr, but only if DEBUG_PRINT is True.
 
229
    """
 
230
    global DEBUG_PRINT
 
231
    if DEBUG_PRINT:
 
232
        print >>sys.stderr, msg
 
233
 
226
234
def dispatch(props):
227
235
    print >> sys.stderr, repr(props)
228
236
    action = props.keys()[0]