<commit_before>from constants import *
import sys, time, datetime
from scraper import Scraper
from dateutil import tz
from execute_query import execute_query

try:
    region = str(sys.argv[1])
    if region not in ['EU','US','TW','KR']: raise Exception
    print '[INFO] [{0}] - Going to reset the snapshot of region {1}'.format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'),region)
except Exception:
    print 'Please specify a valid region.'
    sys.exit()

try:
    team_ids = str(sys.argv[2]).split(',')
    print '[INFO] [{0}] - Not using all team IDs, but only the following: {1}'.format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'),', '.join(team_ids))
except Exception:
    team_ids = False

if team_ids:
    execute_query('UPDATE characters SET weekly_snapshot = \'\' WHERE team_id IN ({0})'.format(','.join(team_ids)))
    print '[INFO] [{0}] - Snapshot resetted successfully for teams {1}'.format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'),','.join(team_ids)   )

else:
    if region == 'US' and datetime.datetime.weekday(datetime.datetime.now()) != 1:
        print "[INFO] [{0}] - It is not Tuesday, snapshots should not be reset for US. Aborting now.".format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'))
        sys.exit()
    elif region == 'EU' and datetime.datetime.weekday(datetime.datetime.now()) != 2:
        print "[INFO] [{0}] - It is not Wednesday, snapshots should not be reset for EU. Aborting now.".format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'))
        sys.exit()
    elif region == 'KR' and datetime.datetime.weekday(datetime.datetime.now()) != 3:
        print "[INFO] [{0}] - It is not Thursday, snapshots should not be reset for KR. Aborting now.".format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'))
        sys.exit()
    elif region == 'TW' and datetime.datetime.weekday(datetime.datetime.now()) != 3:
        print "[INFO] [{0}] - It is not Thursday, snapshots should not be reset for TW. Aborting now.".format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'))
        sys.exit()
    else:
        execute_query('UPDATE characters SET weekly_snapshot = \'\' WHERE team_id IN (SELECT team_id from teams WHERE guild_id IN (SELECT id FROM guilds WHERE region = \'{0}\'))'.format(region))
        print '[INFO] [{0}] - Snapshot resetted successfully of region {1}'.format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'),region)<commit_msg>Another fix for snapshot reset<commit_after>from constants import *
import sys, time, datetime
from scraper import Scraper
from dateutil import tz
from execute_query import execute_query

try:
    region = str(sys.argv[1])
    if region not in ['EU','US','TW','KR']: raise Exception
    print '[INFO] [{0}] - Going to reset the snapshot of region {1}'.format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'),region)
except Exception:
    print 'Please specify a valid region.'
    sys.exit()

try:
    team_ids = str(sys.argv[2]).split(',')
    print '[INFO] [{0}] - Not using all team IDs, but only the following: {1}'.format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'),', '.join(team_ids))
except Exception:
    team_ids = False

if team_ids:
    execute_query('UPDATE characters SET weekly_snapshot = \'\' WHERE team_id IN ({0})'.format(','.join(team_ids)))
    print '[INFO] [{0}] - Snapshot resetted successfully for teams {1}'.format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'),','.join(team_ids)   )

else:
    if region == 'US' and datetime.datetime.weekday(datetime.datetime.now()) != 1:
        print "[INFO] [{0}] - It is not Tuesday, snapshots should not be reset for US. Aborting now.".format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'))
        sys.exit()
    elif region == 'EU' and datetime.datetime.weekday(datetime.datetime.now()) != 2:
        print "[INFO] [{0}] - It is not Wednesday, snapshots should not be reset for EU. Aborting now.".format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'))
        sys.exit()
    elif region == 'KR' and datetime.datetime.weekday(datetime.datetime.now()) != 3:
        print "[INFO] [{0}] - It is not Thursday, snapshots should not be reset for KR. Aborting now.".format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'))
        sys.exit()
    elif region == 'TW' and datetime.datetime.weekday(datetime.datetime.now()) != 3:
        print "[INFO] [{0}] - It is not Thursday, snapshots should not be reset for TW. Aborting now.".format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'))
        sys.exit()
    else:
        execute_query('UPDATE characters SET weekly_snapshot = \'\' WHERE team_id IN (SELECT id from teams WHERE guild_id IN (SELECT id FROM guilds WHERE region = \'{0}\'))'.format(region))
        print '[INFO] [{0}] - Snapshot resetted successfully of region {1}'.format(datetime.datetime.utcnow().replace(tzinfo=tz.gettz('UTC')).astimezone(tz.gettz(TIME_ZONE)).strftime('%d-%m %H:%M:%S'),region)
{'fraction_non_alphanumeric': 0.18866014174822815, 'fraction_numerical': 0.006749915626054675, 'mean_word_length': 4.715525554484088, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2530192', 'n_tokens_mistral': 2028, 'n_tokens_neox': 1979, 'n_words': 445}