コード例 #1
0
# Make a thread in the subreddit to get input on water/don't water 
import os
import praw
import sys

import config as c
import post_templates as posts
import gpio_out as g

REDDIT_USERNAME = '******'
REDDIT_PASSWORD = '******'

# Set-up
r = c.getReddit()
sr = c.getSubReddit(r)

post_body = posts.body
post_title = posts.title

if c.checkKillSwitch() == 1:
    sys.exit()

# Post Thread
s = sr.submit(post_title, text=post_body)
s.sticky()

# Logging
path_prefix = c.pathPrefix()

with open(path_prefix+'daily_thread.txt', 'w') as f:
    f.write(s.id)
コード例 #2
0
        return -1
    for element in listInput:
        if element[0] == key:
            return listInput.index(element)
    return -1


def sortKey(elem):
    return elem[0]


def sortKey2(elem):
    return elem[1]


reddit = getReddit()

input = 'ervfni'

if len(input) > 8:
    submission = reddit.submission(url=input)
else:
    submission = reddit.submission(id=input)

print(50 * '-')

print('Title: {}, score: {}, upvote ratio: {}, number of comments: {}'.format(
    submission.title, submission.score, submission.upvote_ratio,
    submission.num_comments))

print('time of draw: ' + datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
コード例 #3
0
# It will load comments sequentially and breaks when at where it left off
# Does not handle 1/vote per person due to 'voter' list not updating with 
#   each iteration of the loop through s.comments

import pickle
import json
import re
import time
import sys
import praw

import post_templates as posts
import config as c

# Setup
r = c.getReddit()
sr = c.getSubReddit(r, False)

path = c.pathPrefix()


## Get necessary files

# Comment log, in case one exists (vestigial file)

try:
    with open(path+'continuous_tally/cont_comment_log.txt', 'r+') as f:
        try:
            processed = pickle.load(f) 
        except EOFError:
            processed = []