Example #1
0
def run(path_to_config):
    
    set_up_logger()
    logging.info("==============================")
    logging.info("SVNGUT - by David Winterbottom")
    logging.info("==============================")
    
    # Read configuration
    parser = Parser(path_to_config)
    date_range = parser.get_date_range()

    logging.info("Analysis period between %s and %s", date_range[0], date_range[1])
    repositories = parser.get_repositories() 
    logging.info("Found %d repositories to analyse..." % len(repositories))
    
    # Fetch branch contributions for each repository
    all_branch_contributions = {}
    interrogator = RepositoryInterrogator(pysvn.Client())
    for repository_key, repository in repositories.items():
        all_branch_contributions[repository_key] = interrogator.get_all_branch_contributions(repository, date_range)
    
    # Generate and send summary HTML for each user
    path_to_template = os.path.join(os.path.dirname(__file__), 'templates/summary.html')
    digestor = Summariser(path_to_template, all_branch_contributions)
    notifier = Notifier(parser.get_email_server(), parser.get_email_sender_address())
    for email_address, repository_keys in parser.get_user_repositories().items():
        summary_html = digestor.get_summary_html_for(repository_keys)
        file = open('/tmp/svngut.html', 'w')
        file.write(summary_html)
        file.close()
        notifier.send_email(email_address, get_email_subject(date_range), summary_html)
 def testGetBranchUrls(self):
     """URLs for repository branches are returned correctly"""
     client = Mock()
     client.ls = Mock()
     client.ls.side_effect = returnDummyUrls
     
     interrogator = RepositoryInterrogator(client)
     urls = interrogator.get_branch_urls(self.getDummyRepository())
     expected_urls = ['http://svn.example.com/project/trunk/', 
                      'http://svn.example.com/project/branches/dev/']
     urls.sort()
     expected_urls.sort()
     self.assertEquals(expected_urls, urls)
 def testGetUrlList(self):
     """URL list for repository is returned correctly"""
     client = Mock()
     client.ls = Mock()
     client.ls.side_effect = returnDummySvnDirs
     
     interrogator = RepositoryInterrogator(client)
     urls = interrogator.get_url_list(svn_base_url)
     expected_urls = ['http://svn.example.com/project/trunk/', 
                      'http://svn.example.com/project/branches/',
                      'http://svn.example.com/project/tags/']
     urls.sort()
     expected_urls.sort()
     self.assertEqual(expected_urls, urls)