def run(r): print('Checking submissions...') config = get_config('core') if should_check_submissions(config): notify_violating_submissions(r, config, get_last_timestamp(config)) else: # if state file exists, delete it to trigger fresh copy on a non monday if os.path.exists(config['state_filename']): os.remove(config['state_filename']) print('Submission purge complete!')
def run(r): print('Checking submissions...') config = get_config('core') if should_check_submissions(config): notify_violating_submissions( r, config, get_last_timestamp(config) ) else: # if state file exists, delete it to trigger fresh copy on a non monday if os.path.exists(config['state_filename']): os.remove(config['state_filename']) print('Submission purge complete!')
def run(r): print('Starting update of sidebar...') config = get_config('core') mod = r.subreddit(config['subreddit']).mod mod_settings = mod.settings() time_left = compute_how_much_time_left(datetime.datetime.utcnow(), int(config['monday'])) announcement_index = get_mlm_announcement_index_in_description( mod_settings) update_announcement_text(config, mod, mod_settings, announcement_index, time_left) print('Update of sidebar successful!')
def get_es_instance(): conf = get_config() ssl_context = create_ssl_context() ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE user = conf['es']['user'] password = conf['es']['password'] if user and password: auth = (user, password) else: auth = None return Elastic(hosts=[conf['es']['host']], http_auth=auth, scheme=conf['es']['scheme'], port=conf['es']['port'], ssl_context=ssl_context)
def run(r): print('Starting best of processing...') config = get_config('best_of') generate_best_of_lists(r, config) time.sleep(1) post_nominations_to_voting_thread(r, config)
import schedule from utils.config_reader import get_config from modules.mlm_sidebar_update import run as mlm_sidebar_update from modules.mlm_submission_check import ( run as mlm_submission_check ) from modules.best_of import run as best_of_itap from modules.slack_bot import send_error_log # system wide flags timekeeping = -1 debug = True if '--debug' in sys.argv[1:] else False # Retrieve config config = get_config('core') config['monday'] = int(config['monday']) slack_config = get_config('slack_bot') # generate instance of praw print('Logging in...') user_agent = "r/itookapicture MLM announcer v4.2.0 by /u/tehusername" while True: try: r = praw.Reddit( client_id=os.environ['ITAP_ID'], client_secret=os.environ['ITAP_SECRET'], username=os.environ['ITAP_USERNAME'], password=os.environ['ITAP_PASSWORD'],
import traceback import sys import praw import schedule from utils.config_reader import get_config from modules.mlm_sidebar_update import run as mlm_sidebar_update from modules.mlm_submission_check import (run as mlm_submission_check) from modules.best_of import run as best_of_itap from modules.slack_bot import send_error_log # system wide flags timekeeping = -1 debug = True if '--debug' in sys.argv[1:] else False # Retrieve config config = get_config('core') config['monday'] = int(config['monday']) slack_config = get_config('slack_bot') # generate instance of praw print('Logging in...') user_agent = "r/itookapicture MLM announcer v4.2.0 by /u/tehusername" while True: try: r = praw.Reddit(client_id=os.environ['ITAP_ID'], client_secret=os.environ['ITAP_SECRET'], username=os.environ['ITAP_USERNAME'], password=os.environ['ITAP_PASSWORD'], user_agent=user_agent)
def get_path_raw_file(relative_path): return os.path.join(get_config(['data', 'raw']), relative_path)
def get_path_processed_file(relative_path): return os.path.join(get_config(['data', 'processed']), relative_path)
def get_path_intermediate_file(relative_path): return os.path.join(get_config(['data', 'intermediate']), relative_path)