Beispiel #1
0
    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)
Beispiel #2
0
 def delete_luggage(self, client, params = None):
     if params == None:
         dialog = render_to_string("opensim/delete_luggage_confirmation.html")
         return {'data':{'dom':{'dialog':dialog}}}
     else:
         deleted = Luggage.delete_luggage(params)
         online_simulators = Simulators.get_simulators(online=True)
         if deleted: 
             response = {
                 'status':{
                     'code':'SCENES_DELETE_OK',
                     'i18n':_('Deleted: %(deleted)s inventory archive file(s) ') % {'deleted':deleted},
                     'type': HWIOS.ws_realm._t['notify-info']
                 }
             }
         else: 
             response = {
                 'status':{
                     'code':'SCENES_DELETE_FAIL',
                     'i18n':_('Failed to delete inventory archive file(s). Invalid characters!'),
                     'type': HWIOS.ws_realm._t['notify-error']
                 }
             }
         response.update(self.view_avatars(client))
         return response
Beispiel #3
0
    def delete_luggage(self, client, params = None):
        """Either renders the template that shows the dialog to confirm lugguge deletion,
        or handle the luggage deletion process itself.

        :param Client client: The requesting client
        :param dict params: Optional; contains the form parameters
        :return: dict - Status and Html-layout data response
        """
        if params == None:
            dialog = render_to_string("opensim/delete_luggage_confirmation.html")
            return {'data':{'dom':{'dialog':dialog}}}
        else:
            deleted = Luggage.delete_luggage(params)
            online_simulators = Simulators.get_simulators(online=True)
            if deleted: 
                response = {
                    'status':{
                        'code':'SCENES_DELETE_OK',
                        'i18n':_('Deleted: %(deleted)s inventory archive file(s) ') % {'deleted':deleted},
                        'type': HWIOS.ws_realm._t['notify-info']
                    }
                }
            else: 
                response = {
                    'status':{
                        'code':'SCENES_DELETE_FAIL',
                        'i18n':_('Failed to delete inventory archive file(s). Invalid characters!'),
                        'type': HWIOS.ws_realm._t['notify-error']
                    }
                }
            response.update(self.view_avatars(client))
            return response
Beispiel #4
0
 def _get_avatars(self, client):
     profiles = OSUserAccounts.objects.using('grid').all()
     luggage = Luggage.get_luggage()
     online_simulators = Simulators.get_simulators(online=True)
     tpl_params = {'profiles':profiles,'luggage':luggage,'online_simulators':len(online_simulators)}
     main = render_to_string("opensim/read_avatars.html", tpl_params)
     return [
         {'data':{'dom':{'main':main}}},
         {'main':{'tpl':'opensim/read_avatars.html','params':tpl_params}}
     ]
Beispiel #5
0
    def view_avatars(self, client):
        """Renders the template that shows the avatars available. 

        :param Client client: The requesting client
        :return: dict - Html-layout data response
        """        
        profiles = OSUserAccounts.objects.using('grid').all()
        luggage = Luggage.get_luggage()
        online_simulators = Simulators.get_simulators(online=True)
        main = render_to_string("opensim/read_avatars.html", {'profiles':profiles,'luggage':luggage,'online_simulators':len(online_simulators)})
        return {'data':{'dom':{'main':main}}}
Beispiel #6
0
 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)
Beispiel #7
0
def upload_luggage(request):
    if request.method == "POST":
        file_size = request.META['HTTP_X_FILE_SIZE']
        file_name = request.META['HTTP_X_FILE_NAME']
        location = HWIOS.services['web_ui'].config.location
        content = request.raw_post_data
        f = open(os.path.join(location,'dav_store','iar',file_name), 'w')
        f.write(content)
        luggage = Luggage.get_luggage()
        online_simulators = Simulators.get_simulators(online=True)
        response = {
            'status':{
                'code':'FILE_UPLOADED',
                'i18n':'File(s) succesfully uploaded',
                'type': HWIOS.ws_realm._t['notify-info']
                }
        }
        luggage = Luggage.get_luggage()
        online_simulators = Simulators.get_simulators(online=True)
        profiles = OSUserAccounts.objects.using('grid').all()
        main = render_to_string("opensim/read_avatars.html", {'profiles':profiles,'luggage':luggage,'online_simulators':len(online_simulators)})
        response.update({'data':{'dom':{'main':main}}})
        return JSONResponse(response)    
Beispiel #8
0
 def view_avatars(self, client):
     profiles = OSUserAccounts.objects.using('grid').all()
     luggage = Luggage.get_luggage()
     online_simulators = Simulators.get_simulators(online=True)
     main = render_to_string("opensim/read_avatars.html", {'profiles':profiles,'luggage':luggage,'online_simulators':len(online_simulators)})
     return {'data':{'dom':{'main':main}}}