当前位置: 首页>>代码示例>>Python>>正文


Python common.get_current_project函数代码示例

本文整理汇总了Python中tvb.interfaces.web.controllers.common.get_current_project函数的典型用法代码示例。如果您正苦于以下问题:Python get_current_project函数的具体用法?Python get_current_project怎么用?Python get_current_project使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_current_project函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: store_exploration_section

    def store_exploration_section(self, val_range, step, dt_group_guid):
        """
        Launching method for further simulations.
        """
        range_list = [float(num) for num in val_range.split(",")]
        step_list = [float(num) for num in step.split(",")]

        datatype_group_ob = ProjectService().get_datatypegroup_by_gid(dt_group_guid)
        operation_grp = datatype_group_ob.parent_operation_group
        operation_obj = self.flow_service.load_operation(datatype_group_ob.fk_from_operation)
        parameters = json.loads(operation_obj.parameters)

        range1name, range1_dict = json.loads(operation_grp.range1)
        range2name, range2_dict = json.loads(operation_grp.range2)
        parameters[RANGE_PARAMETER_1] = range1name
        parameters[RANGE_PARAMETER_2] = range2name

        ##change the existing simulator parameters to be min max step types
        range1_dict = {constants.ATT_MINVALUE: range_list[0],
                       constants.ATT_MAXVALUE: range_list[1],
                       constants.ATT_STEP: step_list[0]}
        range2_dict = {constants.ATT_MINVALUE: range_list[2],
                       constants.ATT_MAXVALUE: range_list[3],
                       constants.ATT_STEP: step_list[1]}
        parameters[range1name] = json.dumps(range1_dict)  # this is for the x axis parameter
        parameters[range2name] = json.dumps(range2_dict)  # this is for the y axis parameter

        OperationService().group_operation_launch(common.get_logged_user().id, common.get_current_project().id,
                                                  operation_obj.algorithm.id, operation_obj.algorithm.fk_category,
                                                  datatype_group_ob, **parameters)

        return [True, 'Stored the exploration material successfully']
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:32,代码来源:flow_controller.py

示例2: launch_burst

    def launch_burst(self, launch_mode, burst_name, **data):
        """
        Do the actual burst launch, using the configuration saved in current session.
        :param launch_mode: new/branch/continue
        :param burst_name: user-given burst name. It can be empty (case in which we will fill with simulation_x)
        :param data: kwargs for simulation input parameters.
        """
        data = json.loads(data['simulator_parameters'])
        burst_config = common.get_from_session(common.KEY_BURST_CONFIG)

        ## Validate new burst-name
        if launch_mode == LAUNCH_NEW and burst_name != 'none_undefined':
            validation_result = self._is_burst_name_ok(burst_name)
            if validation_result is True:
                burst_config.name = burst_name
            else:
                return {'error': validation_result}

        ## Fill all parameters 
        user_id = common.get_logged_user().id
        data[common.KEY_ADAPTER] = self.cached_simulator_algorithm_id
        burst_config.update_simulator_configuration(data)
        burst_config.fk_project = common.get_current_project().id

        ## Do the asynchronous launch
        try:
            burst_id, burst_name = self.burst_service.launch_burst(burst_config, 0, self.cached_simulator_algorithm_id,
                                                                   user_id, launch_mode)
            return {'id': burst_id, 'name': burst_name}
        except BurstServiceException, e:
            self.logger.exception("Could not launch burst!")
            return {'error': e.message}
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:32,代码来源:burst_controller.py

示例3: _compute_operation_details

    def _compute_operation_details(self, entity_gid, is_group=False):
        """
        Returns a dictionary which contains the details for the given operation.
        """
        selected_project = common.get_current_project()
        op_details = self.project_service.get_operation_details(entity_gid, is_group)
        operation_id = op_details.operation_id

        display_reload_btn = True
        operation = self.flow_service.load_operation(operation_id)

        if (operation.fk_operation_group is not None) or (operation.burst is not None):
            display_reload_btn = False
        else:
            op_categ_id = operation.algorithm.algo_group.fk_category
            raw_categories = self.flow_service.get_raw_categories()
            for category in raw_categories:
                if category.id == op_categ_id:
                    display_reload_btn = False
                    break

        template_specification = {"entity_gid": entity_gid,
                                  "nodeFields": op_details.get_ui_fields(),
                                  "operationId": operation_id,
                                  "displayReloadBtn": display_reload_btn,
                                  "project": selected_project,
                                  "isRelevant": operation.visible}
        return template_specification
