Skip to content

Commit c0055ec

Browse files
author
Cole Gleason
committed
2 parents fe7ff4b + c607efd commit c0055ec

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

animations/crowdsource/main.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import sys
2+
from oscapi import ColorsOut
3+
from animations import FadeAnimation
4+
import imaplib
5+
import getpass
6+
import email
7+
import email.header
8+
import datetime
9+
import random
10+
import time
11+
12+
EMAIL_ACCOUNT = "[email protected]"
13+
EMAIL_FOLDER = "INBOX"
14+
15+
black = (0.0,0.0,0.0)
16+
green = (0.0, 1023.0, 0.0)
17+
red = (1023.0, 0.0, 0.0)
18+
blue = (0.0, 0.0, 1023.0)
19+
orange = (1023.0, 511.5,0.0)
20+
yellow = (1023.0, 1023.0, 0.0)
21+
purple = (1023.0, 0.0, 1023.0)
22+
teal = (511.5, 1023.0, 1023.0)
23+
24+
pixels = [black,black,black,black,black,black,
25+
black,black,black,black,black,black,
26+
black,black,black,black,black,black,
27+
black,black,black,black,black,black,
28+
black,black,black,black,black,black,
29+
black,black,black,black,black,black,
30+
black,black,black,black,black,black,
31+
black,black,black,black,black,black]
32+
33+
out = FadeAnimation()
34+
35+
def pushcolor(color):
36+
time.sleep(1.0)
37+
pixels[0] = color
38+
out.write(pixels)
39+
time.sleep(1.0)
40+
random.shuffle(pixels)
41+
pixels[0] = black
42+
out.write(pixels)
43+
44+
if __name__ == "__main__":
45+
password = "PASSWORD GOES HERE"
46+
out.start()
47+
out.write(pixels)
48+
while True:
49+
M = imaplib.IMAP4_SSL('imap.gmail.com')
50+
try:
51+
rv, data = M.login(EMAIL_ACCOUNT, password)
52+
except imaplib.IMAP4.error:
53+
sys.exit(1)
54+
rv, mailboxes = M.list()
55+
rv, data = M.select(EMAIL_FOLDER)
56+
if rv == 'OK':
57+
rv, data = M.search(None, "ALL")
58+
if rv != 'OK':
59+
M.close()
60+
sys.exit(1)
61+
numcolors = 0
62+
for num in data[0].split():
63+
numcolors = numcolors + 1
64+
rv, data = M.fetch(num, '(RFC822)')
65+
if rv != 'OK':
66+
M.close()
67+
sys.exit(1)
68+
msg = email.message_from_string(data[0][1])
69+
decode = email.header.decode_header(msg['Subject'])[0]
70+
subject = unicode(decode[0])
71+
if subject == "red":
72+
pushcolor(red)
73+
elif subject == "blue":
74+
pushcolor(blue)
75+
elif subject == "green":
76+
pushcolor(green)
77+
elif subject == "black":
78+
pushcolor(black)
79+
elif subject == "orange":
80+
pushcolor(orange)
81+
elif subject == "yellow":
82+
pushcolor(yellow)
83+
elif subject == "purple":
84+
pushcolor(purple)
85+
elif subject == "teal":
86+
pushcolor(teal)
87+
M.store(num, '+FLAGS', '\\Deleted')
88+
if numcolors == 0:
89+
time.sleep(1.0)
90+
random.shuffle(pixels)
91+
out.write(pixels)
92+
M.expunge()
93+
M.close()
94+
M.logout()

animations/crowdsource/manifest.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name":"Crowdsource",
3+
"description":"Email [email protected] with the subject 'red','orange','yellow','green','blue','purple','teal', or 'black' to add colors",
4+
"creator":"Milan Dasgupta"
5+
}

0 commit comments

Comments
 (0)