def get_user(conf): sess = conf.session pwent = passwd.getpwuid(os.getuid()) try: # user = models.User.objects.get(username=pwent.name) user = sess.query(models.User).filter(models.User.username==pwent.name).one() except NoResultFound: user = models.create_user(sess, pwent) return user
def get_pwent(self, name=None, uid=None): if uid is not None: return passwd.getpwuid(int(uid)) return passwd.getpwnam(name)