7
7
import email .header
8
8
import datetime
9
9
import random
10
- from random import randint
11
10
import time
12
11
13
12
EMAIL_ACCOUNT = "[email protected] "
31
30
black ,black ,black ,black ,black ,black ,
32
31
black ,black ,black ,black ,black ,black ]
33
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
+
34
44
if __name__ == "__main__" :
35
- password = "PASSWORD GOES HERE"
36
- out = FadeAnimation ()
45
+ password = "PASSWORD GOES HERE"
37
46
out .start ()
38
47
out .write (pixels )
39
48
while True :
40
49
M = imaplib .IMAP4_SSL ('imap.gmail.com' )
41
-
42
50
try :
43
51
rv , data = M .login (EMAIL_ACCOUNT , password )
44
52
except imaplib .IMAP4 .error :
45
53
sys .exit (1 )
46
-
47
- print rv , data
48
-
49
54
rv , mailboxes = M .list ()
50
55
rv , data = M .select (EMAIL_FOLDER )
51
-
52
56
if rv == 'OK' :
53
-
54
57
rv , data = M .search (None , "ALL" )
55
58
if rv != 'OK' :
56
59
M .close ()
57
60
sys .exit (1 )
58
-
61
+ numcolors = 0
59
62
for num in data [0 ].split ():
63
+ numcolors = numcolors + 1
60
64
rv , data = M .fetch (num , '(RFC822)' )
61
65
if rv != 'OK' :
62
66
M .close ()
63
67
sys .exit (1 )
64
-
65
68
msg = email .message_from_string (data [0 ][1 ])
66
69
decode = email .header .decode_header (msg ['Subject' ])[0 ]
67
70
subject = unicode (decode [0 ])
68
71
if subject == "red" :
69
- time .sleep (1.0 )
70
- pixels [0 ] = red
71
- out .write (pixels )
72
- time .sleep (1.0 )
73
- random .shuffle (pixels )
74
- pixels [0 ] = black
75
- out .write (pixels )
76
- if subject == "blue" :
77
- time .sleep (1.0 )
78
- pixels [0 ] = blue
79
- out .write (pixels )
80
- time .sleep (1.0 )
81
- random .shuffle (pixels )
82
- pixels [0 ] = black
83
- out .write (pixels )
84
- if subject == "green" :
85
- time .sleep (1.0 )
86
- pixels [0 ] = green
87
- out .write (pixels )
88
- time .sleep (1.0 )
89
- random .shuffle (pixels )
90
- pixels [0 ] = black
91
- out .write (pixels )
92
- if subject == "black" :
93
- time .sleep (1.0 )
94
- pixels [0 ] = black
95
- out .write (pixels )
96
- time .sleep (1.0 )
97
- random .shuffle (pixels )
98
- pixels [0 ] = black
99
- out .write (pixels )
100
- if subject == "orange" :
101
- time .sleep (1.0 )
102
- pixels [0 ] = orange
103
- out .write (pixels )
104
- time .sleep (1.0 )
105
- random .shuffle (pixels )
106
- pixels [0 ] = black
107
- out .write (pixels )
108
- if subject == "yellow" :
109
- time .sleep (1.0 )
110
- pixels [0 ] = yellow
111
- out .write (pixels )
112
- time .sleep (1.0 )
113
- random .shuffle (pixels )
114
- pixels [0 ] = black
115
- out .write (pixels )
116
- if subject == "purple" :
117
- time .sleep (1.0 )
118
- pixels [0 ] = purple
119
- out .write (pixels )
120
- time .sleep (1.0 )
121
- random .shuffle (pixels )
122
- pixels [0 ] = black
123
- out .write (pixels )
124
- if subject == "teal" :
125
- time .sleep (1.0 )
126
- pixels [0 ] = teal
127
- out .write (pixels )
128
- time .sleep (1.0 )
129
- random .shuffle (pixels )
130
- pixels [0 ] = black
131
- out .write (pixels )
132
-
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 )
133
87
M .store (num , '+FLAGS' , '\\ Deleted' )
88
+ if numcolors == 0 :
89
+ time .sleep (1.0 )
90
+ random .shuffle (pixels )
91
+ out .write (pixels )
134
92
M .expunge ()
135
93
M .close ()
136
- time .sleep (1.0 )
137
- random .shuffle (pixels )
138
- out .write (pixels )
139
- M .logout ()
94
+ M .logout ()
0 commit comments