Last active
August 29, 2015 14:04
-
-
Save bgerstle/3b0b389a94d149a65108 to your computer and use it in GitHub Desktop.
Generates a link to a Sauce Labs job that anyone can access, using a permanent access token
This file contains hidden or 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
#! /usr/bin/env python | |
import hmac | |
import sys | |
import os | |
from hashlib import md5 | |
def exit_with_usage(): | |
print """ | |
Usage: gen_no_login job_id [username] [access_key] | |
username and access_key can also be derived from the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables, respectively. | |
""" | |
sys.exit(1) | |
def main(): | |
if len(sys.argv) < 2: | |
exit_with_usage() | |
job_id = sys.argv[1] | |
try: | |
username = os.getenv('SAUCE_USERNAME', sys.argv[2]) | |
except: | |
print "No username provided!" | |
exit_with_usage() | |
try: | |
access_key = os.getenv('SAUCE_ACCESS_KEY', sys.argv[3]) | |
except: | |
print "No access key provided!" | |
exit_with_usage() | |
token = hmac.new("{user}:{key}".format(user=username, key=access_key), | |
job_id, | |
md5).hexdigest() | |
print "https://saucelabs.com/jobs/{job}?auth={token}".format(job=job_id, token=token) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment