tidyed code some more, added reading ENV for other scripts, PEP8 some more

This commit is contained in:
dgmt 2015-12-01 01:04:42 +01:00
parent 4d36e85f82
commit 0039227576
4 changed files with 11 additions and 14 deletions

View File

@ -6,8 +6,7 @@ import telnetlib
import time
# exit if no sessions with my username are found
output = subprocess.check_output('who')
if 'my_username' not in output:
if os.environ.get('USER') in subprocess.check_output('who'):
sys.exit()
coffee_machine_ip = '10.10.42.42'
@ -24,4 +23,4 @@ time.sleep(64)
# love the smell!
con.write("sys pour\n")
con.close()
con.close()

View File

@ -7,9 +7,7 @@ from time import strftime
import subprocess
# exit if sessions with my username are found
output = subprocess.check_output('who')
if os.environ.get('USER') in output:
if os.environ.get('USER') in subprocess.check_output('who'):
sys.exit()
# returns 'None' if the key doesn't exist

View File

@ -19,4 +19,5 @@ pattern = re.compile("\bsorry\b | \bhelp\b | \bwrong\b ", flags=re.I)
for msg in msgs:
if pattern.match(msg.body):
msg.label("Database fixes")
msg.reply("No problem. I've fixed it. \n\n Please be careful next time.")
msg.reply("No problem. I've fixed it. \n\n"
"Please be careful next time.")

View File

@ -8,22 +8,21 @@ import sys
from time import strftime
# exit if no sessions with my username are found
output = subprocess.check_output('who')
if 'my_username' not in output:
if os.environ.get('USER') in subprocess.check_output('who'):
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')
TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN')
# Phone numbers
my_number = '+xxx'
my_number = '+xxx'
her_number = '+xxx'
reasons = [
'Working hard',
'Gotta ship this feature',
'Someone fucked the system again'
'Working hard',
'Gotta ship this feature',
'Someone fucked the system again'
]
client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)