From 77ef69bcfab9037e8e32a127dc1cc1f41a593b68 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 15:44:59 +0300 Subject: [PATCH 1/3] send messages to wife --- wife.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 wife.py diff --git a/wife.py b/wife.py new file mode 100644 index 0000000..79a8de9 --- /dev/null +++ b/wife.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +import datetime +import os +import random +from twilio.rest import TwilioRestClient +import subprocess +import sys +from time import strftime + + +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() + +# returns 'None' if the key doesn't exist +TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID') +TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN') + +# Phone numbers +my_number = '+xxx' +her_number = '+xxx' + +reasons = [ + 'Working hard', + 'Gotta ship this feature', + 'Someone fucked the system again' +] + +client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) + +client.messages.create( + to=her_number, + from=my_number, + body="Gonna work from home. " + random.choice(reasons) +) + +try: + f = open('logs/file.txt', 'a') +except IOError as e: + # dir & file don't exist; create them + os.mkdir('logs') + f = open('logs/file.txt', 'a') +except Exception as e: + print e +else: + pass + +# log it +f.write("Message sent at " + strftime("%a, %d %b %Y %H:%M:%S") + "\n") +f.close() From 99d0026be1059ec332041c3f439ca3c8cdb3c05b Mon Sep 17 00:00:00 2001 From: Yann Guineau Date: Mon, 23 Nov 2015 15:48:06 +0100 Subject: [PATCH 2/3] Fix text for wife alert Your wife is not your boss, she don't care if you work at home today, but she worries of the hour at which you come tonight. --- wife.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wife.py b/wife.py index 79a8de9..398c881 100644 --- a/wife.py +++ b/wife.py @@ -39,7 +39,7 @@ client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) client.messages.create( to=her_number, from=my_number, - body="Gonna work from home. " + random.choice(reasons) + body="Late at work. " + random.choice(reasons) ) try: From 55760abca8b34b05a5a2a17386858e3e4fa5e6d0 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 20:16:05 +0300 Subject: [PATCH 3/3] housekeeping --- wife.py => python/wife.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename wife.py => python/wife.py (100%) mode change 100644 => 100755 diff --git a/wife.py b/python/wife.py old mode 100644 new mode 100755 similarity index 100% rename from wife.py rename to python/wife.py