diff --git a/README.md b/README.md index bfda095..a5f0950 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,16 @@ Pull requests with other implementations (Python, Perl, Shell, etc) are welcome. You need these environment variables: ```sh +# used in `smack-my-bitch-up`, `fucking-coffee` and `hangover` scripts +USER= + # used in `smack-my-bitch-up` and `hangover` scripts -TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -TWILIO_AUTH_TOKEN=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +TWILIO_ACCOUNT_SID= +TWILIO_AUTH_TOKEN= # used in `kumar_asshole` script -GMAIL_USERNAME=admin@example.org -GMAIL_PASSWORD=password +GMAIL_USERNAME= +GMAIL_PASSWORD= ``` For Ruby scripts you need to install gems: diff --git a/python/README.md b/python/README.md new file mode 100644 index 0000000..bb42be7 --- /dev/null +++ b/python/README.md @@ -0,0 +1,8 @@ +### Python port of the hacker-scripts code + + +#### Prerequisites + +Apart from setting the environment variables per main README file, install all required libraries (preferably in a virtual environment) + + pip install -r requirements.txt \ No newline at end of file diff --git a/python/fucking_coffee.py b/python/fucking_coffee.py index c19572f..68827d8 100755 --- a/python/fucking_coffee.py +++ b/python/fucking_coffee.py @@ -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() diff --git a/python/hangover.py b/python/hangover.py index b1903cd..fef8c54 100755 --- a/python/hangover.py +++ b/python/hangover.py @@ -7,23 +7,22 @@ from time import strftime import subprocess # exit if sessions with my username are found -output = subprocess.check_output('who') -if 'my_username' 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' number_of_boss = '+xxx' excuses = [ - 'Locked out', - 'Pipes broke', - 'Food poisoning', - 'Not feeling well' + 'Locked out', + 'Pipes broke', + 'Food poisoning', + 'Not feeling well' ] client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) diff --git a/python/kumar_asshole.py b/python/kumar_asshole.py index 36f5f67..96ebe55 100755 --- a/python/kumar_asshole.py +++ b/python/kumar_asshole.py @@ -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.") diff --git a/python/requirements.txt b/python/requirements.txt new file mode 100644 index 0000000..931de55 --- /dev/null +++ b/python/requirements.txt @@ -0,0 +1,6 @@ +gmail==0.5 +httplib2==0.9.2 +pytz==2015.7 +six==1.10.0 +twilio==4.9.2 +wheel==0.24.0 diff --git a/python/smack_my_bitch_up.py b/python/smack_my_bitch_up.py index 02c7e05..e4e90da 100755 --- a/python/smack_my_bitch_up.py +++ b/python/smack_my_bitch_up.py @@ -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)