开发者ID:unimauro,项目名称:tvb-framework,代码行数:28,代码来源:project_controller.py

示例4: invokeadaptermethod

    def invokeadaptermethod(self, adapter_id, method_name, **data):
        """
        Public web method, to be used when invoking specific 
        methods from external Adapters/Algorithms.
        """
        algo_group = self.flow_service.get_algo_group_by_identifier(adapter_id)
        try:
            adapter_instance = self.flow_service.build_adapter_instance(algo_group)
            result = self.flow_service.fire_operation(adapter_instance, common.get_logged_user(),
                                                      common.get_current_project().id, method_name, **data)
            common.set_info_message("Submit OK!")
            if isinstance(adapter_instance, ABCDisplayer) and isinstance(result, dict):
                common.pop_message_from_session()
                result[ABCDisplayer.KEY_IS_ADAPTER] = True
                result[common.KEY_DISPLAY_MENU] = True
                result[common.KEY_OPERATION_ID] = adapter_instance.operation_id
                result[common.KEY_ADAPTER] = adapter_id
                if KEY_CONTROLLS not in result:
                    result[KEY_CONTROLLS] = None
                self._populate_section(algo_group, result)
                return self.fill_default_attributes(result, algo_group.displayname)

        except OperationException, excep:
            common.set_warning_message('Problem when submitting data!')
            self.logger.error("Invalid method, or wrong  parameters when invoking external method on post!")
            self.logger.exception(excep)
开发者ID:rajul,项目名称:tvb-framework,代码行数:26,代码来源:flow_controller.py

示例5: load_burst_from_json

    def load_burst_from_json(self, **data):
        """Upload Burst from previously exported JSON file"""
        self.logger.debug("Uploading ..." + str(data))

        try:
            upload_param = "uploadedfile"
            if upload_param in data and data[upload_param]:

                upload_param = data[upload_param]
                if isinstance(upload_param, FieldStorage) or isinstance(upload_param, Part):
                    if not upload_param.file:
                        raise BurstServiceException("Please select a valid JSON file.")
                    upload_param = upload_param.file.read()

                upload_param = json.loads(upload_param)
                prj_id = common.get_current_project().id
                importer = ImportService()
                burst_entity = importer.load_burst_entity(upload_param, prj_id)
                common.add2session(common.KEY_BURST_CONFIG, burst_entity)

        except Exception as excep:
            self.logger.warning(excep.message)
            common.set_error_message(excep.message)

        raise cherrypy.HTTPRedirect('/burst/')
开发者ID:maedoc,项目名称:tvb-framework,代码行数:25,代码来源:burst_controller.py

示例6: getfiltereddatatypes

    def getfiltereddatatypes(self, name, parent_div, tree_session_key, filters):
        """
        Given the name from the input tree, the dataType required and a number of
        filters, return the available dataType that satisfy the conditions imposed.
        """
        previous_tree = self.context.get_session_tree_for_key(tree_session_key)
        if previous_tree is None:
            common.set_error_message("Adapter Interface not in session for filtering!")
            raise cherrypy.HTTPRedirect("/tvb?error=True")
        current_node = self._get_node(previous_tree, name)
        if current_node is None:
            raise Exception("Could not find node :" + name)
        datatype = current_node[ABCAdapter.KEY_DATATYPE]

        filters = json.loads(filters)
        availablefilter = json.loads(FilterChain.get_filters_for_type(datatype))
        for i, filter_ in enumerate(filters[FILTER_FIELDS]):
            #Check for filter input of type 'date' as these need to be converted
            if filter_ in availablefilter and availablefilter[filter_][FILTER_TYPE] == 'date':
                try:
                    temp_date = string2date(filters[FILTER_VALUES][i], False)
                    filters[FILTER_VALUES][i] = temp_date
                except ValueError:
                    raise
        #In order for the filter object not to "stack up" on multiple calls to
        #this method, create a deepCopy to work with
        if ABCAdapter.KEY_CONDITION in current_node:
            new_filter = copy.deepcopy(current_node[ABCAdapter.KEY_CONDITION])
        else:
            new_filter = FilterChain()
        new_filter.fields.extend(filters[FILTER_FIELDS])
        new_filter.operations.extend(filters[FILTER_OPERATIONS])
        new_filter.values.extend(filters[FILTER_VALUES])
        #Get dataTypes that match the filters from DB then populate with values
        values, total_count = InputTreeManager().populate_option_values_for_dtype(
                                    common.get_current_project().id,
                                    datatype, new_filter,
                                    self.context.get_current_step() )
        #Create a dictionary that matches what the template expects
        parameters = {ABCAdapter.KEY_NAME: name,
                      ABCAdapter.KEY_FILTERABLE: availablefilter,
                      ABCAdapter.KEY_TYPE: ABCAdapter.TYPE_SELECT,
                      ABCAdapter.KEY_OPTIONS: values,
                      ABCAdapter.KEY_DATATYPE: datatype}

        if total_count > MAXIMUM_DATA_TYPES_DISPLAYED:
            parameters[KEY_WARNING] = WARNING_OVERFLOW

        if ABCAdapter.KEY_REQUIRED in current_node:
            parameters[ABCAdapter.KEY_REQUIRED] = current_node[ABCAdapter.KEY_REQUIRED]
            if len(values) > 0 and string2bool(str(parameters[ABCAdapter.KEY_REQUIRED])):
                parameters[ABCAdapter.KEY_DEFAULT] = str(values[-1][ABCAdapter.KEY_VALUE])
        previous_selected = self.context.get_current_default(name)
        if previous_selected in [str(vv['value']) for vv in values]:
            parameters[ABCAdapter.KEY_DEFAULT] = previous_selected

        template_specification = {"inputRow": parameters, "disabled": False,
                                  "parentDivId": parent_div, common.KEY_SESSION_TREE: tree_session_key}
        return self.fill_default_attributes(template_specification)
