325
325
% (username, unixid, unixid, username))
326
326
passwd_file.close()
328
def linktree(src, dst):
329
"""Recursively hard-link a directory tree using os.link().
331
The destination directory must not already exist.
332
If exception(s) occur, an Error is raised with a list of reasons.
334
Symlinks are preserved (in fact, hard links are created which point to the
337
Code heavily based upon shutil.copytree from Python 2.5 library.
339
names = os.listdir(src)
343
srcname = os.path.join(src, name)
344
dstname = os.path.join(dst, name)
346
if os.path.isdir(srcname):
347
linktree(srcname, dstname)
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])
358
shutil.copystat(src, dst)
360
# can't copy file access times on Windows
363
errors.extend((src, dst, str(why)))
365
raise Exception, errors
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.