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

« back to all changes in this revision

Viewing changes to lib/common/makeuser.py

  • Committer: chadnickbok
  • Date: 2009-01-13 05:33:58 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1108
Updated the settings page to require the old password
when updating the password. Note that this field
is not shown when using ldap authentication

Show diffs side-by-side

added added

removed removed

Lines of Context:
325
325
                      % (username, unixid, unixid, username))
326
326
    passwd_file.close()
327
327
 
328
 
def linktree(src, dst):
329
 
    """Recursively hard-link a directory tree using os.link().
330
 
 
331
 
    The destination directory must not already exist.
332
 
    If exception(s) occur, an Error is raised with a list of reasons.
333
 
 
334
 
    Symlinks are preserved (in fact, hard links are created which point to the
335
 
    symlinks).
336
 
 
337
 
    Code heavily based upon shutil.copytree from Python 2.5 library.
338
 
    """
339
 
    names = os.listdir(src)
340
 
    os.makedirs(dst)
341
 
    errors = []
342
 
    for name in names:
343
 
        srcname = os.path.join(src, name)
344
 
        dstname = os.path.join(dst, name)
345
 
        try:
346
 
            if os.path.isdir(srcname):
347
 
                linktree(srcname, dstname)
348
 
            else:
349
 
                os.link(srcname, dstname)
350
 
            # XXX What about devices, sockets etc.?
351
 
        except (IOError, os.error), why:
352
 
            errors.append((srcname, dstname, str(why)))
353
 
        # catch the Error from the recursive copytree so that we can
354
 
        # continue with other files
355
 
        except Exception, err:
356
 
            errors.append(err.args[0])
357
 
    try:
358
 
        shutil.copystat(src, dst)
359
 
    except WindowsError:
360
 
        # can't copy file access times on Windows
361
 
        pass
362
 
    except OSError, why:
363
 
        errors.extend((src, dst, str(why)))
364
 
    if errors:
365
 
        raise Exception, errors
366
 
 
367
328
def make_user_db(throw_on_error = True, **kwargs):
368
329
    """Creates a user's entry in the database, filling in all the fields.
369
330
    All arguments must be keyword args. They are the fields in the table.