Add 'as' and MD
This commit is contained in:
parent
eaac691245
commit
806841c828
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import telnetlib
|
||||
import time
|
||||
import telnetlib as tel
|
||||
import time as t
|
||||
|
||||
from hackerutils import sh
|
||||
|
||||
|
|
@ -16,15 +16,15 @@ def main():
|
|||
if not any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
|
||||
return
|
||||
|
||||
time.sleep(17)
|
||||
t.sleep(17)
|
||||
|
||||
conn = telnetlib.Telnet(host=COFFEE_MACHINE_ADDR)
|
||||
conn = tel.Telnet(host=COFFEE_MACHINE_ADDR)
|
||||
conn.open()
|
||||
conn.expect([COFFEE_MACHINE_PROM])
|
||||
conn.write(COFFEE_MACHINE_PASS)
|
||||
|
||||
conn.write('sys brew')
|
||||
time.sleep(24)
|
||||
t.sleep(24)
|
||||
|
||||
conn.write('sys pour')
|
||||
conn.close()
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pathlib
|
||||
import subprocess
|
||||
import pathlib as pth
|
||||
import subprocess as sbp
|
||||
|
||||
from dotenv import Dotenv
|
||||
|
||||
|
||||
def get_dotenv(filename='.env'):
|
||||
return Dotenv(str(pathlib.Path(__file__).parent / filename))
|
||||
return Dotenv(str(pth.Path(__file__).parent / filename))
|
||||
|
||||
|
||||
def sh(*args):
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
proc = sbp.Popen(args, stdout=sbp.PIPE)
|
||||
stdout, _ = proc.communicate()
|
||||
return stdout
|
||||
|
||||
|
||||
def get_log_path(name):
|
||||
path = pathlib.Path(__file__).parent / 'logs' / name
|
||||
path = pth.Path(__file__).parent / 'logs' / name
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
return path
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
import random
|
||||
|
||||
from twilio import TwilioRestException
|
||||
from twilio.rest import TwilioRestClient
|
||||
from twilio import TwilioRestException as tre
|
||||
from twilio.rest import TwilioRestClient as trc
|
||||
|
||||
from hackerutils import get_dotenv, get_log_path, sh
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ def main():
|
|||
if any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
|
||||
return
|
||||
|
||||
client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
|
||||
client = trc(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
|
||||
|
||||
# Phone numbers.
|
||||
my_number = '+xxx'
|
||||
|
|
@ -41,7 +41,7 @@ def main():
|
|||
from_=my_number,
|
||||
body='Gonna work from home. ' + random.choice(excuses),
|
||||
)
|
||||
except TwilioRestException as e:
|
||||
except tre as e:
|
||||
# Log errors.
|
||||
with LOG_FILE_PATH.open('a') as f:
|
||||
f.write('Failed to send SMS: {}'.format(e))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
#Requirements
|
||||
=
|
||||
- dotenv
|
||||
- twilio
|
||||
- yagmail
|
||||
- git
|
||||
|
||||
[Repo](https://github.com/charlierguo/gmail)
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
import random
|
||||
|
||||
from twilio import TwilioRestException
|
||||
from twilio.rest import TwilioRestClient
|
||||
from twilio import TwilioRestException as tre
|
||||
from twilio.rest import TwilioRestClient as trc
|
||||
|
||||
from hackerutils import get_dotenv, get_log_path, sh
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ def main():
|
|||
if not any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
|
||||
return
|
||||
|
||||
client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
|
||||
client = trc(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
|
||||
|
||||
# Phone numbers.
|
||||
my_number = '+xxx'
|
||||
|
|
@ -40,7 +40,7 @@ def main():
|
|||
from_=my_number,
|
||||
body='Late at work. ' + random.choice(reasons),
|
||||
)
|
||||
except TwilioRestException as e:
|
||||
except tre as e:
|
||||
# Log errors.
|
||||
with LOG_FILE_PATH.open('a') as f:
|
||||
f.write('Failed to send SMS: {}'.format(e))
|
||||
|
|
|
|||
Loading…
Reference in New Issue