def pull_screenshots(key_prefix): s3 = boto3.client("s3") response = s3.list_objects(Bucket=BUCKET_NAME) keys = [ item["Key"] for item in response["Contents"] if item["Key"].startswith(key_prefix) ] results = [] for key in keys: url = s3.generate_presigned_url( "get_object", Params={ "Bucket": BUCKET_NAME, "Key": key }, ExpiresIn=100, ) last_modified = s3.get_object(Bucket=BUCKET_NAME, Key=key)["LastModified"] last_updated = pretty_date(last_modified) results.append( Screenshot(name=key, url=url, last_updated=last_updated, timestamp=last_modified)) return sorted(results, key=lambda x: x.timestamp)
next = page + 1 if page >= max: page = max next = 0 entry = FEED[page] # extract parameters # Wed May 08 12:34:39 +0000 2013 text = entry['text'].encode('ascii', 'xmlcharrefreplace') created_at = datetime.strptime(entry['created_at'], "%a %b %d %H:%M:%S +0000 %Y") time_since = pretty_date(created_at) user_image = entry['user']['profile_background_image_url'] # print output HTML, should be a template t = Template("""<html> <head> <title>$n</title><head> <link rel="stylesheet" type="text/css" href="./css/main.css"> <link href='http://fonts.googleapis.com/css?family=Roboto+Slab:400,700' rel='stylesheet' type='text/css'> <meta http-equiv="refresh" content="30;URL='./index.py?page=$nx'"/> <body> <div id="centered"> <img src="$u" align="left" hspace=30> <h1>$t</h1>
def get_topic(channel, user, time): #topic scores are saved as <USER>&^%<GETS SCORE>&^%<SETS SCORE> with open("topicscores.txt", "r") as scorefile: scores = scorefile.readlines() userscore = 1 found = False with open("topicscores.txt", "w") as scorefile: for idx,score in enumerate(scores): data = score.strip("\n").split("&^%") if(data[0] == user): found = True userscore = int(data[1])+1 scores[idx] = data[0] + "&^%" + str(userscore) + "&^%" + data[2] + "\n" scorefile.writelines(scores) if(not found): scorefile.write(user + "&^%1&^%0\n") with open("topics_" + channel + ".txt", "r") as topics: topic = topics.readlines()[-1].strip("\n").split("&^%", 3) ircsock.send("PRIVMSG "+ channel +" :I've told you " + p.number_to_words(userscore) + " times! It's \"" + topic[2] + "\" (Set by " + topic[1] + " " + pretty_date.pretty_date(int(topic[0])) + ")\n")
next = page + 1 if page >= max: page = max next = 0 entry = FEED[page] # extract parameters # Wed May 08 12:34:39 +0000 2013 text = entry['text'].encode('ascii','xmlcharrefreplace') created_at = datetime.strptime(entry['created_at'],"%a %b %d %H:%M:%S +0000 %Y") time_since = pretty_date(created_at) user_image = entry['user']['profile_background_image_url'] # print output HTML, should be a template t=Template("""<html> <head> <title>$n</title><head> <link rel="stylesheet" type="text/css" href="./css/main.css"> <link href='http://fonts.googleapis.com/css?family=Roboto+Slab:400,700' rel='stylesheet' type='text/css'> <meta http-equiv="refresh" content="30;URL='./index.py?page=$nx'"/> <body> <div id="centered"> <img src="$u" align="left" hspace=30> <h1>$t</h1>
def topic_history(channel, user, count): try: iCount = int(count.split()[1]) except (ValueError, IndexError) as e: iCount = 3 if(iCount > 10): iCount = 10 if(iCount < 1): iCount = 3 with open("topics_" + channel + ".txt", "r") as topicsfile: #topics = topicsfile.readlines()[-iCount:].reverse() ircsock.send("PRIVMSG "+ channel +" :Ok, here were the last " + p.number_to_words(iCount) + " topics\n") for idx,topic in enumerate(reversed(topicsfile.readlines()[-iCount:])): topic = topic.strip("\n").split("&^%", 3) ircsock.send("PRIVMSG "+ channel +" :" + str(idx+1) + ": \"" + topic[2] + "\" (Set by " + topic[1] + " " + pretty_date.pretty_date(int(topic[0])) + ")\n")