summaryrefslogtreecommitdiffstats
path: root/doc/AnalyticsWebReport.py
blob: 182d8367e61ee135affff8d101c4e3a6bfec75ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import sys
import AnalyticsConnect as ac
import TRexDataAnalysis as tr
import time


def main(verbose = False):
    if verbose:
        print('Retrieving data from Google Analytics')
    analytics = ac.initialize_analyticsreporting()
    current_date = time.strftime("%Y-%m-%d")
    response = ac.get_report(analytics, '2016-11-06', current_date)
    ga_all_data_dict, setups = ac.export_to_tuples(response)
    dest_path = os.path.join(os.getcwd(), 'build', 'images')
    if verbose:
        print('Saving data to %s' % dest_path)
    tr.create_all_data(ga_all_data_dict, setups, '2016-11-06', current_date, save_path = dest_path,
                       add_stats='yes')
    if verbose:
        print('Done without errors.')

if __name__ == "__main__":
    main()