def download(request, username): validuser = True try: # validate that this username actually exists user = interface.get_user_for_installers(username) except DoesNotExistError: validuser = False return direct_to_template(request, 'download/installers.html', {'username' : username, 'validuser' : validuser})
def _build_installer(username, platform): """ <Purpose> Builds an installer for the given platform that will donate resources to the user with the given username. <Arguments> username: A string representing the GENI user to which the installer will donate resources. platform: A string representing the platform for which to build the installer. Options include 'windows', 'linux', or 'mac'. <Exceptions> None <Side Effects> None <Returns> On success, returns (True, installer_url) where installer_url is URL from which the installer may be downloaded. On failure, returns (False, error_response) where error_repsponse is an HttpResponse which specifies what went wrong. """ try: user = interface.get_user_for_installers(username) username = user.username except DoesNotExistError: error_response = HttpResponse("Couldn't get user.") return False, error_response try: xmlrpc_proxy = xmlrpclib.ServerProxy( settings.SEATTLECLEARINGHOUSE_INSTALLER_BUILDER_XMLRPC) vessel_list = [{'percentage': 80, 'owner': 'owner', 'users': ['user']}] user_data = { 'owner': { 'public_key': user.donor_pubkey }, 'user': { 'public_key': ACCEPTDONATIONS_STATE_PUBKEY }, } build_results = xmlrpc_proxy.build_installers(vessel_list, user_data) except: error_response = HttpResponse("Failed to build installer.") return False, error_response installer_url = build_results['installers'][platform] return True, installer_url
def _build_installer(username, platform): """ <Purpose> Builds an installer for the given platform that will donate resources to the user with the given username. <Arguments> username: A string representing the GENI user to which the installer will donate resources. platform: A string representing the platform for which to build the installer. Options include 'windows', 'linux', or 'mac'. <Exceptions> None <Side Effects> None <Returns> On success, returns (True, installer_url) where installer_url is URL from which the installer may be downloaded. On failure, returns (False, error_response) where error_repsponse is an HttpResponse which specifies what went wrong. """ try: user = interface.get_user_for_installers(username) username = user.username except DoesNotExistError: error_response = HttpResponse("Couldn't get user.") return False, error_response try: xmlrpc_proxy = xmlrpclib.ServerProxy(settings.INSTALLER_BUILDER_XMLRPC) vessel_list = [{'percentage': 80, 'owner': 'owner', 'users': ['user']}] user_data = { 'owner': {'public_key': user.donor_pubkey}, 'user': {'public_key': ACCEPTDONATIONS_STATE_PUBKEY}, } build_results = xmlrpc_proxy.build_installers(vessel_list, user_data) except: error_response = HttpResponse("Failed to build installer.") return False, error_response installer_url = build_results['installers'][platform] return True, installer_url
def download(request, username): validuser = True try: # validate that this username actually exists user = interface.get_user_for_installers(username) except DoesNotExistError: validuser = False templatedict = {} templatedict['username'] = username templatedict['validuser'] = validuser templatedict['domain'] = "https://" + request.get_host() # I need to build a URL for android to download the installer from. (The # same installer is downloaded from the Google Play store for all users.) # The URL is escaped twice (ask Akos why) and inserted in the referrer # information in the URL. #templatedict['android_installer_link'] = urllib.quote(urllib.quote(domain,safe=''),safe='') return direct_to_template(request, 'download/installers.html', templatedict)