#NEWLINE# def step3_live( request ) : #NEWLINE# #INDENT# constants = settings . CONSTANTS #NEWLINE# STEP_3_TEMPLATE_NAME = constants [ 'STEP_3_TEMPLATE_NAME_LIVE' ] #NEWLINE# STEP_4_TEMPLATE_NAME = constants [ 'STEP_4_TEMPLATE_NAME_LIVE' ] #NEWLINE# CLIENT_ID = constants [ 'CLIENT_ID' ] #NEWLINE# REDIRECT_URI = constants [ 'REDIRECT_URI_LIVE' ] #NEWLINE# GET_SUBSCRIPTIONS_URL = constants [ 'GET_SUBSCRIPTIONS_URL' ] #NEWLINE# MS_API_VERSION_HEADER = constants [ 'MS_API_VERSION_HEADER' ] #NEWLINE# MS_API_VERSION_HEADER_VALUE = constants [ 'MS_API_VERSION_HEADER_VALUE' ] #NEWLINE# context = { #NEWLINE# #INDENT# 'initialize' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# if ( request . method == 'GET' ) : #NEWLINE# #INDENT# return render ( request , STEP_3_TEMPLATE_NAME , context ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# token = request . session [ 'token' ] #NEWLINE# azure_session = OAuth2Session ( CLIENT_ID , redirect_uri = REDIRECT_URI , token = token ) #NEWLINE# resp = azure_session . get ( GET_SUBSCRIPTIONS_URL , headers = { #NEWLINE# #INDENT# MS_API_VERSION_HEADER : MS_API_VERSION_HEADER_VALUE , #NEWLINE# #UNINDENT# } ) #NEWLINE# dom = parseString ( resp . content ) #NEWLINE# subscriptions = dom . getElementsByTagName ( 'Subscription' ) #NEWLINE# output = [ ] #NEWLINE# tenantText = 'No subscriptions found in list.' #NEWLINE# for subscription in subscriptions : #NEWLINE# #INDENT# name = subscription . getElementsByTagName ( 'SubscriptionName' ) [ 0 ] #NEWLINE# nameText = getText ( name . childNodes ) #NEWLINE# output . append ( nameText ) #NEWLINE# tenantid = subscription . getElementsByTagName ( 'AADTenantID' ) [ 0 ] #NEWLINE# tenantText = getText ( tenantid . childNodes ) #NEWLINE# output . append ( tenantText ) #NEWLINE# #UNINDENT# context [ 'subscriptions' ] = output #NEWLINE# request . session [ 'tenantid' ] = tenantText #NEWLINE# return render ( request , STEP_4_TEMPLATE_NAME , context )