def recent_submission(self, n): submission_keys = list(self.submissions.keys()) # print(submission_keys[0]) submission = self.submissions[submission_keys[-n]] problem = Problem.Problem(submission["problem"]) time = submission["time"] memory = submission["memory"] points_earned = submission["points"] verdict = submission["result"] return Submission.Submission(problem, verdict, time, points_earned, memory)
def get_contest_submissions(submission_db, problems_db, contests_db, contestID): submissions = submission_db.find({'Contest Id': contestID}).limit(50) # limit(50).sort([('Submission Time', -1)]) submission_list = [] for i in submissions: submission_list.append(Submission(i, problems_db)) submission_list.sort(key=lambda d: datetime.datetime.strptime( d.submissionTime, '%Y-%m-%d %H:%M'), reverse=True) # print(submission_list) cursor = contests_db.find({"_id": ObjectId(contestID)})[0] name = cursor.get('Contest Title') + " Submissions" return name, submission_list
import falcon import json import requests import time import html import DBFunctions import psycopg2 import math import redis from pprint import pprint from inspect import getmembers from collections import defaultdict import Submission import Comment import User import Parameters from Helpers import * from configparser import ConfigParser api = falcon.API() api.add_route('/reddit/search', Comment.search()) api.add_route('/reddit/comment/search', Comment.search()) api.add_route('/reddit/search/comment', Comment.search()) api.add_route('/reddit/search/submission', Submission.search()) api.add_route('/reddit/submission/search', Submission.search()) api.add_route('/reddit/analyze/user/{author}', User.Analyze()) api.add_route('/get/comment_ids/{submission_id}', Submission.getCommentIDs()) api.add_route('/reddit/submission/comment_ids/{submission_id}', Submission.getCommentIDs())
for hw_id, hw_details in hw_data.iteritems(): if 'disabled' in hw_details and hw_details.get("disabled"): continue print("Checking submissions for: %s (%s)" % (hw_details.get("name") or hw_id, hw_id)) for submission_data in get_submissions(hw_id): submission_details = {} submission_details["id"] = submission_data[0] submission_details["neptun"] = submission_data[1] if config['isDebug']: if not submission_details["neptun"].startswith("TEST"): continue personal = "" if (len(submission_data) > 2): submission_details["personal_index"] = submission_data[2] personal = "pid: %s" % submission_details["personal_index"] print("Testing submission: %s (%s) %s" % ( submission_details["neptun"], submission_details["id"], personal, )) #print("Testing submission: %s (%s) %s %s" % (submission_details["neptun"], submission_details["id"], personal, str(hw_details))) sub = Submission.Submission(submission_details, hw_id, hw_details, config) sub.evaluate() print "Sleeping", datetime.now() time.sleep(10)
import DataClient import Submission from pprint import pprint subreddits = ["gaming", "AskReddit", "ProgrammerHumor", "Showerthoughts", "technology", "pcmasterrace", "StarWars", "Jokes", "MachineLearning"] dictionary = {} filepath = "E:/RedditDaten/" client = DataClient.Client(username="******", password="******", user_agent="Data Streamer for Reddit Content ver 0.0a /u/KirbyDataBot", client_id="x396BlWKhK3VTg", client_secret="bwBi_xVKb8df_8MI3FxZLVEzNq8") client.loadReddit() for subreddit in subreddits: client.addSubReddits(subreddit) dictionary['submission'] = [] for submission in client.getSubmissions(value=5): new_submission = Submission.Submission(submission) dictionary['submission'].append(new_submission.getJson()) client.exportToJson(dictionary, filepath, subreddit+".json")
#Load .env enviroment variable file and then read the required parameters dotenv_path = join(dirname(__file__), '.env') load_dotenv(dotenv_path) env_secret_key = os.environ.get("SECRET_KEY") env_client_id = os.environ.get("CLIENT_ID") env_user_agent = os.environ.get("USER_AGENT") env_sender_email = os.environ.get("SENDER_EMAIL") env_sender_pw = os.environ.get("SENDER_PW") env_reciever_email = os.environ.get("RECIEVER_EMAIL") #setup PRAW API parameters reddit = praw.Reddit(client_id=env_client_id, client_secret=env_secret_key, user_agent=env_user_agent) #pull first 50 hot submissions from /r/mechmarket using a read_only instance #match all results from the UK results = [] for submission in reddit.subreddit('mechmarket').hot(limit=200): location_match = re.match(r'\[EU-UK\].*', str(submission.title)) if location_match and 'koi' in submission.title.lower(): submission_obj = Submission(submission.id, submission.title, submission.comments, submission.URL) results.append(submission_obj) #if any matching results are discovered send url in email if len(results) != 0: for result in results: Email.send_email(env_sender_email, env_sender_pw, env_reciever_email, 'RedditBot', 'Reddit thread meets requirement: ' + result.url)