forked from srschaecher/PAXminer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Leaderboard_MidMonth_Execution.py
executable file
·61 lines (53 loc) · 2.01 KB
/
Leaderboard_MidMonth_Execution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
'''
This script was written by Beaker from F3STL. Questions? @srschaecher on twitter or srschaecher@gmail.com.
This script executes the monthly LeaderboardByAO chart maker for all F3 regions using PAXminer.
'''
from slacker import Slacker
import pandas as pd
import pymysql.cursors
import configparser
import os
# Set the working directory to the directory of the script
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)
# Configure AWS credentials
config = configparser.ConfigParser();
config.read('../config/credentials.ini');
# Configure AWS Credentials
host = config['aws']['host']
port = int(config['aws']['port'])
user = config['aws']['user']
password = config['aws']['password']
db = config['aws']['db']
#Define AWS Database connection criteria
mydb1 = pymysql.connect(
host=host,
port=port,
user=user,
password=password,
db=db,
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
# Get list of regions and Slack tokens for PAXminer execution
try:
with mydb1.cursor() as cursor:
sql = "SELECT * FROM paxminer.regions where firstf_channel IS NOT NULL AND send_mid_month_charts = 1"
cursor.execute(sql)
regions = cursor.fetchall()
regions_df = pd.DataFrame(regions)
finally:
print('Getting list of regions that use PAXminer...')
for index, row in regions_df.iterrows():
region = row['region']
key = row['slack_token']
db = row['schema_name']
firstf = row['firstf_channel']
#firstf = 'U0187M4NWG4' # <--- Use this if sending a test msg to a specific user
print('Processing statistics for region ' + region)
os.system("./Leaderboard_Charter.py " + db + " " + key + " " + region + " " + firstf)
os.system("./Qcharter.py " + db + " " + key + " " + region + " " + firstf)
os.system("./Qcharter_YTD.py " + db + " " + key + " " + region + " " + firstf)
print('----------------- End of Region Update -----------------\n')
print('\nLeaderboardByAO_Charter execution complete.')