Created
March 16, 2015 05:31
-
-
Save ameerkat/2e2afee8eb4eeaf29d9f to your computer and use it in GitHub Desktop.
Send yourself a text and screenshot url. Useful for monitoring a long pending build/deploy operation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tempfile, uuid, pyscreenshot | |
from twilio.rest import TwilioRestClient | |
from azure.storage import BlobService | |
# Your Account Sid and Auth Token from twilio.com/user/account | |
twilio_account_sid = "" | |
twilio_auth_token = "" | |
client = TwilioRestClient(twilio_account_sid, twilio_auth_token) | |
# Screencap | |
im=pyscreenshot.grab() | |
fileid = str(uuid.uuid1()) | |
fullpath = tempfile.gettempdir() + "\\" + fileid + ".jpeg" | |
im.save(fullpath, 'JPEG', quality=25) | |
print fullpath | |
# Upload | |
azure_storage_account_name = '' | |
azure_storage_container_name = '' | |
blob_service = BlobService(account_name=azure_storage_account_name, account_key='') | |
blob_service.create_container('', x_ms_blob_public_access='container') # public so that text can access | |
blob_service.put_block_blob_from_path( | |
azure_storage_container_name, | |
fileid, | |
fullpath, | |
x_ms_blob_content_type='image/jpeg') | |
# replace tokens below with actual values for url format | |
media_url = "http://" + azure_storage_account_name + ".blob.core.windows.net/"+ azure_storage_container_name +"/" + fileid | |
print media_url | |
# change this to whatever you want | |
message_body = "Action Completed. " + media_url | |
if(len(argv) > 1): | |
message_body = argv[1] | |
message = client.messages.create(body=message_body, | |
to="+1XXXXXXXXXX", # Replace with your phone number | |
from_="+1XXXXXXXXXX") # Replace with your Twilio number | |
print message.sid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment