def findReposForAllUsers():
    userDBModule = db.userDB().getUserDBModule()
    if not userDBModule.modificationsSupported(): return

    users = userDBModule.getUserList()
    for user in users:
        findReposForUser(user, userDBModule)
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)
Ejemplo n.º 4
0
def findReposForAllUsers():
    userDBModule = db.userDB().get_userdb_module()
    if not userDBModule.is_modifiable():
        return

    users = userDBModule.list()
    for user in users:
        findReposForUser(user, userDBModule)
Ejemplo n.º 5
0
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()
Ejemplo n.º 7
0
 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()
Ejemplo n.º 9
0
 def getUserDB(self):
    if not hasattr(cherrypy.thread_data, 'db'):
       cherrypy.thread_data.db = db.userDB().getUserDBModule()
    return cherrypy.thread_data.db
Ejemplo n.º 10
0
 def __init__(self):
     self.userDB = db.userDB().getUserDBModule()
Ejemplo n.º 11
0
 def getUserDB(self):
     """Return the user database."""
     return db.userDB().get_userdb_module()
def emailNotificationIsEnabled():
   return getEmailHost() != "" and getEmailSender() != "" and db.userDB().getUserDBModule().modificationsSupported()
Ejemplo n.º 13
0
 def __init__(self):
     self.userDB = db.userDB().get_userdb_module()