AnalyticsWebReport.py revision d83a3f21
1import os
2import sys
3import AnalyticsConnect as ac
4import TRexDataAnalysis as tr
5import time
6import datetime
7
8
9def main(verbose=False, detailed_test_stats=''):
10    if verbose:
11        print('Retrieving data from Google Analytics')
12    analytics = ac.initialize_analyticsreporting()
13    current_date = time.strftime("%Y-%m-%d")
14    k_days_ago = datetime.datetime.now() - datetime.timedelta(days=15)
15    start_date = str(k_days_ago.date())
16    response = ac.get_report(analytics, start_date, current_date)
17    ga_all_data_dict, setups = ac.export_to_tuples(response)
18    dest_path = os.path.join(os.getcwd(), 'build', 'images')
19    if verbose:
20        print('Saving data to %s' % dest_path)
21        if detailed_test_stats:
22            print('generating detailed table for test results')
23    tr.create_all_data(ga_all_data_dict, setups, start_date, current_date, save_path=dest_path,
24                       add_stats='yes', detailed_test_stats=detailed_test_stats)
25    if verbose:
26        print('Done without errors.')
27
28
29if __name__ == "__main__":
30    main()
31