开发者ID:transpersonify,项目名称:tvb-framework,代码行数:59,代码来源:flow_controller.py

示例7: load_burst_history

 def load_burst_history(self):
     """
     Load the available burst that are stored in the database at this time.
     This is one alternative to 'chrome-back problem'.
     """
     session_burst = common.get_from_session(common.KEY_BURST_CONFIG)
     return {'burst_list': self.burst_service.get_available_bursts(common.get_current_project().id),
             'selectedBurst': session_burst.id}
开发者ID:unimauro,项目名称:tvb-framework,代码行数:8,代码来源:burst_controller.py

示例8: reset_burst

 def reset_burst(self):
     """
     Called when click on "New Burst" entry happens from UI.
     This will generate an empty new Burst Configuration.
     """
     common.remove_from_session(common.KEY_CACHED_SIMULATOR_TREE)
     new_burst = self.burst_service.new_burst_configuration(common.get_current_project().id)
     common.add2session(common.KEY_BURST_CONFIG, new_burst)
开发者ID:maedoc,项目名称:tvb-framework,代码行数:8,代码来源:burst_controller.py

示例9: prepare_group_launch

 def prepare_group_launch(self, group_gid, step_key, algorithm_id, **data):
     """
     Receives as input a group gid and an algorithm given by category and id, along
     with data that gives the name of the required input parameter for the algorithm.
     Having these generate a range of GID's for all the DataTypes in the group and
     launch a new operation group.
     """
     prj_service = ProjectService()
     dt_group = prj_service.get_datatypegroup_by_gid(group_gid)
     datatypes = prj_service.get_datatypes_from_datatype_group(dt_group.id)
     range_param_name = data.pop('range_param_name')
     data[RANGE_PARAMETER_1] = range_param_name
     data[range_param_name] = ','.join(dt.gid for dt in datatypes)
     OperationService().group_operation_launch(common.get_logged_user().id, common.get_current_project().id,
                                               int(algorithm_id), int(step_key), **data)
     redirect_url = self._compute_back_link('operations', common.get_current_project())
     raise cherrypy.HTTPRedirect(redirect_url)
开发者ID:transpersonify,项目名称:tvb-framework,代码行数:17,代码来源:flow_controller.py

示例10: _persist_project

 def _persist_project(self, data, project_id, is_create, current_user):
     """Private method to persist"""
     data = EditForm().to_python(data)
     saved_project = self.project_service.store_project(current_user, is_create, project_id, **data)
     selected_project = common.get_current_project()
     if len(self.project_service.retrieve_projects_for_user(current_user.id, 1)) == 1:
         selected_project = saved_project
     if selected_project is None or (saved_project.id == selected_project.id):
         self._mark_selected(saved_project)
开发者ID:unimauro,项目名称:tvb-framework,代码行数:9,代码来源:project_controller.py

示例11: index

 def index(self):
     """
     Display project main-menu. Choose one project to work with.
     """
     current_project = common.get_current_project()
     if current_project is None:
         raise cherrypy.HTTPRedirect("/project/viewall")
     template_specification = dict(mainContent="project_submenu", title="TVB Project Menu")
     return self.fill_default_attributes(template_specification)
