示例#1
0
    def load_scene(self, client, scene_name, params = None):
        """Either renders the template to confirm loading up a region, or handle the scene loading process ifself

        :param Client client: The requesting client
        :param str scene_name: The scene's name to operate on
        :param dict params: Optional; contains the form parameters
        :return: dict - Status and Html-layout data response
        """
        if params == None:
            regions = Regions.get_regions()
            selection = []
            for region in regions:
                selection.append((region['RegionUUID'],region['name']))
            form = LoadSceneForm(choices=selection,initial={'scene_name':scene_name})
            dialog = render_to_string("opensim/load_scene_confirmation.html", {'form':form})
            defer.returnValue({'data':{'dom':{'dialog':dialog}}})
        else:
            response = {'status':{}}
            region = Regions.get_region(params['region_uuid'])
            service_client = HWIOS.pb_server.search_service(region['service_uuid'])
            result = yield service_client['client'].load_scene(region['service_uuid'],params['region_uuid'], params['scene_name'])
            if 'loaded' in result:
                if result['loaded']:
                    response = {
                        'status':{
                            'code':'RESTORE_MADE',
                            'i18n':_('Succesfully restored scene %(scene)s in region %(region)s...') % {'scene':params['scene_name'],'region':region['name']},
                            'type': HWIOS.ws_realm._t['notify-info']
                        }
                    }
            else:
                if 'RADMIN_FAILED' in result['status']['code']:
                    response = {
                        'status':{
                            'code':'RADMIN_FAILED',
                            'i18n':_(result['status']['feedback']),
                            'type': HWIOS.ws_realm._t['notify-error']
                        }
                    }
                elif 'error' in result:
                    if result['error'] == 'SIM_OFFLINE':
                        response = {
                            'status':{
                                'code':'RESTORE_FAILED',
                                'i18n':_('Restore failed! Region must be online when loading a scene...'),
                                'type': HWIOS.ws_realm._t['notify-error']
                            }
                        }
                    elif result['error'] == 'radmin response timed out':
                        response = {
                            'status':{
                                'code':'RESTORE_RUNNING',
                                'i18n':_('Loading this OAR may take a while. Check the console for the current progress...'),
                                'type': HWIOS.ws_realm._t['notify-info']
                            }
                        }
            main = render_to_string("opensim/read_regions.html", {'region_services': Regions().get_region_services(),'scenes':Scenes.get_scenes()})
            response.update({'data':{'dom':{'main':main}}})
            defer.returnValue(response)
示例#2
0
文件: opensim.py 项目: mmetzmac/hwios
 def _get_regions(self, client):
     scenes = Scenes.get_scenes()
     regions = Regions.get_regions()
     tpl_params = {'regions': regions,'scenes':scenes}
     main = render_to_string("opensim/read_regions.html", tpl_params)
     return [
         {'data':{'dom':{'main':main}}},
         {'main':{'tpl':'opensim/read_regions.html','params':tpl_params}}
     ]
示例#3
0
 def _get_regions(self, client):
     """Notify_others helper that gets the template-info and rendering of the regions view"""
     scenes = Scenes.get_scenes()
     regions = Regions.get_regions()
     tpl_params = {'regions': regions,'scenes':scenes}
     main = render_to_string("opensim/read_regions.html", tpl_params)
     return [
         {'data':{'dom':{'main':main}}},
         {'main':{'tpl':'opensim/read_regions.html','params':tpl_params}}
     ]
示例#4
0
文件: opensim.py 项目: mmetzmac/hwios
 def view_regions(self, client):
     scenes = Scenes.get_scenes()
     regions = Regions.get_regions()
     region_services = Regions().get_region_services()
     for count1,region_service in enumerate(region_services):
         for count2,region in enumerate(region_service['regions']):
             try:
                 if 'MasterAvatarUUID' in region:
                     profile = Profile.objects.get(uuid = region['MasterAvatarUUID'])
                     region_services[count1]['regions'][count2]['profile'] = {'first_name':profile.first_name,'last_name':profile.last_name}
                 else:
                     region_services[count1]['regions'][count2]['profile'] = {'first_name':'Invalid','last_name':'Invalid'}
             except ObjectDoesNotExist,KeyError:
                 region_services[count1]['regions'][count2]['profile'] = {'first_name':'Invalid','last_name':'Invalid'}
示例#5
0
def upload_scenes(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','oar',file_name), 'w')
        f.write(content)
        scenes = Scenes.get_scenes()
        regions = Regions.get_regions()
        main = render_to_string("opensim/read_regions.html", {'regions': regions,'scenes':scenes}, context_instance=RequestContext(request))
        return JSONResponse({
            'status':{
                'code':'FILE_UPLOADED',
                'i18n':_('File(s) succesfully uploaded'),
                'type': HWIOS.ws_realm._t['notify-warning']
            },
            'data':{'dom':{'main':main}}
        })
示例#6
0
    def view_regions(self, client):
        """Renders the current available regions view

        :param Client client: The requesting client
        :return: dict - Html-layout data response
        """
        #check if grid db exists first.
        scenes = Scenes.get_scenes()
        regions = Regions.get_regions()
        region_services = Regions().get_region_services()
        for count1,region_service in enumerate(region_services):
            for count2,region in enumerate(region_service['regions']):
                try:
                    if 'MasterAvatarUUID' in region:
                        profile = Profile.objects.get(uuid = region['MasterAvatarUUID'])
                        region_services[count1]['regions'][count2]['profile'] = {'first_name':profile.first_name,'last_name':profile.last_name}
                    else:
                        region_services[count1]['regions'][count2]['profile'] = {'first_name':'Invalid','last_name':'Invalid'}
                except ObjectDoesNotExist,KeyError:
                    region_services[count1]['regions'][count2]['profile'] = {'first_name':'Invalid','last_name':'Invalid'}