made some coffee

This commit is contained in:
EL 2015-11-23 13:14:09 +03:00
parent 8260c7dca5
commit f7b7f6e7ad

42
fucking_coffee.py Normal file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env python
import datetime
import sys
import subprocess
import telnetlib
import time
today = datetime.date.today()
# skip weekends
if today.strftime('%A') == 'Saturday' || today('%A') == 'Sunday':
sys.exit()
# exit if no sessions with my username are found
output = subprocess.check_output('who')
if 'my_username' not in output:
sys.exit()
coffee_machine_ip = '10.10.42.42'
password = '1234'
password_prompt = 'Password: '
con = telnetlib.Telnet(coffee_machine_ip)
con.read_until(password_prompt)
con.write(password + "\n")
# Make some coffee!
con.write("sys brew\n")
time.sleep(64)
# love the smell!
con.write("sys pour\n")
con.close()