Created
July 9, 2016 06:35
-
-
Save xvwang/f9e57b324085d7a3293a193e67b11643 to your computer and use it in GitHub Desktop.
Control air-condition by e-mail and IR-emmiter from PC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import poplib | |
import getpass | |
import sys | |
import subprocess | |
import time | |
while 1: | |
mServer = poplib.POP3('mailserver(example: seed.net.tw)') | |
mServer.user('username') | |
mServer.pass_('password') | |
numMessages = len(mServer.list()[1]) | |
#List the subject line of each message | |
for mList in range(numMessages) : | |
for msg in mServer.retr(mList+1)[1]: | |
if msg.startswith('Subject') and sys.argv[1] in msg: | |
subprocess.call("mpv --audio-device='pulse/alsa_output.pci-0000_00_1b.0.analog-stereo' "+msg.split(' ')[2]+".wav", shell=True) | |
mServer.dele(mList+1) | |
print msg.split(' ')[2]+" sent" | |
mServer.quit() | |
print 'sleeping....' | |
time.sleep(600) | |
print 'wake' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment