Example #1
0
def get_popular():
    lines = [line.strip() for line in \
    file(config.image_view_log_file, 'r').readlines() if line.strip()]
    populars = calculate_popular(config.base_dir, lines)
    results = populars.keys()
    random.shuffle(results)
    return json.dumps(results)
Example #2
0
    def test_calculate_popular(self):
        source = r"""
[IMAGE_VIEW] image view 48/26.JPEG at 1353828876
[IMAGE_VIEW] image view 48/26.JPEG at 1353828876
[IMAGE_VIEW] image view 48/27.JPEG at 1353828876
[IMAGE_VIEW] image view 48/3.JPEG at 1353828876
[IMAGE_VIEW] image view e:\rosi\48\4.JPEG at 1353829195
[IMAGE_VIEW] image view e:\rosi\48\5.JPEG at 1353829195
[IMAGE_VIEW] image view e:\rosi\48\6.JPEG at 1353829196
        """
        lines = [m.strip() for m in source.split('\n') if m.strip()]
        base_dir = 'e:\\rosi'
        counter = cron.calculate_popular(base_dir, lines)
        assert type(counter) is dict
        assert counter['48/26.JPEG'] == 2
        assert counter['48/5.JPEG'] == 1
Example #3
0
    def test_calculate_popular(self):
        source = r"""
[IMAGE_VIEW] image view 48/26.JPEG at 1353828876
[IMAGE_VIEW] image view 48/26.JPEG at 1353828876
[IMAGE_VIEW] image view 48/27.JPEG at 1353828876
[IMAGE_VIEW] image view 48/3.JPEG at 1353828876
[IMAGE_VIEW] image view e:\rosi\48\4.JPEG at 1353829195
[IMAGE_VIEW] image view e:\rosi\48\5.JPEG at 1353829195
[IMAGE_VIEW] image view e:\rosi\48\6.JPEG at 1353829196
        """
        lines = [m.strip() for m in source.split('\n') if m.strip()]
        base_dir = 'e:\\rosi'
        counter = cron.calculate_popular(base_dir, lines)
        assert type(counter) is dict
        assert counter['48/26.JPEG'] == 2
        assert counter['48/5.JPEG'] == 1