Skip to content

Instantly share code, notes, and snippets.

@xvwang
Created July 9, 2016 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xvwang/f9e57b324085d7a3293a193e67b11643 to your computer and use it in GitHub Desktop.
Save xvwang/f9e57b324085d7a3293a193e67b11643 to your computer and use it in GitHub Desktop.
Control air-condition by e-mail and IR-emmiter from PC
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