def backup_luggage(self, client, profile_uuid = None, params = None): """Either renders the template that shows the dialog to backup lugguge, or handle the backup luggage process itself. :param Client client: The requesting client :param str profile_uuid: The profile's uuid to operate on :param dict params: Optional; contains the form parameters :return: dict - Status and Html-layout data response """ if params == None: online_simulators = Simulators.get_simulators(online=True) selection = [] profile = Profile.objects.get(uuid=profile_uuid) for simulator in online_simulators: selection.append((simulator['uuid'],simulator['name'])) current_time = time.strftime('%Y-%m-%d-%H.%M') proposed_name = '%s_%s-%s' % (profile.first_name,profile.last_name,current_time) form = BackupLuggageForm(choices=selection,initial={'luggage_name':proposed_name}) dialog = render_to_string("opensim/backup_luggage_confirmation.html", {'form':form}) response ={'data':{'dom':{'dialog':dialog}}} defer.returnValue(response) else: #{'simulator_uuid': '5ced4744-f5b7-4100-9a4e-40ab73ec5c0c', 'inventory_dir': '/', 'luggage_name': 'InventoryDump.iar', 'avatar': '13'} response = {'status':{},'data':{}} online_simulators = Simulators.get_simulators(online=True) profile = Profile.objects.get(uuid=params['profile_uuid']) selection = [] for simulator in online_simulators: selection.append((simulator['uuid'],simulator['name'])) form = BackupLuggageForm(params,choices=selection,profile=profile) if form.is_valid(): simulator = Simulators.get_simulator(params['simulator_uuid']) service_client = HWIOS.pb_server.search_service(params['simulator_uuid']) result = yield service_client['client'].backup_luggage(params['simulator_uuid'],[profile.first_name,profile.last_name,params['password']],params['inventory_dir'],params['luggage_name']) luggage = Luggage.get_luggage() profiles = Profile.objects.all() main = render_to_string("opensim/read_avatars.html", {'profiles':profiles,'luggage':luggage,'online_simulators':len(online_simulators)}) response['status'] = { 'code':'LUGGAGE_LOAD_OK', 'i18n':_('Trying to backup luggage file. Check your avatar in-world for the notification, or open the remote console for further information...'), 'type': HWIOS.ws_realm._t['notify-info'] } response['data']['dom'] = {'main':main} else: response['status'] = { 'code':'FORM_INVALID', 'i18n':_('Invalid form...'), 'type': HWIOS.ws_realm._t['notify-warning'] } dialog = render_to_string("opensim/backup_luggage_confirmation.html", {'form':form}) response['data']['dom'] = {'dialog':dialog} defer.returnValue(response)
def load_luggage(self, client, luggage_name, params = None): if params == None: online_simulators = Simulators.get_simulators(online=True) selection = [] for simulator in online_simulators: selection.append((simulator['uuid'],simulator['name'])) form = LoadLuggageForm(choices=selection,initial={'luggage_name':luggage_name}) dialog = render_to_string("opensim/load_luggage_confirmation.html", {'form':form}) response = {'data':{'dom':{'dialog':dialog}}} defer.returnValue(response) else: #{'simulator_uuid': '5ced4744-f5b7-4100-9a4e-40ab73ec5c0c', 'inventory_dir': '/', 'luggage_name': 'InventoryDump.iar', 'avatar': '13'} response = {'status':{}} online_simulators = Simulators.get_simulators(online=True) selection = [] for simulator in online_simulators: selection.append((simulator['uuid'],simulator['name'])) form = LoadLuggageForm(params,choices=selection) if form.is_valid(): profile = form.cleaned_data['avatar'] simulator = Simulators.get_simulator(params['simulator_uuid']) service_client = HWIOS.pb_server.search_service(params['simulator_uuid']) result = yield service_client['client'].load_luggage(params['simulator_uuid'],[profile.first_name,profile.last_name,params['password']],params['inventory_dir'],params['luggage_name']) luggage = Luggage.get_luggage() profiles = Profile.objects.all() main = render_to_string("opensim/read_avatars.html", {'profiles':profiles,'luggage':luggage,'online_simulators':len(online_simulators)}) response['status'] = { 'code':'LUGGAGE_LOAD_OK', 'i18n':_('Trying to load luggage file. Check your avatar in-world for the notification, or open the remote console for further information...'), 'type': HWIOS.ws_realm._t['notify-info'] } response['dom'] = {'main':main} else: response['status'] = { 'code':'FORM_INVALID', 'i18n':_('Invalid form...'), 'type': HWIOS.ws_realm._t['notify-warning'] } dialog = render_to_string("opensim/load_luggage_confirmation.html", {'form':form}) response['dom'] = {'dialog':dialog} defer.returnValue(response)