Created
July 1, 2014 22:05
-
-
Save ankona/7b3587ee6bd005cf9604 to your computer and use it in GitHub Desktop.
test harness for requesting launch URLs from UCMS
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 webapp2 | |
from lib import auth | |
from lib import keys | |
import logging | |
# call the UCMS launch URL endpoint and retrieve the url to open the KAPx session with the supplied UCMS ID. | |
def get_launch_url(ucms_id, headers): | |
krc = auth.KapRestClient(keys.AuthKeys.AUTH_PREFIX, | |
keys.AuthKeys.SECRET_KEY, | |
keys.AuthKeys.ACCESS_KEY) | |
launch_url = "" | |
try: | |
launch_url = krc.request_uri('http://kaplandevucms.appspot.com/record/' + ucms_id + '/embed', headers) | |
except Exception as e: | |
logging.error(e) | |
return launch_url | |
class UCMSLaunchHandler(webapp2.RequestHandler): | |
# Default view for test harness - returns a URL that can launch into a KAPx session | |
def get(self, ucms_id): | |
headers = {} | |
launch_url = get_launch_url(ucms_id, headers) | |
if launch_url and (len(launch_url) > 0): | |
self.response.write(launch_url) | |
else: | |
self.response.write("failed to retrieve launch_url") | |
app = webapp2.WSGIApplication([ | |
webapp2.Route('/ucmslaunch/<ucms_id:\d+>', UCMSLaunchHandler) | |
], debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment