def findReposForAllUsers(): userDBModule = db.userDB().getUserDBModule() if not userDBModule.modificationsSupported(): return users = userDBModule.getUserList() for user in users: findReposForUser(user, userDBModule)
def findReposForAllUsers(verbose): userDBModule = db.userDB().getUserDBModule() users = userDBModule.getUserList() for user in users: if verbose: print 'Finding repositories for %s...' % user findReposForUser(user, userDBModule)
def findReposForAllUsers(): userDBModule = db.userDB().get_userdb_module() if not userDBModule.is_modifiable(): return users = userDBModule.list() for user in users: findReposForUser(user, userDBModule)
def handle_setup(): """This filter tool redirect users to /setup/ if no users.""" # Get the user database. try: userdb = db.userDB().get_userdb_module() except: logger.warn("user database is not configured") userdb = False if not userdb or len(userdb.list()) == 0: logger.info("redirect user to setup page") raise cherrypy.HTTPRedirect("/setup/")
def emailNotifications(): emailHost = getEmailHost() emailSender = getEmailSender() emailUsername = getEmailUsername() emailPassword = getEmailPassword() dbBackend = db.userDB().getUserDBModule() for user in dbBackend.getUserList(): userRepos = dbBackend.getUserRepoPaths(user) oldRepos = [] for repo in userRepos: maxDaysOld = dbBackend.getRepoMaxAge(user, repo) if maxDaysOld != 0: # get the last backup date try: lastBackup = librdiff.getLastBackupHistoryEntry(rdw_helpers.joinPaths(dbBackend.getUserRoot(user), repo), False) except librdiff.FileError: pass # Skip repos that have never been successfully backed up else: if lastBackup: oldestGoodBackupTime = rdw_helpers.rdwTime() oldestGoodBackupTime.initFromMidnightUTC(-maxDaysOld) if lastBackup.date < oldestGoodBackupTime: oldRepos.append({"repo" : repo, "lastBackupDate" : lastBackup.date.getDisplayString(), "maxAge" : maxDaysOld }) if oldRepos: userEmailAddress = dbBackend.getUserEmail(user) emailText = rdw_helpers.compileTemplate("email_notification.txt", repos=oldRepos, sender=emailSender, user=user) session = smtplib.SMTP(emailHost) session.login(emailUsername, emailPassword) smtpresult = session.sendmail(emailSender, userEmailAddress.split(";"), emailText) if smtpresult: error = "" for recipient in smtpresult.keys(): error = """Could not delivery mail to: %s Server said: %s %s %s""" % (recipient, smtpresult[recipient][0], smtpresult[recipient][1], error) raise smtplib.SMTPException, error session.quit()
def getUserDB(self): if not hasattr(cherrypy.thread_data, 'db'): cherrypy.thread_data.db = db.userDB().getUserDBModule() return cherrypy.thread_data.db
def __init__(self): self.userDB = db.userDB().getUserDBModule()
def getUserDB(self): """Return the user database.""" return db.userDB().get_userdb_module()
def emailNotificationIsEnabled(): return getEmailHost() != "" and getEmailSender() != "" and db.userDB().getUserDBModule().modificationsSupported()
def __init__(self): self.userDB = db.userDB().get_userdb_module()