File tree Expand file tree Collapse file tree 4 files changed +171
-0
lines changed Expand file tree Collapse file tree 4 files changed +171
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import datetime
4+ import sys
5+ import subprocess
6+ import telnetlib
7+ import time
8+
9+ today = datetime .date .today ()
10+
11+ # skip weekends
12+ if today .strftime ('%A' ) in ('Saturday' , 'Sunday' ):
13+ sys .exit ()
14+
15+ # exit if no sessions with my username are found
16+ output = subprocess .check_output ('who' )
17+ if 'my_username' not in output :
18+ sys .exit ()
19+
20+ coffee_machine_ip = '10.10.42.42'
21+ password = '1234'
22+ password_prompt = 'Password: '
23+
24+ con = telnetlib .Telnet (coffee_machine_ip )
25+ con .read_until (password_prompt )
26+ con .write (password + "\n " )
27+
28+ # Make some coffee!
29+ con .write ("sys brew\n " )
30+ time .sleep (64 )
31+
32+ # love the smell!
33+ con .write ("sys pour\n " )
34+ con .close ()
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import datetime
4+ import os
5+ import random
6+ from twilio .rest import TwilioRestClient
7+ from time import strftime
8+ import subprocess
9+
10+ today = datetime .date .today ()
11+
12+ # skip weekends
13+ if today .strftime ('%A' ) == 'Saturday' | | today ('%A' ) == 'Sunday' :
14+ sys .exit ()
15+
16+ # exit if no sessions with my username are found
17+ output = subprocess .check_output ('who' )
18+ if 'my_username' not in output :
19+ sys .exit ()
20+
21+ # returns 'None' if the key doesn't exist
22+ TWILIO_ACCOUNT_SID = os .environ .get ('TWILIO_ACCOUNT_SID' )
23+ TWILIO_AUTH_TOKEN = os .environ .get ('TWILIO_AUTH_TOKEN' )
24+
25+ # Phone numbers
26+ my_number = '+xxx'
27+ number_of_boss = '+xxx'
28+
29+ excuses = [
30+ 'Locked out' ,
31+ 'Pipes broke' ,
32+ 'Food poisoning' ,
33+ 'Not feeling well'
34+ ]
35+
36+ client = TwilioRestClient (TWILIO_ACCOUNT_SID , TWILIO_AUTH_TOKEN )
37+
38+ client .messages .create (
39+ to = number_of_boss ,
40+ from = my_number ,
41+ body = "Gonna work from home. " + random .choice (excuses )
42+ )
43+
44+ try :
45+ f = open ('logs/file.txt' , 'a' )
46+ except IOError as e :
47+ # dir & file don't exist; create them
48+ os .mkdir ('logs' )
49+ f = open ('logs/file.txt' , 'a' )
50+ except Exception as e :
51+ print e
52+ else :
53+ pass
54+
55+ # log it
56+ f .write ("Message sent at " + strftime ("%a, %d %b %Y %H:%M:%S" ) + "\n " )
57+ f .close ()
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import gmail
4+ import sys
5+ import re
6+
7+ GMAIL_USERNAME = ENV ['GMAIL_USERNAME' ]
8+ GMAIL_PASSWORD = ENV ['GMAIL_PASSWORD' ]
9+
10+ g = gmail .login (GMAIL_USERNAME , GMAIL_PASSWORD )
11+
12+ if not g .logged_in :
13+ sys .exit ()
14+
15+ msgs = g .
inbox ().
mail (
sender = "[email protected] " ,
unread = True )
16+
17+ pattern = re .compile ("\b sorry\b | \b help\b | \b wrong\b " , flags = re .I )
18+
19+ for msg in msgs :
20+ if pattern .match (msg .body ):
21+ msg .label ("Database fixes" )
22+ msg .reply ("No problem. I've fixed it. \n \n Please be careful next time." )
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import datetime
4+ import os
5+ import random
6+ from twilio .rest import TwilioRestClient
7+ import subprocess
8+ import sys
9+ from time import strftime
10+
11+
12+ today = datetime .date .today ()
13+
14+ # skip weekends
15+ if today .strftime ('%A' ) == 'Saturday' | | today ('%A' ) == 'Sunday' :
16+ sys .exit ()
17+
18+ # exit if no sessions with my username are found
19+ output = subprocess .check_output ('who' )
20+ if 'my_username' not in output :
21+ sys .exit ()
22+
23+ # returns 'None' if the key doesn't exist
24+ TWILIO_ACCOUNT_SID = os .environ .get ('TWILIO_ACCOUNT_SID' )
25+ TWILIO_AUTH_TOKEN = os .environ .get ('TWILIO_AUTH_TOKEN' )
26+
27+ # Phone numbers
28+ my_number = '+xxx'
29+ her_number = '+xxx'
30+
31+ reasons = [
32+ 'Working hard' ,
33+ 'Gotta ship this feature' ,
34+ 'Someone fucked the system again'
35+ ]
36+
37+ client = TwilioRestClient (TWILIO_ACCOUNT_SID , TWILIO_AUTH_TOKEN )
38+
39+ client .messages .create (
40+ to = her_number ,
41+ from = my_number ,
42+ body = "Late at work. " + random .choice (reasons )
43+ )
44+
45+ try :
46+ f = open ('logs/file.txt' , 'a' )
47+ except IOError as e :
48+ # dir & file don't exist; create them
49+ os .mkdir ('logs' )
50+ f = open ('logs/file.txt' , 'a' )
51+ except Exception as e :
52+ print e
53+ else :
54+ pass
55+
56+ # log it
57+ f .write ("Message sent at " + strftime ("%a, %d %b %Y %H:%M:%S" ) + "\n " )
58+ f .close ()
You can’t perform that action at this time.
0 commit comments