开发者ID:unimauro,项目名称:tvb-framework,代码行数:9,代码来源:project_controller.py

示例12: storeresultfigure

 def storeresultfigure(self, img_type, **kwargs):
     """Create preview for current displayed canvas and 
     store image in current session, for future comparison."""
     project = common.get_current_project()
     user = common.get_logged_user()
     operation_id = kwargs.get("operationId")
     suggested_name = kwargs.get("suggestedName")
     self.figure_service.store_result_figure(project, user, img_type, kwargs['export_data'],
                                             image_name=suggested_name, operation_id=operation_id)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:9,代码来源:figure_controller.py

示例13: get_simple_adapter_interface

 def get_simple_adapter_interface(self, algorithm_id, parent_div='', is_uploader=False):
     """
     AJAX exposed method. Will return only the interface for a adapter, to
     be used when tabs are needed.
     """
     curent_project = common.get_current_project()
     is_uploader = string2bool(is_uploader)
     template_specification = self.get_adapter_template(curent_project.id, algorithm_id, is_uploader)
     template_specification[common.KEY_PARENT_DIV] = parent_div
     return self.fill_default_attributes(template_specification)
开发者ID:transpersonify,项目名称:tvb-framework,代码行数:10,代码来源:flow_controller.py

示例14: editresultfigures

    def editresultfigures(self, remove_figure=False, rename_session=False, remove_session=False, **data):
        """
        This method knows how to handle the following actions:
        remove figure, update figure, remove session and update session.
        """
        project = common.get_current_project()
        user = common.get_logged_user()

        redirect_url = '/project/figure/displayresultfigures'
        if "selected_session" in data and data["selected_session"] is not None and len(data["selected_session"]):
            redirect_url += '/' + data["selected_session"]
            del data["selected_session"]
        figure_id = None
        if "figure_id" in data:
            figure_id = data["figure_id"]
            del data["figure_id"]

        if cherrypy.request.method == 'POST' and rename_session:
            successfully_updated = True
            if "old_session_name" in data and "new_session_name" in data:
                figures_dict, _ = self.figure_service.retrieve_result_figures(project, user, data["old_session_name"])
                for _key, value in figures_dict.iteritems():
                    for figure in value:
                        new_data = {"name": figure.name, "session_name": data["new_session_name"]}
                        success = self._update_figure(figure.id, **new_data)
                        if not success:
                            successfully_updated = False
                if successfully_updated:
                    common.set_info_message("The session was successfully updated!")
                else:
                    common.set_error_message("The session was not successfully updated! "
                                             "There could be some figures that still refer to the old session.")
        elif cherrypy.request.method == 'POST' and remove_session:
            successfully_removed = True
            if "old_session_name" in data:
                figures_dict, _ = self.figure_service.retrieve_result_figures(project, user, data["old_session_name"])
                for _key, value in figures_dict.iteritems():
                    for figure in value:
                        success = self.figure_service.remove_result_figure(figure.id)
                        if not success:
                            successfully_removed = False
                if successfully_removed:
                    common.set_info_message("The session was removed successfully!")
                else:
                    common.set_error_message("The session was not entirely removed!")
        elif cherrypy.request.method == 'POST' and remove_figure and figure_id is not None:
            success = self.figure_service.remove_result_figure(figure_id)
            if success:
                common.set_info_message("Figure removed successfully!")
            else:
                common.set_error_message("Figure could not be removed!")
        elif figure_id is not None:
            self._update_figure(figure_id, **data)
        raise cherrypy.HTTPRedirect(redirect_url)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:54,代码来源:figure_controller.py

示例15: create_stimulus

 def create_stimulus(self):
     """
     Creates a stimulus from the given data.
     """
     context = common.get_from_session(KEY_REGION_CONTEXT)
     local_connectivity_creator = self.get_creator_and_interface(REGION_STIMULUS_CREATOR_MODULE,
                                                                 REGION_STIMULUS_CREATOR_CLASS, StimuliRegion())[0]
     context.equation_kwargs.update({'weight': json.dumps(context.get_weights())})
     self.flow_service.fire_operation(local_connectivity_creator, common.get_logged_user(),
                                      common.get_current_project().id, **context.equation_kwargs)
     common.set_important_message("The operation for creating the stimulus was successfully launched.")
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:11,代码来源:region_stimulus_controller.py


注:本文中的tvb.interfaces.web.controllers.common.get_current_project函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。